mirror of
https://gitlab.com/apparmor/apparmor.git
synced 2025-03-04 08:24:42 +01:00
tests: Fix mount.sh test error
The end of the mount.sh regression test script contained cleanup commands to unmount and detach the loop device used for testing. However, the second losetup command fails and, with the recent regression test suite fix to not ignore failed shell commands, an error is triggered at the end of the test run. Additionally, these cleanup commands are not ran when the test fails during the test run and an immediate exit is requested upon failure (with the -r flag). This patch fixes and moves the cleanup logic into a function that is assigned to do_onexit so that the cleanup is always performed at exit and the test can run successfully. Signed-off-by: Tyler Hicks <tyhicks@canonical.com> Acked-by: Seth Arnold <seth.arnold@canonical.com>
This commit is contained in:
parent
b3863c8af7
commit
d3030f8627
1 changed files with 9 additions and 5 deletions
|
@ -47,6 +47,15 @@ remove_mnt() {
|
|||
fi
|
||||
}
|
||||
|
||||
mount_cleanup() {
|
||||
remove_mnt &> /dev/null
|
||||
if [ "$loop_device" != "unset" ]
|
||||
then
|
||||
/sbin/losetup -d ${loop_device} &> /dev/null
|
||||
fi
|
||||
}
|
||||
do_onexit="mount_cleanup"
|
||||
|
||||
dd if=/dev/zero of=${mount_file} bs=1024 count=512 2> /dev/null
|
||||
/sbin/mkfs -t${fstype} -F ${mount_file} > /dev/null 2> /dev/null
|
||||
/bin/mkdir ${mount_point}
|
||||
|
@ -163,8 +172,3 @@ else
|
|||
fi
|
||||
|
||||
#need tests for move mount, remount, bind mount, chroot
|
||||
|
||||
# cleanup, umount file
|
||||
/bin/umount ${loop_device} > /dev/null 2> /dev/null || /sbin/losetup -d ${loop_device} > /dev/null 2> /dev/null
|
||||
|
||||
/sbin/losetup -d ${loop_device} > /dev/null 2> /dev/null
|
||||
|
|
Loading…
Add table
Reference in a new issue