]>
git.ipfire.org Git - thirdparty/systemd.git/blob - test/units/testsuite-24.sh
1ff1c3347b2c04c7b78591a3fd58b76bf7733151
6 MAX_QUEUE_SIZE
=${NPROC:-2}
7 IFS
=$
'\n' TEST_LIST
=($
(ls /usr
/lib
/systemd
/tests
/test-
*))
10 rm /failed-tests
/skipped-tests
/skipped
12 # Check & report test results
16 function report_result
() {
17 if [[ $# -ne 2 ]]; then
18 echo >&2 "check_result: missing arguments"
25 if [[ $ret -ne 0 && $ret != 77 ]]; then
26 echo "$name failed with $ret"
27 echo "$name" >>/failed-tests
29 echo "--- $name begin ---"
31 echo "--- $name end ---"
33 elif [[ $ret == 77 ]]; then
35 echo "$name" >>/skipped-tests
37 echo "--- $name begin ---"
39 echo "--- $name end ---"
43 echo "$name" >>/testok
46 systemd-cat
echo "--- $name ---"
47 systemd-cat
cat "/$name.log"
50 # Associative array for running tasks, where running[test-path]=PID
52 for task
in "${TEST_LIST[@]}"; do
53 # If there's MAX_QUEUE_SIZE running tasks, keep checking the running queue
54 # until one of the tasks finishes, so we can replace it.
55 while [[ ${#running[@]} -ge $MAX_QUEUE_SIZE ]]; do
56 for key
in "${!running[@]}"; do
57 if ! kill -0 ${running[$key]} &>/dev
/null
; then
58 # Task has finished, report its result and drop it from the queue
61 report_result
"$key" $ec
63 # Break from inner for loop and outer while loop to skip
64 # the sleep below when we find a free slot in the queue
69 # Precisely* calculated constant to keep the spinlock from burning the CPU(s)
73 if [[ -x $task ]]; then
74 log_file
="/${task##*/}.log"
80 # Wait for remaining running tasks
81 for key
in "${!running[@]}"; do
84 report_result
"$key" $ec