[apparmor] [patch] parser caching test: more accurate detection of fs timestamp limitation
Steve Beattie
steve at nxnw.org
Sat Dec 8 00:34:34 UTC 2012
This patch modifies the parser's caching test to more accurately detect
whether or not the filesystem has a fine enough timestamp resolution.
Occasionally even on filesystems like ext3, the two files' creation
dates would differ when created less than a second apart, which would
typically cause the 'Cache is used when cache is newer' test to fail
because the cached file would have the same timestamp as the profile.
The fix creates 10 files 0.1 seconds apart and ensures that all ten
have distinct timestamps.
(The occasional failure was caught in testing runs like
https://bugs.launchpad.net/qa-regression-testing/+bug/1087061/ )
=== modified file 'parser/tst/caching.sh'
--- parser/tst/caching.sh 2012-11-06 01:22:37 +0000
+++ parser/tst/caching.sh 2012-12-08 00:03:55 +0000
@@ -24,15 +24,17 @@
# 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
+_count=10
+for ((i = 0; i < ${_count} ; i++)) ; do
+ touch $basedir/test${i}
+ sleep $timeout
+done
+TIMES=$(stat $basedir/test* -c %z | cut -d" " -f2 | cut -d: -f3 | sort -u | wc -l)
+if [ $TIMES -ne ${_count} ]; then
echo "WARNING: $basedir lacks nanosecond timestamp resolution, falling back to slower test"
timeout=1
fi
-rm -f $basedir/test1 $basedir/test2
+rm -f $basedir/test*
echo -n "Profiles are not cached by default: "
${APPARMOR_PARSER} $ARGS -q -r $basedir/$profile
--
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: 836 bytes
Desc: Digital signature
URL: <https://lists.ubuntu.com/archives/apparmor/attachments/20121207/a38efd23/attachment.pgp>
More information about the AppArmor
mailing list