On Thu, Apr 24, 2014 at 01:06:05AM -0500, Tyler Hicks wrote: > 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 <tyhi...@canonical.com>
Acked-by: Seth Arnold <seth.arn...@canonical.com> Thanks > --- > tests/regression/apparmor/mount.sh | 14 +++++++++----- > 1 file changed, 9 insertions(+), 5 deletions(-) > > diff --git a/tests/regression/apparmor/mount.sh > b/tests/regression/apparmor/mount.sh > index fa3e931..b4951a8 100755 > --- a/tests/regression/apparmor/mount.sh > +++ b/tests/regression/apparmor/mount.sh > @@ -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 > -- > 1.9.1 > > > -- > AppArmor mailing list > AppArmor@lists.ubuntu.com > Modify settings or unsubscribe at: > https://lists.ubuntu.com/mailman/listinfo/apparmor >
signature.asc
Description: Digital signature
-- AppArmor mailing list AppArmor@lists.ubuntu.com Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/apparmor