diff options
Diffstat (limited to 'test/TEST-02-CRYPTSETUP/test.sh')
-rwxr-xr-x | test/TEST-02-CRYPTSETUP/test.sh | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/test/TEST-02-CRYPTSETUP/test.sh b/test/TEST-02-CRYPTSETUP/test.sh index 9d25e94250..e28cec0340 100755 --- a/test/TEST-02-CRYPTSETUP/test.sh +++ b/test/TEST-02-CRYPTSETUP/test.sh @@ -25,13 +25,11 @@ check_result_qemu() { test_setup() { - create_empty_image + create_empty_image_rootdir echo -n test >$TESTDIR/keyfile 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 - mount ${LOOPDEV}p1 $TESTDIR/root mkdir -p $TESTDIR/root/var mount /dev/mapper/varcrypt $TESTDIR/root/var @@ -76,20 +74,22 @@ EOF /dev/mapper/varcrypt /var ext4 defaults 0 1 EOF ) +} +cleanup_root_var() { ddebug "umount $TESTDIR/root/var" - umount $TESTDIR/root/var - cryptsetup luksClose /dev/mapper/varcrypt - ddebug "umount $TESTDIR/root" - umount $TESTDIR/root + mountpoint $TESTDIR/root/var && umount $TESTDIR/root/var + [[ -b /dev/mapper/varcrypt ]] && cryptsetup luksClose /dev/mapper/varcrypt } test_cleanup() { - [ -d $TESTDIR/root/var ] && mountpoint $TESTDIR/root/var && umount $TESTDIR/root/var - [[ -b /dev/mapper/varcrypt ]] && cryptsetup luksClose /dev/mapper/varcrypt - umount $TESTDIR/root 2>/dev/null || true - [[ $LOOPDEV ]] && losetup -d $LOOPDEV - return 0 + cleanup_root_var + _test_cleanup +} + +test_setup_cleanup() { + cleanup_root_var + _test_setup_cleanup } do_test "$@" |