Re: [apparmor] [patch 1/3] parameterize parser tests to support different binaries

2012-11-05 Thread John Johansen
On 10/26/2012 10:59 AM, Steve Beattie wrote:
> This patch replaces the hardcoded path to the in-tree apparmor parser
> in several of the script based test scripts with the APPARMOR_PARSER
> environment variable, keeping the hardcoded location as the default.
> It also adds support for overriding the location of the parser via the
> same environment variable. The make infrastructure is updated to use
> this, though uses a different variable (PARSER) to drive it.
> 
> Thus 'make check PARSER=/some/path/to/an/alternate/apparmor_parser'
> will run all the parser tests on that binary. This is useful for
> running the testsuite in an automated post-install environment.
> (It should be noted that doing so will still build and run the unit
> test binaries based on the source tree.)

Acked-by: John Johansen 


-- 
AppArmor mailing list
AppArmor@lists.ubuntu.com
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/apparmor


[apparmor] [patch 1/3] parameterize parser tests to support different binaries

2012-10-26 Thread Steve Beattie
This patch replaces the hardcoded path to the in-tree apparmor parser
in several of the script based test scripts with the APPARMOR_PARSER
environment variable, keeping the hardcoded location as the default.
It also adds support for overriding the location of the parser via the
same environment variable. The make infrastructure is updated to use
this, though uses a different variable (PARSER) to drive it.

Thus 'make check PARSER=/some/path/to/an/alternate/apparmor_parser'
will run all the parser tests on that binary. This is useful for
running the testsuite in an automated post-install environment.
(It should be noted that doing so will still build and run the unit
test binaries based on the source tree.)

---
 parser/tst/Makefile|6 +++---
 parser/tst/README  |4 
 parser/tst/caching.sh  |   30 --
 parser/tst/minimize.sh |   19 +++
 parser/tst/simple.pl   |8 +++-
 5 files changed, 41 insertions(+), 26 deletions(-)

Index: b/parser/tst/Makefile
===
--- a/parser/tst/Makefile
+++ b/parser/tst/Makefile
@@ -36,13 +36,13 @@ error_output: $(PARSER)
@echo "Error Output: PASS"
 
 parser_sanity: $(PARSER)
-   $(Q)${PROVE} ${PROVE_ARG} ${TESTS}
+   $(Q)LANG=C APPARMOR_PARSER="$(PARSER)" ${PROVE} ${PROVE_ARG} ${TESTS}
 
 caching: $(PARSER)
-   LANG=C ./caching.sh
+   LANG=C APPARMOR_PARSER="$(PARSER)" ./caching.sh
 
 minimize: $(PARSER)
-   LANG=C ./minimize.sh
+   LANG=C APPARMOR_PARSER="$(PARSER)" ./minimize.sh
 
 $(PARSER):
make -C $(PARSER_DIR) $(PARSER_BIN)
Index: b/parser/tst/caching.sh
===
--- a/parser/tst/caching.sh
+++ b/parser/tst/caching.sh
@@ -10,6 +10,8 @@ if [ ! -d /sys/kernel/security/apparmor
 exit 0
 fi
 
+APPARMOR_PARSER="${APPARMOR_PARSER:-../apparmor_parser}"
+
 # fake base directory
 basedir=$(mktemp -d -t aa-cache-XX)
 trap "rm -rf $basedir" EXIT
@@ -33,19 +35,19 @@ fi
 rm -f $basedir/test1 $basedir/test2
 
 echo -n "Profiles are not cached by default: "
-../apparmor_parser $ARGS -q -r $basedir/$profile
+${APPARMOR_PARSER} $ARGS -q -r $basedir/$profile
 [ -f $basedir/cache/$profile ] && echo "FAIL ($basedir/cache/$profile exists)" 
&& exit 1
 echo "ok"
 
 echo -n "Profiles are not cached when using --skip-cache: "
-../apparmor_parser $ARGS -q --write-cache --skip-cache -r $basedir/$profile
+${APPARMOR_PARSER} $ARGS -q --write-cache --skip-cache -r $basedir/$profile
 [ -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
+${APPARMOR_PARSER} $ARGS -q --write-cache -r $basedir/$profile
 [ ! -f $basedir/cache/$profile ] && echo "FAIL ($basedir/cache/$profile does 
not exist)" && exit 1
 echo "ok"
 
@@ -80,22 +82,22 @@ fi
 echo "ok"
 
 echo -n "Cache is loaded when it exists and features match: "
-../apparmor_parser $ARGS -v -r $basedir/$profile | grep -q 'Cached reload 
succeeded' || { echo "FAIL"; exit 1; }
+${APPARMOR_PARSER} $ARGS -v -r $basedir/$profile | grep -q 'Cached reload 
succeeded' || { echo "FAIL"; exit 1; }
 echo "ok"
 
 echo -n "Cache is not loaded when skipping is requested: "
-../apparmor_parser $ARGS -v --skip-read-cache -r $basedir/$profile | grep -q 
'Replacement succeeded for' || { echo "FAIL"; exit 1; }
-../apparmor_parser $ARGS -v --skip-cache -r $basedir/$profile | grep -q 
'Replacement succeeded for' || { echo "FAIL"; exit 1; }
+${APPARMOR_PARSER} $ARGS -v --skip-read-cache -r $basedir/$profile | grep -q 
'Replacement succeeded for' || { echo "FAIL"; exit 1; }
+${APPARMOR_PARSER} $ARGS -v --skip-cache -r $basedir/$profile | grep -q 
'Replacement succeeded for' || { echo "FAIL"; exit 1; }
 echo "ok"
 
 echo -n "Cache reading is skipped when features do not match cache: "
 echo -n "monkey" > $basedir/cache/.features
-../apparmor_parser $ARGS -v -r $basedir/$profile | grep -q 'Replacement 
succeeded for' || { echo "FAIL"; exit 1; }
+${APPARMOR_PARSER} $ARGS -v -r $basedir/$profile | grep -q 'Replacement 
succeeded for' || { echo "FAIL"; exit 1; }
 echo "ok"
 
 echo -n "Cache writing is skipped when features do not match and not cleared: "
 rm $basedir/cache/$profile
-../apparmor_parser $ARGS -v --write-cache --skip-bad-cache -r 
$basedir/$profile | grep -q 'Replacement succeeded for' || { echo "FAIL"; exit 
1; }
+${APPARMOR_PARSER} $ARGS -v --write-cache --skip-bad-cache -r 
$basedir/$profile | grep -q 'Replacement succeeded for' || { echo "FAIL"; exit 
1; }
 [ -f $basedir/cache/$profile ] && echo "FAIL ($basedir/cache/$profile exists)" 
&& exit 1
 echo "ok"
 
@@ -104,7 +106,7 @@ rm -f $basedir/cache/$profile || true
 echo -n "monkey" > $basedir/cache/.features
 echo -n "monkey" > $basedir/cache/$profile
 echo -n "monkey" > $basedir/cache/monkey
-../apparmor_pa