summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2019-08-18 17:34:35 +0200
committerGitHub <noreply@github.com>2019-08-18 17:34:35 +0200
commit134075bf30560e3ec6893126f1ae9ed1146cd653 (patch)
treec116151e4ea0d95aabb615c1373adae556e1d369 /test
parenttest: increase qemu timeout for TEST-18 and TEST-19 (diff)
parenttest/test-functions: add mkdir to import_initdir (diff)
downloadsystemd-134075bf30560e3ec6893126f1ae9ed1146cd653.tar.xz
systemd-134075bf30560e3ec6893126f1ae9ed1146cd653.zip
Merge pull request #13344 from ddstreet/test-functions
Minor/cosmetic changes to test/test-functions, some test.sh
Diffstat (limited to 'test')
-rwxr-xr-xtest/TEST-02-CRYPTSETUP/test.sh24
-rwxr-xr-xtest/TEST-24-UNIT-TESTS/test.sh22
-rwxr-xr-xtest/TEST-33-CLEAN-UNIT/test.sh7
-rwxr-xr-xtest/TEST-36-NUMAPOLICY/test.sh7
-rw-r--r--test/test-functions36
5 files changed, 44 insertions, 52 deletions
diff --git a/test/TEST-02-CRYPTSETUP/test.sh b/test/TEST-02-CRYPTSETUP/test.sh
index 16fda42754..801dc71569 100755
--- a/test/TEST-02-CRYPTSETUP/test.sh
+++ b/test/TEST-02-CRYPTSETUP/test.sh
@@ -7,15 +7,15 @@ TEST_NO_NSPAWN=1
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
+ mkdir -p $initdir
+ mount ${LOOPDEV}p1 $initdir
+ [[ -e $initdir/testok ]] && ret=0
+ [[ -f $initdir/failed ]] && cp -a $initdir/failed $TESTDIR
cryptsetup luksOpen ${LOOPDEV}p2 varcrypt <$TESTDIR/keyfile
- mount /dev/mapper/varcrypt $TESTDIR/root/var
- cp -a $TESTDIR/root/var/log/journal $TESTDIR
- umount $TESTDIR/root/var
- umount $TESTDIR/root
+ mount /dev/mapper/varcrypt $initdir/var
+ cp -a $initdir/var/log/journal $TESTDIR
+ umount $initdir/var
+ umount $initdir
cryptsetup luksClose /dev/mapper/varcrypt
[[ -f $TESTDIR/failed ]] && cat $TESTDIR/failed
ls -l $TESTDIR/journal/*/*.journal
@@ -30,8 +30,8 @@ test_setup() {
cryptsetup -q luksFormat --pbkdf pbkdf2 --pbkdf-force-iterations 1000 ${LOOPDEV}p2 $TESTDIR/keyfile
cryptsetup luksOpen ${LOOPDEV}p2 varcrypt <$TESTDIR/keyfile
mkfs.ext4 -L var /dev/mapper/varcrypt
- mkdir -p $TESTDIR/root/var
- mount /dev/mapper/varcrypt $TESTDIR/root/var
+ mkdir -p $initdir/var
+ mount /dev/mapper/varcrypt $initdir/var
# Create what will eventually be our root filesystem onto an overlay
(
@@ -77,8 +77,8 @@ EOF
}
cleanup_root_var() {
- ddebug "umount $TESTDIR/root/var"
- mountpoint $TESTDIR/root/var && umount $TESTDIR/root/var
+ ddebug "umount $initdir/var"
+ mountpoint $initdir/var && umount $initdir/var
[[ -b /dev/mapper/varcrypt ]] && cryptsetup luksClose /dev/mapper/varcrypt
}
diff --git a/test/TEST-24-UNIT-TESTS/test.sh b/test/TEST-24-UNIT-TESTS/test.sh
index 2b622676ef..3c993e67f7 100755
--- a/test/TEST-24-UNIT-TESTS/test.sh
+++ b/test/TEST-24-UNIT-TESTS/test.sh
@@ -29,25 +29,25 @@ check_result_nspawn() {
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
+ mkdir -p $initdir
+ mount ${LOOPDEV}p1 $initdir
+ [[ -e $initdir/testok ]] && _ret=0
+ if [[ -s $initdir/failed ]]; then
_ret=$(($_ret+1))
echo "=== Failed test log ==="
- cat $TESTDIR/root/failed
+ cat $initdir/failed
else
- if [[ -s $TESTDIR/root/skipped ]]; then
+ if [[ -s $initdir/skipped ]]; then
echo "=== Skipped test log =="
- cat $TESTDIR/root/skipped
+ cat $initdir/skipped
fi
- if [[ -s $TESTDIR/root/testok ]]; then
+ if [[ -s $initdir/testok ]]; then
echo "=== Passed tests ==="
- cat $TESTDIR/root/testok
+ cat $initdir/testok
fi
fi
- cp -a $TESTDIR/root/var/log/journal $TESTDIR
- umount $TESTDIR/root
+ cp -a $initdir/var/log/journal $TESTDIR
+ umount $initdir
[[ -n "$TIMED_OUT" ]] && _ret=$(($_ret+1))
return $_ret
}
diff --git a/test/TEST-33-CLEAN-UNIT/test.sh b/test/TEST-33-CLEAN-UNIT/test.sh
index 44082af4d4..aeda69baae 100755
--- a/test/TEST-33-CLEAN-UNIT/test.sh
+++ b/test/TEST-33-CLEAN-UNIT/test.sh
@@ -7,9 +7,7 @@ TEST_DESCRIPTION="test CleanUnit"
. $TEST_BASE_DIR/test-functions
test_setup() {
- create_empty_image
- mkdir -p $TESTDIR/root
- mount ${LOOPDEV}p1 $TESTDIR/root
+ create_empty_image_rootdir
(
LOG_LEVEL=5
@@ -41,9 +39,6 @@ EOF
setup_testsuite
) || return 1
setup_nspawn_root
-
- ddebug "umount $TESTDIR/root"
- umount $TESTDIR/root
}
do_test "$@"
diff --git a/test/TEST-36-NUMAPOLICY/test.sh b/test/TEST-36-NUMAPOLICY/test.sh
index f0a321e7a1..5e775b2d5a 100755
--- a/test/TEST-36-NUMAPOLICY/test.sh
+++ b/test/TEST-36-NUMAPOLICY/test.sh
@@ -7,9 +7,7 @@ QEMU_OPTIONS="-numa node,nodeid=0"
. $TEST_BASE_DIR/test-functions
test_setup() {
- create_empty_image
- mkdir -p $TESTDIR/root
- mount ${LOOPDEV}p1 $TESTDIR/root
+ create_empty_image_rootdir
(
LOG_LEVEL=5
@@ -43,9 +41,6 @@ EOF
setup_testsuite
) || return 1
setup_nspawn_root
-
- ddebug "umount $TESTDIR/root"
- umount $TESTDIR/root
}
do_test "$@"
diff --git a/test/test-functions b/test/test-functions
index 47a4fa8111..03bfcaf972 100644
--- a/test/test-functions
+++ b/test/test-functions
@@ -561,8 +561,8 @@ EOF
create_empty_image_rootdir() {
create_empty_image
- mkdir -p $TESTDIR/root
- mount ${LOOPDEV}p1 $TESTDIR/root
+ mkdir -p $initdir
+ mount ${LOOPDEV}p1 $initdir
TEST_SETUP_CLEANUP_ROOTDIR=1
}
@@ -622,13 +622,13 @@ check_result_nspawn() {
# can be overridden in specific test
check_result_qemu() {
local 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
- check_asan_reports "$TESTDIR/root" || ret=$(($ret+1))
- umount $TESTDIR/root
+ mkdir -p $initdir
+ mount ${LOOPDEV}p1 $initdir
+ [[ -e $initdir/testok ]] && ret=0
+ [[ -f $initdir/failed ]] && cp -a $initdir/failed $TESTDIR
+ cp -a $initdir/var/log/journal $TESTDIR
+ check_asan_reports "$initdir" || ret=$(($ret+1))
+ umount $initdir
[[ -f $TESTDIR/failed ]] && cat $TESTDIR/failed
ls -l $TESTDIR/journal/*/*.journal
test -s $TESTDIR/failed && ret=$(($ret+1))
@@ -941,6 +941,7 @@ import_testdir() {
import_initdir() {
initdir=$TESTDIR/root
+ mkdir -p $initdir
export initdir
}
@@ -1668,12 +1669,16 @@ setup_suse() {
inst_simple "/usr/lib/systemd/system/haveged.service"
}
+_umount_dir() {
+ if mountpoint -q $1; then
+ ddebug "umount $1"
+ umount $1
+ fi
+}
+
_test_setup_cleanup() {
# only umount if create_empty_image_rootdir() was called to mount it
- if [[ $TEST_SETUP_CLEANUP_ROOTDIR ]]; then
- ddebug "umount $TESTDIR/root"
- umount $TESTDIR/root
- fi
+ [[ -z $TEST_SETUP_CLEANUP_ROOTDIR ]] || _umount_dir $initdir
}
# can be overridden in specific test
@@ -1685,10 +1690,7 @@ _test_cleanup() {
# (post-test) cleanup should always ignore failure and cleanup as much as possible
(
set +e
- if mountpoint $TESTDIR/root; then
- ddebug "umount $TESTDIR/root"
- umount $TESTDIR/root
- fi
+ _umount_dir $initdir
if [[ $LOOPDEV && -b $LOOPDEV ]]; then
ddebug "losetup -d $LOOPDEV"
losetup -d $LOOPDEV