if USE_SYSTEM is not set, the utils make check target will instruct test-aa-easyprof.py to provide the path of the in-tree parser executable to aa-easyprof.
If USE_SYSTEM is set, the default parser path (/sbin/apparmor_parser or the result of `which apparmor_parser`) is used. The test-aa-easyprof.py script receives the parser path by checking the __AA_PARSER environment variable. This environment variable is strictly used by the test script and not any user-facing code so two leading underscores were used. Signed-off-by: Tyler Hicks <[email protected]> Acked-by: Christian Boltz <[email protected]> Acked-by: Seth Arnold <[email protected]> --- utils/test/Makefile | 6 ++++-- utils/test/test-aa-easyprof.py | 7 +++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/utils/test/Makefile b/utils/test/Makefile index ce08cbb..db2312e 100644 --- a/utils/test/Makefile +++ b/utils/test/Makefile @@ -25,6 +25,7 @@ ifdef USE_SYSTEM PYTHONPATH= CONFDIR= BASEDIR= + PARSER= else # PYTHON_DIST_BUILD_PATH based on libapparmor/swig/python/test/Makefile.am PYTHON_DIST_BUILD_PATH = ../../libraries/libapparmor/swig/python/build/$$($(PYTHON) -c "import distutils.util; import platform; print(\"lib.%s-%s\" %(distutils.util.get_platform(), platform.python_version()[:3]))") @@ -32,6 +33,7 @@ else PYTHONPATH=..:$(PYTHON_DIST_BUILD_PATH) CONFDIR=$(CURDIR) BASEDIR=../../profiles/apparmor.d + PARSER=../../parser/apparmor_parser endif .PHONY: __libapparmor @@ -66,10 +68,10 @@ clean: rm -rf __pycache__/ .coverage htmlcov check: __libapparmor - export PYTHONPATH=$(PYTHONPATH) LD_LIBRARY_PATH=$(LD_LIBRARY_PATH) LC_ALL=C __AA_CONFDIR=$(CONFDIR) __AA_BASEDIR=$(BASEDIR) ; $(foreach test, $(wildcard test-*.py), echo ; echo === $(test) === ; $(call pyalldo, $(test))) + export PYTHONPATH=$(PYTHONPATH) LD_LIBRARY_PATH=$(LD_LIBRARY_PATH) LC_ALL=C __AA_CONFDIR=$(CONFDIR) __AA_BASEDIR=$(BASEDIR) __AA_PARSER=$(PARSER) ; $(foreach test, $(wildcard test-*.py), echo ; echo === $(test) === ; $(call pyalldo, $(test))) .coverage: $(wildcard ../aa-* ../apparmor/*.py test-*.py) __libapparmor - export PYTHONPATH=$(PYTHONPATH) LD_LIBRARY_PATH=$(LD_LIBRARY_PATH) LC_ALL=C __AA_CONFDIR=$(CONFDIR) __AA_BASEDIR=$(BASEDIR) ; $(COVERAGE_IGNORE_FAILURES_CMD) ; $(foreach test, $(wildcard test-*.py), echo ; echo === $(test) === ; $(PYTHON) -m coverage run --branch -p $(test); ) + export PYTHONPATH=$(PYTHONPATH) LD_LIBRARY_PATH=$(LD_LIBRARY_PATH) LC_ALL=C __AA_CONFDIR=$(CONFDIR) __AA_BASEDIR=$(BASEDIR) __AA_PARSER=$(PARSER) ; $(COVERAGE_IGNORE_FAILURES_CMD) ; $(foreach test, $(wildcard test-*.py), echo ; echo === $(test) === ; $(PYTHON) -m coverage run --branch -p $(test); ) $(PYTHON) -m coverage combine coverage: .coverage diff --git a/utils/test/test-aa-easyprof.py b/utils/test/test-aa-easyprof.py index 8f7e916..e7916de 100755 --- a/utils/test/test-aa-easyprof.py +++ b/utils/test/test-aa-easyprof.py @@ -173,6 +173,13 @@ TEMPLATES_DIR="%s/templates" if base: self.full_args.append('--base=%s' % base) + # Check __AA_PARSER, which may be set by the Makefile, to see if + # we should use a non-default apparmor_parser path to verify + # policy + parser = os.getenv('__AA_PARSER') + if parser: + self.full_args.append('--parser=%s' % parser) + if debugging: self.full_args.append('-d') -- 2.7.4 -- AppArmor mailing list [email protected] Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/apparmor
