mirror of
https://github.com/systemd/systemd.git
synced 2025-01-09 01:18:19 +03:00
test: Factorize common integration test functions (#6540)
All test/TEST* but TEST-02-CRYPTSETUP share the same check_result_qemu() and test_cleanup(), so move them into test_functions and only override them in TEST-02-CRYPTSETUP. Also provide a common test_run() which by default assumes that both QEMU and nspawn tests are run. Particular tests which don't support either need to explicitly opt out by setting $TEST_NO_{QEMU,NSPAWN}. Do it this way around to avoid accidentally forgetting to opt in, and to encourage test authors to at least always support nspawn.
This commit is contained in:
parent
a93e2f65eb
commit
054ee249a2
@ -5,34 +5,6 @@ TEST_DESCRIPTION="Basic systemd setup"
|
||||
|
||||
. $TEST_BASE_DIR/test-functions
|
||||
|
||||
check_result_qemu() {
|
||||
ret=1
|
||||
mkdir -p $TESTDIR/root
|
||||
mount ${LOOPDEV}p1 $TESTDIR/root
|
||||
[[ -e $TESTDIR/root/testok ]] && ret=0
|
||||
[[ -f $TESTDIR/root/failed ]] && cp -a $TESTDIR/root/failed $TESTDIR
|
||||
cp -a $TESTDIR/root/var/log/journal $TESTDIR
|
||||
umount $TESTDIR/root
|
||||
[[ -f $TESTDIR/failed ]] && cat $TESTDIR/failed
|
||||
ls -l $TESTDIR/journal/*/*.journal
|
||||
test -s $TESTDIR/failed && ret=$(($ret+1))
|
||||
return $ret
|
||||
}
|
||||
|
||||
test_run() {
|
||||
if run_qemu; then
|
||||
check_result_qemu || return 1
|
||||
else
|
||||
dwarn "can't run QEMU, skipping"
|
||||
fi
|
||||
if run_nspawn; then
|
||||
check_result_nspawn || return 1
|
||||
else
|
||||
dwarn "can't run systemd-nspawn, skipping"
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
test_setup() {
|
||||
create_empty_image
|
||||
mkdir -p $TESTDIR/root
|
||||
@ -71,10 +43,4 @@ EOF
|
||||
umount $TESTDIR/root
|
||||
}
|
||||
|
||||
test_cleanup() {
|
||||
umount $TESTDIR/root 2>/dev/null
|
||||
[[ $LOOPDEV ]] && losetup -d $LOOPDEV
|
||||
return 0
|
||||
}
|
||||
|
||||
do_test "$@"
|
||||
|
@ -2,6 +2,7 @@
|
||||
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
|
||||
# ex: ts=8 sw=4 sts=4 et filetype=sh
|
||||
TEST_DESCRIPTION="cryptsetup systemd setup"
|
||||
TEST_NO_NSPAWN=1
|
||||
|
||||
. $TEST_BASE_DIR/test-functions
|
||||
|
||||
@ -24,15 +25,6 @@ check_result_qemu() {
|
||||
}
|
||||
|
||||
|
||||
test_run() {
|
||||
if run_qemu; then
|
||||
check_result_qemu || return 1
|
||||
else
|
||||
dwarn "can't run QEMU, skipping"
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
test_setup() {
|
||||
create_empty_image
|
||||
echo -n test >$TESTDIR/keyfile
|
||||
|
@ -5,34 +5,6 @@ TEST_DESCRIPTION="Job-related tests"
|
||||
|
||||
. $TEST_BASE_DIR/test-functions
|
||||
|
||||
check_result_qemu() {
|
||||
ret=1
|
||||
mkdir -p $TESTDIR/root
|
||||
mount ${LOOPDEV}p1 $TESTDIR/root
|
||||
[[ -e $TESTDIR/root/testok ]] && ret=0
|
||||
[[ -f $TESTDIR/root/failed ]] && cp -a $TESTDIR/root/failed $TESTDIR
|
||||
cp -a $TESTDIR/root/var/log/journal $TESTDIR
|
||||
umount $TESTDIR/root
|
||||
[[ -f $TESTDIR/failed ]] && cat $TESTDIR/failed
|
||||
ls -l $TESTDIR/journal/*/*.journal
|
||||
test -s $TESTDIR/failed && ret=$(($ret+1))
|
||||
return $ret
|
||||
}
|
||||
|
||||
test_run() {
|
||||
if run_qemu; then
|
||||
check_result_qemu || return 1
|
||||
else
|
||||
dwarn "can't run QEMU, skipping"
|
||||
fi
|
||||
if run_nspawn; then
|
||||
check_result_nspawn || return 1
|
||||
else
|
||||
dwarn "can't run systemd-nspawn, skipping"
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
test_setup() {
|
||||
create_empty_image
|
||||
mkdir -p $TESTDIR/root
|
||||
@ -69,10 +41,4 @@ EOF
|
||||
umount $TESTDIR/root
|
||||
}
|
||||
|
||||
test_cleanup() {
|
||||
umount $TESTDIR/root 2>/dev/null
|
||||
[[ $LOOPDEV ]] && losetup -d $LOOPDEV
|
||||
return 0
|
||||
}
|
||||
|
||||
do_test "$@"
|
||||
|
@ -5,34 +5,6 @@ TEST_DESCRIPTION="Journal-related tests"
|
||||
|
||||
. $TEST_BASE_DIR/test-functions
|
||||
|
||||
check_result_qemu() {
|
||||
ret=1
|
||||
mkdir -p $TESTDIR/root
|
||||
mount ${LOOPDEV}p1 $TESTDIR/root
|
||||
[[ -e $TESTDIR/root/testok ]] && ret=0
|
||||
[[ -f $TESTDIR/root/failed ]] && cp -a $TESTDIR/root/failed $TESTDIR
|
||||
cp -a $TESTDIR/root/var/log/journal $TESTDIR
|
||||
umount $TESTDIR/root
|
||||
[[ -f $TESTDIR/failed ]] && cat $TESTDIR/failed
|
||||
ls -l $TESTDIR/journal/*/*.journal
|
||||
test -s $TESTDIR/failed && ret=$(($ret+1))
|
||||
return $ret
|
||||
}
|
||||
|
||||
test_run() {
|
||||
if run_qemu; then
|
||||
check_result_qemu || return 1
|
||||
else
|
||||
dwarn "can't run QEMU, skipping"
|
||||
fi
|
||||
if run_nspawn; then
|
||||
check_result_nspawn || return 1
|
||||
else
|
||||
dwarn "can't run systemd-nspawn, skipping"
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
test_setup() {
|
||||
create_empty_image
|
||||
mkdir -p $TESTDIR/root
|
||||
@ -75,10 +47,4 @@ EOF
|
||||
umount $TESTDIR/root
|
||||
}
|
||||
|
||||
test_cleanup() {
|
||||
umount $TESTDIR/root 2>/dev/null
|
||||
[[ $LOOPDEV ]] && losetup -d $LOOPDEV
|
||||
return 0
|
||||
}
|
||||
|
||||
do_test "$@"
|
||||
|
@ -5,34 +5,6 @@ TEST_DESCRIPTION="Resource limits-related tests"
|
||||
|
||||
. $TEST_BASE_DIR/test-functions
|
||||
|
||||
check_result_qemu() {
|
||||
ret=1
|
||||
mkdir -p $TESTDIR/root
|
||||
mount ${LOOPDEV}p1 $TESTDIR/root
|
||||
[[ -e $TESTDIR/root/testok ]] && ret=0
|
||||
[[ -f $TESTDIR/root/failed ]] && cp -a $TESTDIR/root/failed $TESTDIR
|
||||
cp -a $TESTDIR/root/var/log/journal $TESTDIR
|
||||
umount $TESTDIR/root
|
||||
[[ -f $TESTDIR/failed ]] && cat $TESTDIR/failed
|
||||
ls -l $TESTDIR/journal/*/*.journal
|
||||
test -s $TESTDIR/failed && ret=$(($ret+1))
|
||||
return $ret
|
||||
}
|
||||
|
||||
test_run() {
|
||||
if run_qemu; then
|
||||
check_result_qemu || return 1
|
||||
else
|
||||
dwarn "can't run QEMU, skipping"
|
||||
fi
|
||||
if run_nspawn; then
|
||||
check_result_nspawn || return 1
|
||||
else
|
||||
dwarn "can't run systemd-nspawn, skipping"
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
test_setup() {
|
||||
create_empty_image
|
||||
mkdir -p $TESTDIR/root
|
||||
@ -71,10 +43,4 @@ EOF
|
||||
umount $TESTDIR/root
|
||||
}
|
||||
|
||||
test_cleanup() {
|
||||
umount $TESTDIR/root 2>/dev/null
|
||||
[[ $LOOPDEV ]] && losetup -d $LOOPDEV
|
||||
return 0
|
||||
}
|
||||
|
||||
do_test "$@"
|
||||
|
@ -2,6 +2,7 @@
|
||||
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
|
||||
# ex: ts=8 sw=4 sts=4 et filetype=sh
|
||||
TEST_DESCRIPTION="SELinux tests"
|
||||
TEST_NO_NSPAWN=1
|
||||
|
||||
# Requirements:
|
||||
# Fedora 23
|
||||
@ -12,29 +13,6 @@ TEST_DESCRIPTION="SELinux tests"
|
||||
SETUP_SELINUX=yes
|
||||
KERNEL_APPEND="$KERNEL_APPEND selinux=1 security=selinux"
|
||||
|
||||
check_result_qemu() {
|
||||
ret=1
|
||||
mkdir -p $TESTDIR/root
|
||||
mount ${LOOPDEV}p1 $TESTDIR/root
|
||||
[[ -e $TESTDIR/root/testok ]] && ret=0
|
||||
[[ -f $TESTDIR/root/failed ]] && cp -a $TESTDIR/root/failed $TESTDIR
|
||||
cp -a $TESTDIR/root/var/log/journal $TESTDIR
|
||||
umount $TESTDIR/root
|
||||
[[ -f $TESTDIR/failed ]] && cat $TESTDIR/failed
|
||||
ls -l $TESTDIR/journal/*/*.journal
|
||||
test -s $TESTDIR/failed && ret=$(($ret+1))
|
||||
return $ret
|
||||
}
|
||||
|
||||
test_run() {
|
||||
if run_qemu; then
|
||||
check_result_qemu || return 1
|
||||
else
|
||||
dwarn "can't run QEMU, skipping"
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
test_setup() {
|
||||
create_empty_image
|
||||
mkdir -p $TESTDIR/root
|
||||
@ -126,10 +104,4 @@ EOF
|
||||
umount $TESTDIR/root
|
||||
}
|
||||
|
||||
test_cleanup() {
|
||||
umount $TESTDIR/root 2>/dev/null
|
||||
[[ $LOOPDEV ]] && losetup -d $LOOPDEV
|
||||
return 0
|
||||
}
|
||||
|
||||
do_test "$@"
|
||||
|
@ -2,21 +2,12 @@
|
||||
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
|
||||
# ex: ts=8 sw=4 sts=4 et filetype=sh
|
||||
TEST_DESCRIPTION="https://github.com/systemd/systemd/issues/1981"
|
||||
TEST_NO_QEMU=1
|
||||
|
||||
. $TEST_BASE_DIR/test-functions
|
||||
|
||||
NSPAWN_TIMEOUT=30s
|
||||
|
||||
test_run() {
|
||||
dwarn "skipping QEMU"
|
||||
if run_nspawn; then
|
||||
check_result_nspawn || return 1
|
||||
else
|
||||
dwarn "can't run systemd-nspawn, skipping"
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
test_setup() {
|
||||
create_empty_image
|
||||
mkdir -p $TESTDIR/root
|
||||
@ -50,10 +41,4 @@ EOF
|
||||
umount $TESTDIR/root
|
||||
}
|
||||
|
||||
test_cleanup() {
|
||||
umount $TESTDIR/root 2>/dev/null
|
||||
[[ $LOOPDEV ]] && losetup -d $LOOPDEV
|
||||
return 0
|
||||
}
|
||||
|
||||
do_test "$@"
|
||||
|
@ -2,36 +2,13 @@
|
||||
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
|
||||
# ex: ts=8 sw=4 sts=4 et filetype=sh
|
||||
TEST_DESCRIPTION="https://github.com/systemd/systemd/issues/2730"
|
||||
TEST_NO_NSPAWN=1
|
||||
|
||||
. $TEST_BASE_DIR/test-functions
|
||||
SKIP_INITRD=yes
|
||||
QEMU_TIMEOUT=180
|
||||
FSTYPE=ext4
|
||||
|
||||
check_result_qemu() {
|
||||
ret=1
|
||||
mkdir -p $TESTDIR/root
|
||||
mount ${LOOPDEV}p1 $TESTDIR/root
|
||||
[[ -e $TESTDIR/root/testok ]] && ret=0
|
||||
[[ -f $TESTDIR/root/failed ]] && cp -a $TESTDIR/root/failed $TESTDIR
|
||||
cp -a $TESTDIR/root/var/log/journal $TESTDIR
|
||||
umount $TESTDIR/root
|
||||
[[ -f $TESTDIR/failed ]] && cat $TESTDIR/failed
|
||||
ls -l $TESTDIR/journal/*/*.journal
|
||||
test -s $TESTDIR/failed && ret=$(($ret+1))
|
||||
[ -n "$TIMED_OUT" ] && ret=$(($ret+1))
|
||||
return $ret
|
||||
}
|
||||
|
||||
test_run() {
|
||||
if run_qemu; then
|
||||
check_result_qemu || return 1
|
||||
else
|
||||
dwarn "can't run QEMU, skipping"
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
test_setup() {
|
||||
create_empty_image
|
||||
mkdir -p $TESTDIR/root
|
||||
@ -103,10 +80,4 @@ EOF
|
||||
umount $TESTDIR/root
|
||||
}
|
||||
|
||||
test_cleanup() {
|
||||
umount $TESTDIR/root 2>/dev/null
|
||||
[[ $LOOPDEV ]] && losetup -d $LOOPDEV
|
||||
return 0
|
||||
}
|
||||
|
||||
do_test "$@"
|
||||
|
@ -2,35 +2,12 @@
|
||||
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
|
||||
# ex: ts=8 sw=4 sts=4 et filetype=sh
|
||||
TEST_DESCRIPTION="https://github.com/systemd/systemd/issues/2691"
|
||||
TEST_NO_NSPAWN=1
|
||||
|
||||
. $TEST_BASE_DIR/test-functions
|
||||
SKIP_INITRD=yes
|
||||
QEMU_TIMEOUT=90
|
||||
|
||||
check_result_qemu() {
|
||||
ret=1
|
||||
mkdir -p $TESTDIR/root
|
||||
mount ${LOOPDEV}p1 $TESTDIR/root
|
||||
[[ -e $TESTDIR/root/testok ]] && ret=0
|
||||
[[ -f $TESTDIR/root/failed ]] && cp -a $TESTDIR/root/failed $TESTDIR
|
||||
cp -a $TESTDIR/root/var/log/journal $TESTDIR
|
||||
umount $TESTDIR/root
|
||||
[[ -f $TESTDIR/failed ]] && cat $TESTDIR/failed
|
||||
ls -l $TESTDIR/journal/*/*.journal
|
||||
test -s $TESTDIR/failed && ret=$(($ret+1))
|
||||
[ -n "$TIMED_OUT" ] && ret=$(($ret+1))
|
||||
return $ret
|
||||
}
|
||||
|
||||
test_run() {
|
||||
if run_qemu; then
|
||||
check_result_qemu || return 1
|
||||
else
|
||||
dwarn "can't run QEMU, skipping"
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
test_setup() {
|
||||
create_empty_image
|
||||
mkdir -p $TESTDIR/root
|
||||
@ -71,10 +48,4 @@ EOF
|
||||
umount $TESTDIR/root
|
||||
}
|
||||
|
||||
test_cleanup() {
|
||||
umount $TESTDIR/root 2>/dev/null
|
||||
[[ $LOOPDEV ]] && losetup -d $LOOPDEV
|
||||
return 0
|
||||
}
|
||||
|
||||
do_test "$@"
|
||||
|
@ -2,33 +2,11 @@
|
||||
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
|
||||
# ex: ts=8 sw=4 sts=4 et filetype=sh
|
||||
TEST_DESCRIPTION="https://github.com/systemd/systemd/issues/2467"
|
||||
TEST_NO_NSPAWN=1
|
||||
|
||||
. $TEST_BASE_DIR/test-functions
|
||||
SKIP_INITRD=yes
|
||||
|
||||
check_result_qemu() {
|
||||
ret=1
|
||||
mkdir -p $TESTDIR/root
|
||||
mount ${LOOPDEV}p1 $TESTDIR/root
|
||||
[[ -e $TESTDIR/root/testok ]] && ret=0
|
||||
[[ -f $TESTDIR/root/failed ]] && cp -a $TESTDIR/root/failed $TESTDIR
|
||||
cp -a $TESTDIR/root/var/log/journal $TESTDIR
|
||||
umount $TESTDIR/root
|
||||
[[ -f $TESTDIR/failed ]] && cat $TESTDIR/failed
|
||||
ls -l $TESTDIR/journal/*/*.journal
|
||||
test -s $TESTDIR/failed && ret=$(($ret+1))
|
||||
return $ret
|
||||
}
|
||||
|
||||
test_run() {
|
||||
if run_qemu; then
|
||||
check_result_qemu || return 1
|
||||
else
|
||||
dwarn "can't run QEMU, skipping"
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
test_setup() {
|
||||
create_empty_image
|
||||
mkdir -p $TESTDIR/root
|
||||
@ -82,10 +60,4 @@ EOF
|
||||
umount $TESTDIR/root
|
||||
}
|
||||
|
||||
test_cleanup() {
|
||||
umount $TESTDIR/root 2>/dev/null
|
||||
[[ $LOOPDEV ]] && losetup -d $LOOPDEV
|
||||
return 0
|
||||
}
|
||||
|
||||
do_test "$@"
|
||||
|
@ -2,33 +2,11 @@
|
||||
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
|
||||
# ex: ts=8 sw=4 sts=4 et filetype=sh
|
||||
TEST_DESCRIPTION="https://github.com/systemd/systemd/issues/3166"
|
||||
TEST_NO_NSPAWN=1
|
||||
|
||||
. $TEST_BASE_DIR/test-functions
|
||||
SKIP_INITRD=yes
|
||||
|
||||
check_result_qemu() {
|
||||
ret=1
|
||||
mkdir -p $TESTDIR/root
|
||||
mount ${LOOPDEV}p1 $TESTDIR/root
|
||||
[[ -e $TESTDIR/root/testok ]] && ret=0
|
||||
[[ -f $TESTDIR/root/failed ]] && cp -a $TESTDIR/root/failed $TESTDIR
|
||||
cp -a $TESTDIR/root/var/log/journal $TESTDIR
|
||||
umount $TESTDIR/root
|
||||
[[ -f $TESTDIR/failed ]] && cat $TESTDIR/failed
|
||||
ls -l $TESTDIR/journal/*/*.journal
|
||||
test -s $TESTDIR/failed && ret=$(($ret+1))
|
||||
return $ret
|
||||
}
|
||||
|
||||
test_run() {
|
||||
if run_qemu; then
|
||||
check_result_qemu || return 1
|
||||
else
|
||||
dwarn "can't run QEMU, skipping"
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
test_setup() {
|
||||
create_empty_image
|
||||
mkdir -p $TESTDIR/root
|
||||
@ -85,10 +63,4 @@ EOF
|
||||
umount $TESTDIR/root
|
||||
}
|
||||
|
||||
test_cleanup() {
|
||||
umount $TESTDIR/root 2>/dev/null
|
||||
[[ $LOOPDEV ]] && losetup -d $LOOPDEV
|
||||
return 0
|
||||
}
|
||||
|
||||
do_test "$@"
|
||||
|
@ -2,18 +2,10 @@
|
||||
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
|
||||
# ex: ts=8 sw=4 sts=4 et filetype=sh
|
||||
TEST_DESCRIPTION="https://github.com/systemd/systemd/issues/3171"
|
||||
TEST_NO_QEMU=1
|
||||
|
||||
. $TEST_BASE_DIR/test-functions
|
||||
|
||||
test_run() {
|
||||
if run_nspawn; then
|
||||
check_result_nspawn || return 1
|
||||
else
|
||||
dwarn "can't run systemd-nspawn, skipping"
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
test_setup() {
|
||||
create_empty_image
|
||||
mkdir -p $TESTDIR/root
|
||||
@ -100,10 +92,4 @@ EOF
|
||||
umount $TESTDIR/root
|
||||
}
|
||||
|
||||
test_cleanup() {
|
||||
umount $TESTDIR/root 2>/dev/null
|
||||
[[ $LOOPDEV ]] && losetup -d $LOOPDEV
|
||||
return 0
|
||||
}
|
||||
|
||||
do_test "$@"
|
||||
|
@ -2,32 +2,10 @@
|
||||
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
|
||||
# ex: ts=8 sw=4 sts=4 et filetype=sh
|
||||
TEST_DESCRIPTION="systemd-nspawn smoke test"
|
||||
TEST_NO_NSPAWN=1
|
||||
SKIP_INITRD=yes
|
||||
. $TEST_BASE_DIR/test-functions
|
||||
|
||||
check_result_qemu() {
|
||||
ret=1
|
||||
mkdir -p $TESTDIR/root
|
||||
mount ${LOOPDEV}p1 $TESTDIR/root
|
||||
[[ -e $TESTDIR/root/testok ]] && ret=0
|
||||
[[ -f $TESTDIR/root/failed ]] && cp -a $TESTDIR/root/failed $TESTDIR
|
||||
cp -a $TESTDIR/root/var/log/journal $TESTDIR
|
||||
umount $TESTDIR/root
|
||||
[[ -f $TESTDIR/failed ]] && cat $TESTDIR/failed
|
||||
ls -l $TESTDIR/journal/*/*.journal
|
||||
test -s $TESTDIR/failed && ret=$(($ret+1))
|
||||
return $ret
|
||||
}
|
||||
|
||||
test_run() {
|
||||
if run_qemu; then
|
||||
check_result_qemu || return 1
|
||||
else
|
||||
dwarn "can't run QEMU, skipping"
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
test_setup() {
|
||||
create_empty_image
|
||||
mkdir -p $TESTDIR/root
|
||||
@ -153,10 +131,4 @@ EOF
|
||||
umount $TESTDIR/root
|
||||
}
|
||||
|
||||
test_cleanup() {
|
||||
umount $TESTDIR/root 2>/dev/null
|
||||
[[ $LOOPDEV ]] && losetup -d $LOOPDEV
|
||||
return 0
|
||||
}
|
||||
|
||||
do_test "$@"
|
||||
|
@ -2,32 +2,10 @@
|
||||
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
|
||||
# ex: ts=8 sw=4 sts=4 et filetype=sh
|
||||
TEST_DESCRIPTION="Basic systemd setup"
|
||||
TEST_NO_NSPAWN=1
|
||||
SKIP_INITRD=yes
|
||||
. $TEST_BASE_DIR/test-functions
|
||||
|
||||
check_result_qemu() {
|
||||
ret=1
|
||||
mkdir -p $TESTDIR/root
|
||||
mount ${LOOPDEV}p1 $TESTDIR/root
|
||||
[[ -e $TESTDIR/root/testok ]] && ret=0
|
||||
[[ -f $TESTDIR/root/failed ]] && cp -a $TESTDIR/root/failed $TESTDIR
|
||||
cp -a $TESTDIR/root/var/log/journal $TESTDIR
|
||||
umount $TESTDIR/root
|
||||
[[ -f $TESTDIR/failed ]] && cat $TESTDIR/failed
|
||||
ls -l $TESTDIR/journal/*/*.journal
|
||||
test -s $TESTDIR/failed && ret=$(($ret+1))
|
||||
return $ret
|
||||
}
|
||||
|
||||
test_run() {
|
||||
if run_qemu; then
|
||||
check_result_qemu || return 1
|
||||
else
|
||||
dwarn "can't run QEMU, skipping"
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
test_setup() {
|
||||
create_empty_image
|
||||
mkdir -p $TESTDIR/root
|
||||
@ -110,10 +88,4 @@ chmod +x $initdir/test-machine-id-setup.sh
|
||||
umount $TESTDIR/root
|
||||
}
|
||||
|
||||
test_cleanup() {
|
||||
umount $TESTDIR/root 2>/dev/null
|
||||
[[ $LOOPDEV ]] && losetup -d $LOOPDEV
|
||||
return 0
|
||||
}
|
||||
|
||||
do_test "$@"
|
||||
|
@ -3,22 +3,10 @@
|
||||
# ex: ts=8 sw=4 sts=4 et filetype=sh
|
||||
|
||||
TEST_DESCRIPTION="Dropin tests"
|
||||
TEST_NO_QEMU=1
|
||||
|
||||
. $TEST_BASE_DIR/test-functions
|
||||
|
||||
|
||||
test_run_nspawn() {
|
||||
if ! run_nspawn; then
|
||||
dwarn "can't run systemd-nspawn, skipping"
|
||||
return 0
|
||||
fi
|
||||
check_result_nspawn
|
||||
}
|
||||
|
||||
test_run() {
|
||||
test_run_nspawn || return
|
||||
}
|
||||
|
||||
test_setup() {
|
||||
# create the basic filesystem layout
|
||||
setup_basic_environment >/dev/null
|
||||
|
@ -375,6 +375,22 @@ check_result_nspawn() {
|
||||
return $ret
|
||||
}
|
||||
|
||||
# can be overridden in specific test
|
||||
check_result_qemu() {
|
||||
ret=1
|
||||
mkdir -p $TESTDIR/root
|
||||
mount ${LOOPDEV}p1 $TESTDIR/root
|
||||
[[ -e $TESTDIR/root/testok ]] && ret=0
|
||||
[[ -f $TESTDIR/root/failed ]] && cp -a $TESTDIR/root/failed $TESTDIR
|
||||
cp -a $TESTDIR/root/var/log/journal $TESTDIR
|
||||
umount $TESTDIR/root
|
||||
[[ -f $TESTDIR/failed ]] && cat $TESTDIR/failed
|
||||
ls -l $TESTDIR/journal/*/*.journal
|
||||
test -s $TESTDIR/failed && ret=$(($ret+1))
|
||||
[ -n "$TIMED_OUT" ] && ret=$(($ret+1))
|
||||
return $ret
|
||||
}
|
||||
|
||||
strip_binaries() {
|
||||
if [[ "$STRIP_BINARIES" = "no" ]]; then
|
||||
ddebug "Don't strip binaries"
|
||||
@ -1360,6 +1376,31 @@ setup_suse() {
|
||||
inst_simple "/usr/lib/systemd/system/haveged.service"
|
||||
}
|
||||
|
||||
# can be overridden in specific test
|
||||
test_cleanup() {
|
||||
umount $TESTDIR/root 2>/dev/null || true
|
||||
[[ $LOOPDEV ]] && losetup -d $LOOPDEV
|
||||
return 0
|
||||
}
|
||||
|
||||
test_run() {
|
||||
if [ -z "$TEST_NO_QEMU" ]; then
|
||||
if run_qemu; then
|
||||
check_result_qemu || return 1
|
||||
else
|
||||
dwarn "can't run QEMU, skipping"
|
||||
fi
|
||||
fi
|
||||
if [ -z "$TEST_NO_NSPAWN" ]; then
|
||||
if run_nspawn; then
|
||||
check_result_nspawn || return 1
|
||||
else
|
||||
dwarn "can't run systemd-nspawn, skipping"
|
||||
fi
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
do_test() {
|
||||
if [[ $UID != "0" ]]; then
|
||||
echo "TEST: $TEST_DESCRIPTION [SKIPPED]: not root" >&2
|
||||
|
Loading…
Reference in New Issue
Block a user