]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
TEST-02-UNITTESTS: reuse $TEST_MATCH_SUBTEST to specify unit tests to be run 27916/head
authorYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 22 Oct 2024 06:32:12 +0000 (15:32 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 22 Oct 2024 11:14:33 +0000 (20:14 +0900)
Then, we can easily test specific unit tests in qemu or container.

test/units/TEST-02-UNITTESTS.sh

index 4448643f9a2b44429d148f1b86ea25a56776b11e..0aced75c67a3f598a2778bdc75ded8ef9175b2cc 100755 (executable)
@@ -9,13 +9,15 @@ if ! systemd-detect-virt -qc && [[ "${TEST_CMDLINE_NEWLINE:-}" != bar ]]; then
     exit 1
 fi
 
-# If we're running with TEST_PREFER_NSPAWN=1 limit the set of tests we run
-# in QEMU to only those that can't run in a container to avoid running
-# the same tests again in a, most likely, very slow environment
-if ! systemd-detect-virt -qc && [[ "${TEST_PREFER_NSPAWN:-0}" -ne 0 ]]; then
-    TESTS_GLOB="test-loop-block"
-else
-    TESTS_GLOB=${TESTS_GLOB:-test-*}
+if [[ -z "${TEST_MATCH_SUBTEST:-}" ]]; then
+    # If we're running with TEST_PREFER_NSPAWN=1 limit the set of tests we run
+    # in QEMU to only those that can't run in a container to avoid running
+    # the same tests again in a, most likely, very slow environment
+    if ! systemd-detect-virt -qc && [[ "${TEST_PREFER_NSPAWN:-0}" -ne 0 ]]; then
+        TEST_MATCH_SUBTEST="test-loop-block"
+    else
+        TEST_MATCH_SUBTEST="test-*"
+    fi
 fi
 
 NPROC=$(nproc)
@@ -92,7 +94,7 @@ run_test() {
 
 export -f run_test
 
-find /usr/lib/systemd/tests/unit-tests/ -maxdepth 1 -type f -name "${TESTS_GLOB}" -print0 |
+find /usr/lib/systemd/tests/unit-tests/ -maxdepth 1 -type f -name "${TEST_MATCH_SUBTEST}" -print0 |
     xargs -0 -I {} --max-procs="$MAX_QUEUE_SIZE" bash -ec "run_test {}"
 
 # Write all pending messages, so they don't get mixed with the summaries below