From dfbcf63302599b72f68a27656d4c617e45c3c06a Mon Sep 17 00:00:00 2001 From: Evan Benn Date: Wed, 20 Jul 2022 11:13:13 +1000 Subject: tests/test.c: Allow filtering of tests using cmocka API Tests can be filtered by providing patterns on the command line. The pattern is the first argument provided to the test binary, if present. Only tests matching the string provided are run, wildcards * and ? match any characters, or one character respectively. `meson test` or `ninja test` will continue to run all tests, as they do not provide an argument to the test binary. https://api.cmocka.org/group__cmocka.html TEST=tests/flashrom_unit_tests 'layout_*' Change-Id: I45f4ac5ef0cfb74156408022a19769d6598ad2ea Signed-off-by: Evan Benn Reviewed-on: https://review.coreboot.org/c/flashrom/+/65998 Tested-by: build bot (Jenkins) Reviewed-by: Edward O'Callaghan Reviewed-by: Anastasia Klimchuk Reviewed-by: Felix Singer --- tests/tests.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/tests.c b/tests/tests.c index c747488b..1ad9bb81 100644 --- a/tests/tests.c +++ b/tests/tests.c @@ -366,10 +366,13 @@ unsigned int __wrap_INL(unsigned short port) return 0; } -int main(void) +int main(int argc, char *argv[]) { int ret = 0; + if (argc > 1) + cmocka_set_test_filter(argv[1]); + cmocka_set_message_output(CM_OUTPUT_STDOUT); const struct CMUnitTest helpers_tests[] = { -- cgit v1.2.3