2020-03-04 09:35:06 +00:00
|
|
|
#!/usr/bin/env bash
|
2018-09-19 05:30:29 +00:00
|
|
|
set -e
|
|
|
|
TEST_DESCRIPTION="Run unit tests under containers"
|
|
|
|
RUN_IN_UNPRIVILEGED_CONTAINER=yes
|
|
|
|
|
|
|
|
. $TEST_BASE_DIR/test-functions
|
|
|
|
|
|
|
|
check_result_nspawn() {
|
|
|
|
local _ret=1
|
2019-12-13 13:21:31 +00:00
|
|
|
[[ -e $1/testok ]] && _ret=0
|
|
|
|
if [[ -s $1/failed ]]; then
|
2018-09-19 05:30:29 +00:00
|
|
|
_ret=$(($_ret+1))
|
|
|
|
echo "=== Failed test log ==="
|
2019-12-13 13:21:31 +00:00
|
|
|
cat $1/failed
|
2018-09-19 05:30:29 +00:00
|
|
|
else
|
2019-12-13 13:21:31 +00:00
|
|
|
if [[ -s $1/skipped ]]; then
|
2018-09-19 05:30:29 +00:00
|
|
|
echo "=== Skipped test log =="
|
2019-12-13 13:21:31 +00:00
|
|
|
cat $1/skipped
|
2018-09-19 05:30:29 +00:00
|
|
|
fi
|
2019-12-13 13:21:31 +00:00
|
|
|
if [[ -s $1/testok ]]; then
|
2018-09-19 05:30:29 +00:00
|
|
|
echo "=== Passed tests ==="
|
2019-12-13 13:21:31 +00:00
|
|
|
cat $1/testok
|
2018-09-19 05:30:29 +00:00
|
|
|
fi
|
|
|
|
fi
|
2019-12-13 13:21:31 +00:00
|
|
|
cp -a $1/var/log/journal $TESTDIR
|
|
|
|
rm -r $1/var/log/journal/*
|
2020-03-20 19:17:11 +00:00
|
|
|
_umount_dir $initdir
|
2019-12-13 13:21:31 +00:00
|
|
|
[[ -n "$TIMED_OUT" ]] && _ret=$(($_ret+1))
|
2018-09-19 05:30:29 +00:00
|
|
|
return $_ret
|
|
|
|
}
|
|
|
|
|
|
|
|
check_result_qemu() {
|
|
|
|
local _ret=1
|
2019-12-12 08:37:19 +00:00
|
|
|
mount_initdir
|
2019-08-15 13:39:31 +00:00
|
|
|
[[ -e $initdir/testok ]] && _ret=0
|
|
|
|
if [[ -s $initdir/failed ]]; then
|
2018-09-19 05:30:29 +00:00
|
|
|
_ret=$(($_ret+1))
|
|
|
|
echo "=== Failed test log ==="
|
2019-08-15 13:39:31 +00:00
|
|
|
cat $initdir/failed
|
2018-09-19 05:30:29 +00:00
|
|
|
else
|
2019-08-15 13:39:31 +00:00
|
|
|
if [[ -s $initdir/skipped ]]; then
|
2018-09-19 05:30:29 +00:00
|
|
|
echo "=== Skipped test log =="
|
2019-08-15 13:39:31 +00:00
|
|
|
cat $initdir/skipped
|
2018-09-19 05:30:29 +00:00
|
|
|
fi
|
2019-08-15 13:39:31 +00:00
|
|
|
if [[ -s $initdir/testok ]]; then
|
2018-09-19 05:30:29 +00:00
|
|
|
echo "=== Passed tests ==="
|
2019-08-15 13:39:31 +00:00
|
|
|
cat $initdir/testok
|
2018-09-19 05:30:29 +00:00
|
|
|
fi
|
|
|
|
fi
|
2019-08-15 13:39:31 +00:00
|
|
|
cp -a $initdir/var/log/journal $TESTDIR
|
2020-03-20 16:46:04 +00:00
|
|
|
rm -r $initdir/var/log/journal/*
|
2020-03-20 19:17:11 +00:00
|
|
|
_umount_dir $initdir
|
2018-09-19 05:30:29 +00:00
|
|
|
[[ -n "$TIMED_OUT" ]] && _ret=$(($_ret+1))
|
|
|
|
return $_ret
|
|
|
|
}
|
|
|
|
|
2019-12-10 14:31:09 +00:00
|
|
|
do_test "$@" 24
|