1
0
mirror of https://review.coreboot.org/flashrom.git synced 2025-04-27 23:22:37 +02:00

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 <evanbenn@chromium.org>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/65998
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
Reviewed-by: Felix Singer <felixsinger@posteo.net>
This commit is contained in:
Evan Benn 2022-07-20 11:13:13 +10:00 committed by Anastasia Klimchuk
parent 6308fc3b9f
commit dfbcf63302

View File

@ -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[] = {