From 5ebdfb891f2b04d24d312f0ca307083be0ebfcc8 Mon Sep 17 00:00:00 2001 From: Edward O'Callaghan Date: Wed, 3 May 2023 16:49:29 +1000 Subject: tests/chip_wp.c: Allow for logging during test Hook logging callback so unit-tests print what they are doing. This make debug far easier for a failing test. BUG=none TEST=ninja test. Change-Id: I7ab0ff0915a76eea9857fc876493615c06193a37 Signed-off-by: Edward O'Callaghan Reviewed-on: https://review.coreboot.org/c/flashrom/+/74932 Tested-by: build bot (Jenkins) Reviewed-by: Anastasia Klimchuk --- tests/chip_wp.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'tests') diff --git a/tests/chip_wp.c b/tests/chip_wp.c index 2686f4463..1fa6bb9c8 100644 --- a/tests/chip_wp.c +++ b/tests/chip_wp.c @@ -24,6 +24,12 @@ #include "programmer.h" #include "tests.h" +static int unittest_print_cb(enum flashrom_log_level level, const char *fmt, va_list ap) +{ + if (level > FLASHROM_MSG_INFO) return 0; + return vfprintf(stderr, fmt, ap); +} + /* * Tests in this file do not use any mocking, because using write-protect * emulation in dummyflasher programmer is sufficient @@ -47,6 +53,8 @@ static void setup_chip(struct flashrom_flashctx *flash, struct flashrom_layout * flashrom_layout_set(flash, *layout); } + flashrom_set_log_callback((flashrom_log_callback *)&unittest_print_cb); + assert_int_equal(0, programmer_init(&programmer_dummy, programmer_param)); /* Assignment below normally happens while probing, but this test is not probing. */ flash->mst = ®istered_masters[0]; -- cgit v1.2.3