]>
git.ipfire.org Git - thirdparty/systemd.git/blob - test/TEST-24-UNIT-TESTS/testsuite.sh
6 MAX_QUEUE_SIZE
=${NPROC:-2}
7 IFS
=$
'\n' TEST_LIST
=($
(ls /usr
/lib
/systemd
/tests
/test-
*))
9 # Check & report test results
13 function report_result
() {
14 if [[ $# -ne 2 ]]; then
15 echo >&2 "check_result: missing arguments"
22 if [[ $ret -ne 0 && $ret != 77 ]]; then
23 echo "$name failed with $ret"
24 echo "$name" >> /failed-tests
26 echo "--- $name begin ---"
28 echo "--- $name end ---"
30 elif [[ $ret == 77 ]]; then
32 echo "$name" >> /skipped-tests
34 echo "--- $name begin ---"
36 echo "--- $name end ---"
40 echo "$name" >> /testok
43 systemd-cat
echo "--- $name ---"
44 systemd-cat
cat "/$name.log"
47 # Associative array for running tasks, where running[test-path]=PID
49 for task
in "${TEST_LIST[@]}"; do
50 # If there's MAX_QUEUE_SIZE running tasks, keep checking the running queue
51 # until one of the tasks finishes, so we can replace it.
52 while [[ ${#running[@]} -ge $MAX_QUEUE_SIZE ]]; do
53 for key
in "${!running[@]}"; do
54 if ! kill -0 ${running[$key]} &>/dev
/null
; then
55 # Task has finished, report its result and drop it from the queue
58 report_result
"$key" $ec
60 # Break from inner for loop and outer while loop to skip
61 # the sleep below when we find a free slot in the queue
66 # Precisely* calculated constant to keep the spinlock from burning the CPU(s)
70 if [[ -x $task ]]; then
71 log_file
="/${task##*/}.log"
72 $task &> "$log_file" &
77 # Wait for remaining running tasks
78 for key
in "${!running[@]}"; do
81 report_result
"$key" $ec