diff options
author | Frantisek Sumsal <frantisek@sumsal.cz> | 2023-06-05 10:47:21 +0200 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2023-06-05 15:58:37 +0200 |
commit | 0efa27bd4bcda98cab0b4c2602d7cdd90296af20 (patch) | |
tree | d90e98754d0e60a7ed67a5ba2978058eb3735ad3 /test | |
parent | man: parition → partition typo fix (diff) | |
download | systemd-0efa27bd4bcda98cab0b4c2602d7cdd90296af20.tar.xz systemd-0efa27bd4bcda98cab0b4c2602d7cdd90296af20.zip |
test: allow running only specified subtests/testcases
Useful when debugging, e.g.:
make -C test/TEST-74-AUX-UTILS clean setup run TEST_MATCH_SUBTEST=run
Resolves: #27914
Diffstat (limited to 'test')
-rw-r--r-- | test/README.testsuite | 7 | ||||
-rw-r--r-- | test/test-functions | 4 | ||||
-rw-r--r-- | test/units/test-control.sh | 10 |
3 files changed, 21 insertions, 0 deletions
diff --git a/test/README.testsuite b/test/README.testsuite index 695cce15aa..c0f1a2b102 100644 --- a/test/README.testsuite +++ b/test/README.testsuite @@ -98,6 +98,13 @@ INTERACTIVE_DEBUG=1 (e.g. by setting a usable default terminal, suppressing the shutdown after the test, etc.) +TEST_MATCH_SUBTEST=subtest + If the test makes use of `run_subtests` use this variable to provide + a POSIX extended regex to run only subtests matching the expression + +TEST_MATCH_TESTCASE=testcase + Same as $TEST_MATCH_SUBTEST but for subtests that make use of `run_testcases` + The kernel and initrd can be specified with $KERNEL_BIN and $INITRD. (Fedora's or Debian's default kernel path and initrd are used by default.) diff --git a/test/test-functions b/test/test-functions index 2502177908..4df6184d00 100644 --- a/test/test-functions +++ b/test/test-functions @@ -490,6 +490,8 @@ run_qemu() { "systemd.unit=testsuite.target" "systemd.wants=testsuite-$1.service" "noresume" + ${TEST_MATCH_SUBTEST:+"systemd.setenv=TEST_MATCH_SUBTEST=$TEST_MATCH_SUBTEST"} + ${TEST_MATCH_TESTCASE:+"systemd.setenv=TEST_MATCH_TESTCASE=$TEST_MATCH_TESTCASE"} ) if ! get_bool "$INTERACTIVE_DEBUG"; then @@ -567,6 +569,8 @@ run_nspawn() { "$PATH_TO_INIT" "systemd.unit=testsuite.target" "systemd.wants=testsuite-$2.service" + ${TEST_MATCH_SUBTEST:+"systemd.setenv=TEST_MATCH_SUBTEST=$TEST_MATCH_SUBTEST"} + ${TEST_MATCH_TESTCASE:+"systemd.setenv=TEST_MATCH_TESTCASE=$TEST_MATCH_TESTCASE"} ) if ! get_bool "$INTERACTIVE_DEBUG"; then diff --git a/test/units/test-control.sh b/test/units/test-control.sh index cd7048ae97..2760acd34f 100644 --- a/test/units/test-control.sh +++ b/test/units/test-control.sh @@ -118,6 +118,11 @@ run_subtests() { fi for subtest in "${subtests[@]}"; do + if [[ -n "${TEST_MATCH_SUBTEST:-}" ]] && ! [[ "$subtest" =~ $TEST_MATCH_SUBTEST ]]; then + echo "Skipping $subtest (not matching '$TEST_MATCH_SUBTEST')" + continue + fi + : "--- $subtest BEGIN ---" "./$subtest" && _PASSED_TESTS+=("$subtest") || _FAILED_TESTS+=("$subtest") : "--- $subtest END ---" @@ -139,6 +144,11 @@ run_testcases() { fi for testcase in "${testcases[@]}"; do + if [[ -n "${TEST_MATCH_TESTCASE:-}" ]] && ! [[ "$testcase" =~ $TEST_MATCH_TESTCASE ]]; then + echo "Skipping $testcase (not matching '$TEST_MATCH_TESTCASE')" + continue + fi + : "+++ $testcase BEGIN +++" # Note: the subshell here is used purposefully, otherwise we might # unexpectedly inherit a RETURN trap handler from the called |