mirror of
https://github.com/systemd/systemd-stable.git
synced 2024-12-22 13:33:56 +03:00
cc5549ca12
We had all kinds of indentation: 2 sp, 3 sp, 4 sp, 8 sp, and mixed. 4 sp was the most common, in particular the majority of scripts under test/ used that. Let's standarize on 4 sp, because many commandlines are long and there's a lot of nesting, and with 8sp indentation less stuff fits. 4 sp also seems to be the default indentation, so this will make it less likely that people will mess up if they don't load the editor config. (I think people often use vi, and vi has no support to load project-wide configuration automatically. We distribute a .vimrc file, but it is not loaded by default, and even the instructions in it seem to discourage its use for security reasons.) Also remove the few vim config lines that were left. We should either have them on all files, or none. Also remove some strange stuff like '#!/bin/env bash', yikes.
107 lines
2.9 KiB
Bash
Executable File
107 lines
2.9 KiB
Bash
Executable File
#!/bin/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 $TESTDIR/$1/testok ]] && _ret=0
|
|
if [[ -s $TESTDIR/$1/failed ]]; then
|
|
_ret=$(($_ret+1))
|
|
echo "=== Failed test log ==="
|
|
cat $TESTDIR/$1/failed
|
|
else
|
|
if [[ -s $TESTDIR/$1/skipped ]]; then
|
|
echo "=== Skipped test log =="
|
|
cat $TESTDIR/$1/skipped
|
|
fi
|
|
if [[ -s $TESTDIR/$1/testok ]]; then
|
|
echo "=== Passed tests ==="
|
|
cat $TESTDIR/$1/testok
|
|
fi
|
|
fi
|
|
cp -a $TESTDIR/$1/var/log/journal $TESTDIR
|
|
[[ -n "$TIMED_OUT" ]] && _ret=$(($_ret+1))
|
|
return $_ret
|
|
}
|
|
|
|
check_result_qemu() {
|
|
local _ret=1
|
|
mkdir -p $TESTDIR/root
|
|
mount ${LOOPDEV}p1 $TESTDIR/root
|
|
[[ -e $TESTDIR/root/testok ]] && _ret=0
|
|
if [[ -s $TESTDIR/root/failed ]]; then
|
|
_ret=$(($_ret+1))
|
|
echo "=== Failed test log ==="
|
|
cat $TESTDIR/root/failed
|
|
else
|
|
if [[ -s $TESTDIR/root/skipped ]]; then
|
|
echo "=== Skipped test log =="
|
|
cat $TESTDIR/root/skipped
|
|
fi
|
|
if [[ -s $TESTDIR/root/testok ]]; then
|
|
echo "=== Passed tests ==="
|
|
cat $TESTDIR/root/testok
|
|
fi
|
|
fi
|
|
cp -a $TESTDIR/root/var/log/journal $TESTDIR
|
|
umount $TESTDIR/root
|
|
[[ -n "$TIMED_OUT" ]] && _ret=$(($_ret+1))
|
|
return $_ret
|
|
}
|
|
|
|
test_setup() {
|
|
if type -P meson && [[ "$(meson configure $BUILD_DIR | grep install-tests | awk '{ print $2 }')" != "true" ]]; then
|
|
dfatal "Needs to be built with -Dinstall-tests=true"
|
|
exit 1
|
|
fi
|
|
|
|
create_empty_image
|
|
mkdir -p $TESTDIR/root
|
|
mount ${LOOPDEV}p1 $TESTDIR/root
|
|
|
|
# Create what will eventually be our root filesystem onto an overlay
|
|
(
|
|
LOG_LEVEL=5
|
|
eval $(udevadm info --export --query=env --name=${LOOPDEV}p2)
|
|
|
|
for i in getfacl dirname basename capsh cut rev stat mktemp rmdir ionice unshare uname tr awk getent diff xzcat lz4cat; do
|
|
inst_binary $i
|
|
done
|
|
|
|
inst /etc/hosts
|
|
|
|
setup_basic_environment
|
|
install_keymaps yes
|
|
install_zoneinfo
|
|
# Install nproc to determine # of CPUs for correct parallelization
|
|
inst_binary nproc
|
|
|
|
# setup the testsuite service
|
|
cat >$initdir/etc/systemd/system/testsuite.service <<EOF
|
|
[Unit]
|
|
Description=Testsuite service
|
|
|
|
[Service]
|
|
ExecStart=/testsuite.sh
|
|
Type=oneshot
|
|
EOF
|
|
cp testsuite.sh $initdir/
|
|
|
|
setup_testsuite
|
|
) || return 1
|
|
setup_nspawn_root
|
|
|
|
# mask some services that we do not want to run in these tests
|
|
ln -s /dev/null $initdir/etc/systemd/system/systemd-networkd.service
|
|
ln -s /dev/null $initdir/etc/systemd/system/systemd-networkd.socket
|
|
ln -s /dev/null $initdir/etc/systemd/system/systemd-resolved.service
|
|
|
|
ddebug "umount $TESTDIR/root"
|
|
umount $TESTDIR/root
|
|
}
|
|
|
|
do_test "$@"
|