Anastasia Klimchuk has uploaded this change for review.

View Change

tests: Do not build/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 built either.

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

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

Change-Id: Ic1c48e41f658045a608f46636071f478ba646f77
Signed-off-by: Anastasia Klimchuk <aklm@chromium.org>
---
M tests/init_shutdown.c
M tests/tests.c
M tests/tests.h
3 files changed, 24 insertions(+), 0 deletions(-)

git pull ssh://review.coreboot.org:29418/flashrom refs/changes/95/55295/1
diff --git a/tests/init_shutdown.c b/tests/init_shutdown.c
index 4d9c549..5144416 100644
--- a/tests/init_shutdown.c
+++ b/tests/init_shutdown.c
@@ -32,11 +32,14 @@
printf("... programmer_shutdown for programmer=%u successful\n", prog);
}

+#if CONFIG_DUMMY == 1
void dummy_init_and_shutdown_test_success(void **state)
{
run_lifecycle(state, PROGRAMMER_DUMMY, "bus=parallel+lpc+fwh+spi");
}
+#endif /* CONFIG_DUMMY */

+#if CONFIG_MEC1308 == 1
struct mec1308_io_state {
unsigned char outb_val;
};
@@ -76,7 +79,9 @@

io_mock_register(NULL);
}
+#endif /* CONFIG_MEC1308 */

+#if CONFIG_ENE_LPC == 1
struct ene_lpc_io_state {
unsigned char outb_val;
int pause_cmd;
@@ -135,7 +140,9 @@

io_mock_register(NULL);
}
+#endif /* CONFIG_ENE_LPC */

+#if CONFIG_LINUX_SPI == 1
void linux_spi_init_and_shutdown_test_success(void **state)
{
/*
@@ -146,3 +153,4 @@
*/
run_lifecycle(state, PROGRAMMER_LINUX_SPI, "dev=/dev/null");
}
+#endif /* CONFIG_LINUX_SPI */
diff --git a/tests/tests.c b/tests/tests.c
index 44bbbdb..e12bcfd 100644
--- a/tests/tests.c
+++ b/tests/tests.c
@@ -164,10 +164,18 @@
ret |= cmocka_run_group_tests_name("spi25.c tests", spi25_tests, NULL, NULL);

const struct CMUnitTest init_shutdown_tests[] = {
+#if CONFIG_DUMMY == 1
cmocka_unit_test(dummy_init_and_shutdown_test_success),
+#endif
+#if CONFIG_MEC1308 == 1
cmocka_unit_test(mec1308_init_and_shutdown_test_success),
+#endif
+#if CONFIG_ENE_LPC == 1
cmocka_unit_test(ene_lpc_init_and_shutdown_test_success),
+#endif
+#if CONFIG_LINUX_SPI == 1
cmocka_unit_test(linux_spi_init_and_shutdown_test_success),
+#endif
};
ret |= cmocka_run_group_tests_name("init_shutdown.c tests", init_shutdown_tests, NULL, NULL);

diff --git a/tests/tests.h b/tests/tests.h
index da4f4a9..6c783b1 100644
--- a/tests/tests.h
+++ b/tests/tests.h
@@ -41,9 +41,17 @@
void probe_spi_st95_test_success(void **state); /* spi95.c */

/* init_shutdown.c */
+#if CONFIG_DUMMY == 1
void dummy_init_and_shutdown_test_success(void **state);
+#endif
+#if CONFIG_MEC1308 == 1
void mec1308_init_and_shutdown_test_success(void **state);
+#endif
+#if CONFIG_ENE_LPC == 1
void ene_lpc_init_and_shutdown_test_success(void **state);
+#endif
+#if CONFIG_LINUX_SPI == 1
void linux_spi_init_and_shutdown_test_success(void **state);
+#endif

#endif /* TESTS_H */

To view, visit change 55295. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: Ic1c48e41f658045a608f46636071f478ba646f77
Gerrit-Change-Number: 55295
Gerrit-PatchSet: 1
Gerrit-Owner: Anastasia Klimchuk <aklm@chromium.org>
Gerrit-MessageType: newchange