2020-03-04 12:35:06 +03:00
#!/usr/bin/env bash
2018-09-19 08:30:29 +03:00
set -e
2021-04-19 14:01:59 +03:00
2018-09-19 08:30:29 +03:00
TEST_DESCRIPTION = "Run unit tests under containers"
RUN_IN_UNPRIVILEGED_CONTAINER = yes
2019-12-13 16:20:35 +03:00
# embed some newlines in the kernel command line to stress our test suite
KERNEL_APPEND = "
frobnicate!
$KERNEL_APPEND
"
2021-04-19 14:01:59 +03:00
# shellcheck source=test/test-functions
. " ${ TEST_BASE_DIR : ? } /test-functions "
2018-09-19 08:30:29 +03:00
check_result_nspawn( ) {
2021-04-19 14:01:59 +03:00
local workspace = " ${ 1 : ? } "
local ret = 1
[ [ -e " $workspace /testok " ] ] && ret = 0
if [ [ -s " $workspace /failed " ] ] ; then
ret = $(( ret + 1 ))
2018-09-19 08:30:29 +03:00
echo "=== Failed test log ==="
2021-04-19 14:01:59 +03:00
cat " $workspace /failed "
2018-09-19 08:30:29 +03:00
else
2021-04-19 14:01:59 +03:00
if [ [ -s " $workspace /skipped " ] ] ; then
2018-09-19 08:30:29 +03:00
echo "=== Skipped test log =="
2021-04-19 14:01:59 +03:00
cat " $workspace /skipped "
2018-09-19 08:30:29 +03:00
fi
2021-04-19 14:01:59 +03:00
if [ [ -s " $workspace /testok " ] ] ; then
2018-09-19 08:30:29 +03:00
echo "=== Passed tests ==="
2021-04-19 14:01:59 +03:00
cat " $workspace /testok "
2018-09-19 08:30:29 +03:00
fi
fi
2021-04-19 14:01:59 +03:00
save_journal " $workspace /var/log/journal "
_umount_dir " ${ initdir : ? } "
[ [ -n " ${ TIMED_OUT : = } " ] ] && ret = $(( ret + 1 ))
return $ret
2018-09-19 08:30:29 +03:00
}
check_result_qemu( ) {
2021-04-19 14:01:59 +03:00
local ret = 1
2019-12-12 11:37:19 +03:00
mount_initdir
2021-04-19 14:01:59 +03:00
[ [ -e " ${ initdir : ? } /testok " ] ] && ret = 0
if [ [ -s " $initdir /failed " ] ] ; then
ret = $(( ret + 1 ))
2018-09-19 08:30:29 +03:00
echo "=== Failed test log ==="
2021-04-19 14:01:59 +03:00
cat " $initdir /failed "
2018-09-19 08:30:29 +03:00
else
2021-04-19 14:01:59 +03:00
if [ [ -s " $initdir /skipped " ] ] ; then
2018-09-19 08:30:29 +03:00
echo "=== Skipped test log =="
2021-04-19 14:01:59 +03:00
cat " $initdir /skipped "
2018-09-19 08:30:29 +03:00
fi
2021-04-19 14:01:59 +03:00
if [ [ -s " $initdir /testok " ] ] ; then
2018-09-19 08:30:29 +03:00
echo "=== Passed tests ==="
2021-04-19 14:01:59 +03:00
cat " $initdir /testok "
2018-09-19 08:30:29 +03:00
fi
fi
2021-04-19 14:01:59 +03:00
save_journal " $initdir /var/log/journal "
_umount_dir " $initdir "
[ [ -n " ${ TIMED_OUT : = } " ] ] && ret = $(( ret + 1 ))
return $ret
2018-09-19 08:30:29 +03:00
}
2020-09-22 19:26:28 +03:00
do_test " $@ " 02