summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorEdward O'Callaghan <quasisec@google.com>2023-05-03 16:49:29 +1000
committerAnastasia Klimchuk <aklm@chromium.org>2023-05-09 07:44:00 +0000
commit5ebdfb891f2b04d24d312f0ca307083be0ebfcc8 (patch)
tree7bc0fd843bc28647d25990f60e3569cd6078e68a /tests
parent00c9fac2a66ab2aafc6949166dfc733fd0b747ea (diff)
downloadflashrom-5ebdfb891f2b04d24d312f0ca307083be0ebfcc8.tar.gz
flashrom-5ebdfb891f2b04d24d312f0ca307083be0ebfcc8.tar.bz2
flashrom-5ebdfb891f2b04d24d312f0ca307083be0ebfcc8.zip
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 <quasisec@google.com> Reviewed-on: https://review.coreboot.org/c/flashrom/+/74932 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/chip_wp.c8
1 files changed, 8 insertions, 0 deletions
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 = &registered_masters[0];