[apparmor] [patch] parser caching test: more accurate detection of fs timestamp limitation

John Johansen john.johansen at canonical.com
Sat Dec 8 00:56:28 UTC 2012


On 12/07/2012 04:34 PM, Steve Beattie wrote:
> 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/ )
> 

Acked-by: John Johansen <john.johansen at canonical.com>

> === 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
> 
> 
> 




More information about the AppArmor mailing list