summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorEvan Benn <evanbenn@chromium.org>2022-07-20 11:13:13 +1000
committerAnastasia Klimchuk <aklm@chromium.org>2022-08-02 02:38:23 +0000
commitdfbcf63302599b72f68a27656d4c617e45c3c06a (patch)
tree5bd706c573958d2c49121e894d6da4330d7a6b63 /tests
parent6308fc3b9fac53423ff53040845973661299d6d8 (diff)
downloadflashrom-dfbcf63302599b72f68a27656d4c617e45c3c06a.tar.gz
flashrom-dfbcf63302599b72f68a27656d4c617e45c3c06a.tar.bz2
flashrom-dfbcf63302599b72f68a27656d4c617e45c3c06a.zip
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>
Diffstat (limited to 'tests')
-rw-r--r--tests/tests.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/tests/tests.c b/tests/tests.c
index c747488bd..1ad9bb813 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[] = {