1
0
mirror of https://review.coreboot.org/flashrom.git synced 2025-04-28 07:23:43 +02:00

tests: Do not run a test if its driver is not built

For all tests that exist as of today, drivers are built by default,
however config options can be disabled and in that case test should
not be run.

Technically, this is done by skipping the test.

BUG=b:181803212
TEST=1) Tested by adding into tests/meson.build
-DCONFIG_xxx=0
4 times (for every driver with test), and then running ninja test
Result: corresponding test is skipped, all other tests are passed

2) Running ninja test with default config settings (everything is
enabled, no overriding in test meson).
Result: all tests are passed.

3) Replacing one of config options in the patch with CONFIG_JLINK_SPI
which is disabled by default.
Result: corresponding test is skipped.

Change-Id: Ic1c48e41f658045a608f46636071f478ba646f77
Signed-off-by: Anastasia Klimchuk <aklm@chromium.org>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/55295
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
Reviewed-by: Nico Huber <nico.h@gmx.de>
Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
This commit is contained in:
Anastasia Klimchuk 2021-06-21 10:29:18 +10:00 committed by Nico Huber
parent ae836bd00f
commit 20ff3d464b

View File

@ -34,7 +34,11 @@ static void run_lifecycle(void **state, const struct programmer_entry *prog, con
void dummy_init_and_shutdown_test_success(void **state) void dummy_init_and_shutdown_test_success(void **state)
{ {
#if CONFIG_DUMMY == 1
run_lifecycle(state, &programmer_dummy, "bus=parallel+lpc+fwh+spi"); run_lifecycle(state, &programmer_dummy, "bus=parallel+lpc+fwh+spi");
#else
skip();
#endif
} }
struct mec1308_io_state { struct mec1308_io_state {
@ -62,6 +66,7 @@ unsigned char mec1308_inb(void *state, unsigned short port)
void mec1308_init_and_shutdown_test_success(void **state) void mec1308_init_and_shutdown_test_success(void **state)
{ {
#if CONFIG_MEC1308 == 1
struct mec1308_io_state mec1308_io_state = { 0 }; struct mec1308_io_state mec1308_io_state = { 0 };
const struct io_mock mec1308_io = { const struct io_mock mec1308_io = {
.state = &mec1308_io_state, .state = &mec1308_io_state,
@ -75,6 +80,9 @@ void mec1308_init_and_shutdown_test_success(void **state)
run_lifecycle(state, &programmer_mec1308, ""); run_lifecycle(state, &programmer_mec1308, "");
io_mock_register(NULL); io_mock_register(NULL);
#else
skip();
#endif
} }
struct ene_lpc_io_state { struct ene_lpc_io_state {
@ -118,6 +126,7 @@ unsigned char ene_lpc_inb_kb932(void *state, unsigned short port)
void ene_lpc_init_and_shutdown_test_success(void **state) void ene_lpc_init_and_shutdown_test_success(void **state)
{ {
#if CONFIG_ENE_LPC == 1
/* /*
* Current implementation tests for chip ENE_KB932. * Current implementation tests for chip ENE_KB932.
* Another chip which is not tested here is ENE_KB94X. * Another chip which is not tested here is ENE_KB94X.
@ -134,6 +143,9 @@ void ene_lpc_init_and_shutdown_test_success(void **state)
run_lifecycle(state, &programmer_ene_lpc, ""); run_lifecycle(state, &programmer_ene_lpc, "");
io_mock_register(NULL); io_mock_register(NULL);
#else
skip();
#endif
} }
void linux_spi_init_and_shutdown_test_success(void **state) void linux_spi_init_and_shutdown_test_success(void **state)
@ -144,5 +156,9 @@ void linux_spi_init_and_shutdown_test_success(void **state)
* and the fallback to getpagesize(). This test does the latter (fallback to * and the fallback to getpagesize(). This test does the latter (fallback to
* getpagesize). * getpagesize).
*/ */
#if CONFIG_LINUX_SPI == 1
run_lifecycle(state, &programmer_linux_spi, "dev=/dev/null"); run_lifecycle(state, &programmer_linux_spi, "dev=/dev/null");
#else
skip();
#endif
} }