1
0
mirror of https://github.com/systemd/systemd.git synced 2024-11-05 15:21:37 +03:00
systemd/test/TEST-24-UNIT-TESTS/test.sh
Zbigniew Jędrzejewski-Szmek ec43f6862e test: run tests directly from the loopback device
Before, we'd copy the test tree into nspawn-root, and run the tests from there.
This is OK, and doesn't actually take much extra time. But it uses quite a lot
of extra disk space. So let's make things a bit more efficient by running
directly from the image file.

We still run the unprivileged nspawn tests from a copy. Once the kernel
implements fs shift, we can do away with that too.
2020-03-28 11:51:29 +01:00

58 lines
1.4 KiB
Bash
Executable File

#!/usr/bin/env bash
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
[[ -e $1/testok ]] && _ret=0
if [[ -s $1/failed ]]; then
_ret=$(($_ret+1))
echo "=== Failed test log ==="
cat $1/failed
else
if [[ -s $1/skipped ]]; then
echo "=== Skipped test log =="
cat $1/skipped
fi
if [[ -s $1/testok ]]; then
echo "=== Passed tests ==="
cat $1/testok
fi
fi
cp -a $1/var/log/journal $TESTDIR
rm -r $1/var/log/journal/*
umount_initdir
[[ -n "$TIMED_OUT" ]] && _ret=$(($_ret+1))
return $_ret
}
check_result_qemu() {
local _ret=1
mount_initdir
[[ -e $initdir/testok ]] && _ret=0
if [[ -s $initdir/failed ]]; then
_ret=$(($_ret+1))
echo "=== Failed test log ==="
cat $initdir/failed
else
if [[ -s $initdir/skipped ]]; then
echo "=== Skipped test log =="
cat $initdir/skipped
fi
if [[ -s $initdir/testok ]]; then
echo "=== Passed tests ==="
cat $initdir/testok
fi
fi
cp -a $initdir/var/log/journal $TESTDIR
rm -r $initdir/var/log/journal/*
umount_initdir
[[ -n "$TIMED_OUT" ]] && _ret=$(($_ret+1))
return $_ret
}
do_test "$@" 24