[apparmor] [patch] caching tests: reorder timeout test and add sleep

Steve Beattie steve at nxnw.org
Wed Sep 15 22:18:32 BST 2010


After Kees' patch to enable the caching testsuite in the parser, I get
occasional failures on ext3 in the "Profiles are cached when requested:"
test case due to the cache file and the profile having the same
timestamp; this patch reorders the timstamp check to move it to the
beginning of the script and adds an additional sleep before the parser
invocation that generates the cache file for the first time.

This is both for trunk and for 2.5.1.

=== modified file 'parser/tst/caching.sh'
--- parser/tst/caching.sh	2010-09-14 19:45:34 +0000
+++ parser/tst/caching.sh	2010-09-15 20:51:19 +0000
@@ -13,6 +13,18 @@
 profile=sbin.pingy
 cp caching.profile $basedir/$profile
 
+# Detect and slow down cache test when filesystem can't represent nanosecond delays.
+timeout=0.1
+touch $basedir/test1
+sleep $timeout
+touch $basedir/test2
+TIMES=$(stat $basedir/test1 $basedir/test2 -c %z | cut -d" " -f2 | cut -d. -f2 | sort -u | wc -l)
+if [ $TIMES -ne 2 ]; then
+    echo "WARNING: $basedir lacks nanosecond timestamp resolution, falling back to slower test"
+    timeout=1
+fi
+rm -f $basedir/test1 $basedir/test2
+
 echo -n "Profiles are not cached by default: "
 ../apparmor_parser $ARGS -q -r $basedir/$profile
 [ -f $basedir/cache/$profile ] && echo "FAIL ($basedir/cache/$profile exists)" && exit 1
@@ -23,6 +35,8 @@
 [ -f $basedir/cache/$profile ] && echo "FAIL ($basedir/cache/$profile exists)" && exit 1
 echo "ok"
 
+sleep $timeout
+
 echo -n "Profiles are cached when requested: "
 ../apparmor_parser $ARGS -q --write-cache -r $basedir/$profile
 [ ! -f $basedir/cache/$profile ] && echo "FAIL ($basedir/cache/$profile does not exist)" && exit 1
@@ -62,18 +76,6 @@
 [ ! -f $basedir/cache/$profile ] && echo "FAIL ($basedir/cache/$profile does not exist)" && exit 1
 echo "ok"
 
-# Detect and slow down cache test when filesystem can't represent nanosecond delays.
-timeout=0.1
-touch $basedir/test1
-sleep $timeout
-touch $basedir/test2
-TIMES=$(stat $basedir/test1 $basedir/test2 -c %z | cut -d" " -f2 | cut -d. -f2 | sort -u | wc -l)
-if [ $TIMES -ne 2 ]; then
-    echo "WARNING: $basedir lacks nanosecond timestamp resolution, falling back to slower test"
-    timeout=1
-fi
-rm -f $basedir/test1 $basedir/test2
-
 echo -n "Cache reading is skipped when profile is newer: "
 sleep $timeout
 touch $basedir/$profile


-- 
Steve Beattie
<sbeattie at ubuntu.com>
http://NxNW.org/~steve/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
Url : https://lists.ubuntu.com/archives/apparmor/attachments/20100915/4e28d346/attachment.pgp 


More information about the AppArmor mailing list