From fca085a3523186728739142e69c426389eb1e968 Mon Sep 17 00:00:00 2001 From: Tyler Hicks Date: Mon, 4 Dec 2017 18:03:44 +0000 Subject: [PATCH 1/2] utils: Gracefully handle a missing parser in the check target The test-aa-easyprof.py script relies on the parser to be built so the check target of the utils/test/Makefile should detect if the parser exists before running any tests. Signed-off-by: Tyler Hicks Reported-by: Christian Boltz --- utils/test/Makefile | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/utils/test/Makefile b/utils/test/Makefile index db2312efb..cce58d1ba 100644 --- a/utils/test/Makefile +++ b/utils/test/Makefile @@ -36,7 +36,7 @@ else PARSER=../../parser/apparmor_parser endif -.PHONY: __libapparmor +.PHONY: __libapparmor __parser __libapparmor: ifndef USE_SYSTEM @if [ ! -f $(LD_LIBRARY_PATH)libapparmor.so ]; then \ @@ -47,6 +47,16 @@ ifndef USE_SYSTEM fi endif +__parser: +ifndef USE_SYSTEM + @if [ ! -f $(PARSER) ]; then \ + echo "error: $(PARSER) is missing. Pick one of these possible solutions:" 1>&2; \ + echo " 1) Test using the in-tree parser by building it first and then trying again. See the top-level README for help." 1>&2; \ + echo " 2) Test using the system parser by adding USE_SYSTEM=1 to your make command." 1>&2; \ + exit 1; \ + fi +endif + COVERAGE_OMIT=test-*.py,common_test.py ifneq ($(COVERAGE_OUT), ) HTML_COVR_ARGS=-d $(COVERAGE_OUT) @@ -67,10 +77,10 @@ endif clean: rm -rf __pycache__/ .coverage htmlcov -check: __libapparmor +check: __libapparmor __parser 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 +.coverage: $(wildcard ../aa-* ../apparmor/*.py test-*.py) __libapparmor __parser 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 From da42248a954b6e4081e785ac4cf8c14257b94a77 Mon Sep 17 00:00:00 2001 From: Tyler Hicks Date: Mon, 4 Dec 2017 18:08:16 +0000 Subject: [PATCH 2/2] README: Document that the parser should be built before the utils The utils have tests that rely on the in-tree parser to be built so it should be documented that the parser should be built first. Signed-off-by: Tyler Hicks --- README | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/README b/README index 54bc47f8d..5fa95c2b3 100644 --- a/README +++ b/README @@ -79,16 +79,16 @@ $ make check $ make install -Utilities: -$ cd utils -$ make +parser: +$ cd parser +$ make # depends on libapparmor having been built first $ make check $ make install -parser: -$ cd parser -$ make # depends on libapparmor having been built first +Utilities: +$ cd utils +$ make $ make check $ make install