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 <[email protected]>
---
 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
<[email protected]>
http://NxNW.org/~steve/

Attachment: signature.asc
Description: Digital signature

-- 
AppArmor mailing list
[email protected]
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/apparmor

Reply via email to