chrony/test/system/run
Miroslav Lichvar 6e52a9be7a test: add system tests
Add a new set of tests for testing basic functionality, starting chronyd
with root privileges on the actual system instead of the simulator.

Tests numbered in the 100-199 range are considered destructive and
intended to be used only on machines dedicated for development or
testing. They are started by the run script only with the -d option.
They may adjust/step the system clock and other clocks, block the RTC,
enable HW timestamping, create SHM segments, etc.

Other tests should not interfere with the system and should work even
when another NTP server/client is running.
2019-04-18 16:11:45 +02:00

64 lines
1.1 KiB
Bash
Executable file

#!/bin/bash
print_help() {
echo "$1 [-a] [-d] [TEST]..."
}
run_test() {
local result name=$1
if [ $destructive -ne 1 ] && [[ "$name" == 1[0-9][0-9]-* ]]; then
echo "SKIP (destructive test)"
return 9
fi
./$name
result=$?
if [ $result -ne 0 -a $result -ne 9 ]; then
if [ $abort_on_fail -ne 0 ]; then
exit 1
fi
fi
return $result
}
passed=() failed=() skipped=()
abort_on_fail=0
destructive=0
while getopts ":ad" opt; do
case $opt in
a) abort_on_fail=1;;
d) destructive=1;;
*) print_help "$0"; exit 3;;
esac
done
shift $[$OPTIND - 1]
[ $# -gt 0 ] && tests=($@) || tests=([0-9]*-*[^_])
for test in "${tests[@]}"; do
printf "%s " "$test"
run_test $test
result=$?
echo
case $result in
0) passed=(${passed[@]} $test);;
9) skipped=(${skipped[@]} $test);;
*) failed=(${failed[@]} $test);;
esac
done
echo
echo "SUMMARY:"
echo " TOTAL $[${#passed[@]} + ${#failed[@]} + ${#skipped[@]}]"
echo " PASSED ${#passed[@]}"
echo " FAILED ${#failed[@]} (${failed[@]})"
echo " SKIPPED ${#skipped[@]} (${skipped[@]})"
[ ${#failed[@]} -eq 0 ]