[apparmor] [PATCH 1/2] tests: Fix mount.sh test error

Seth Arnold seth.arnold at canonical.com
Thu Apr 24 18:59:50 UTC 2014


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 <tyhicks at canonical.com>

Acked-by: Seth Arnold <seth.arnold at 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 at lists.ubuntu.com
> Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/apparmor
> 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: Digital signature
URL: <https://lists.ubuntu.com/archives/apparmor/attachments/20140424/489dec5e/attachment.pgp>


More information about the AppArmor mailing list