1
0
mirror of https://review.coreboot.org/flashrom.git synced 2025-04-26 22:52:34 +02:00

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>
This commit is contained in:
Edward O'Callaghan 2023-05-03 16:49:29 +10:00 committed by Anastasia Klimchuk
parent 00c9fac2a6
commit 5ebdfb891f

View File

@ -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];