[apparmor] [patch] regression swap test: skip if on tmpfs

Steve Beattie steve at nxnw.org
Wed Mar 19 07:29:58 UTC 2014


The regression swap test attempts to activate a swap file in a directory
under where the tmpdir[1] set in uservars.inc; if this is a tmpfs
filesystem, this will fail (it's kind of silly to create a swap file on
a tmpfs i.e. a memory-backed filesystem). This patch adds a check for
that to the swap test script, skips the tests and marks the test as a
failure if the check fails.

[1] Sadly, it does not honor TMPDIR.

Signed-off-by: Steve Beattie <steve at nxnw.org>
---
 tests/regression/apparmor/swap.sh |    9 +++++++++
 1 file changed, 9 insertions(+)

Index: b/tests/regression/apparmor/swap.sh
===================================================================
--- a/tests/regression/apparmor/swap.sh
+++ b/tests/regression/apparmor/swap.sh
@@ -27,6 +27,15 @@ bin=$pwd
 ## A. SWAP
 ##
 
+# check if we can run the test at all
+fstype=$(stat -f --format '%T' "${tmpdir}")
+if [ "${fstype}" == "tmpfs" ] ; then
+	echo "ERROR: tmpdir '${tmpdir}' is of type tmpfs; can't mount a swapfile on it" 1>&2
+	echo "ERROR: skipping swap tests" 1>&2
+	num_testfailures=1
+	exit
+fi
+
 swap_file=$tmpdir/swapfile
 
 dd if=/dev/zero of=${swap_file} bs=1024 count=512 2> /dev/null

-- 
Steve Beattie
<sbeattie at ubuntu.com>
http://NxNW.org/~steve/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <https://lists.ubuntu.com/archives/apparmor/attachments/20140319/66e75044/attachment.pgp>


More information about the AppArmor mailing list