[apparmor] [patch] Change utils/test/Makefile to use the in-tree libapparmor

John Johansen john.johansen at canonical.com
Tue Oct 20 20:22:44 UTC 2015


On 09/09/2015 05:32 AM, Christian Boltz wrote:
> Hello,
> 
> this patch changes utils/test/Makefile to use the in-tree libapparmor.
> 
> It also adds support for the USE_SYSTEM variable, which means:
> - test against the in-tree libapparmor and python modules by default
> - test against the system libapparmor and python modules if USE_SYSTEM
>   is set
> 
> The old behaviour was a mix of both - it always used the in-tree python
> modules and the system libapparmor.
> 
> For obvious reasons, you'll need to build libapparmor before running the
> tests (unless you specify USE_SYSTEM=1 as parameter to make check).
> 
> 
> This patch also means Steve can no longer argue it's hard to test my
> patches because he has an old libapparmor installed - therefore I expect
> quicker reviews in the future ;-)
> 
> 
> I propose this patch for trunk and 2.9.
> 
> 
Acked-by: John Johansen <john.johansen at canonical.com>


> [ 85-utils-test-with-in-tree-libapparmor.diff ]
> 
> === modified file ./utils/test/Makefile
> --- utils/test/Makefile 2015-01-24 19:10:51.725549000 +0100
> +++ utils/test/Makefile 2015-09-09 14:29:16.916162945 +0200
> @@ -20,6 +20,25 @@
>  
>  include $(COMMONDIR)/Make.rules
>  
> +ifdef USE_SYSTEM
> +    LD_LIBRARY_PATH=
> +    PYTHONPATH=
> +else
> +    LD_LIBRARY_PATH=../../libraries/libapparmor/src/.libs/
> +    PYTHONPATH=..
> +endif
> +
> +.PHONY: __libapparmor
> +__libapparmor:
> +ifndef USE_SYSTEM
> +       @if [ ! -f $(LD_LIBRARY_PATH)libapparmor.so ]; then \
> +               echo "error: $(LD_LIBRARY_PATH)libapparmor.so is missing. Pick one of these possible solutions:" 1>&2; \
> +               echo "  1) Build against the in-tree libapparmor by building it first and then trying again. See the top-level README for help." 1>&2; \
> +               echo "  2) Build against the system libapparmor by adding USE_SYSTEM=1 to your make command." 1>&2; \
> +               return 1; \
> +       fi
> +endif
> +
>  COVERAGE_OMIT=test-*.py,common_test.py
>  ifneq ($(COVERAGE_OUT), )
>  HTML_COVR_ARGS=-d $(COVERAGE_OUT)
> @@ -40,11 +59,11 @@
>  clean:
>         rm -rf __pycache__/ .coverage htmlcov
>  
> -check:
> -       export PYTHONPATH=.. ; $(foreach test, $(wildcard test-*.py), $(call pyalldo, $(test)))
> +check: __libapparmor
> +       export PYTHONPATH=$(PYTHONPATH) ; export LD_LIBRARY_PATH=$(LD_LIBRARY_PATH) ; $(foreach test, $(wildcard test-*.py), $(call pyalldo, $(test)))
>  
> -.coverage: $(wildcard ../aa-* ../apparmor/*.py test-*.py)
> -       export PYTHONPATH=.. ; $(COVERAGE_IGNORE_FAILURES_CMD) ; $(foreach test, $(wildcard test-*.py), $(PYTHON) -m coverage run --branch -p $(test); )
> +.coverage: $(wildcard ../aa-* ../apparmor/*.py test-*.py) __libapparmor
> +       export PYTHONPATH=$(PYTHONPATH) ; export LD_LIBRARY_PATH=$(LD_LIBRARY_PATH); $(COVERAGE_IGNORE_FAILURES_CMD) ; $(foreach test, $(wildcard test-*.py), $(PYTHON) -m coverage run --branch -p $(test); )
>         $(PYTHON) -m coverage combine
>  
>  coverage: .coverage
> 
> 
> 
> Regards,
> 
> Christian Boltz
> 




More information about the AppArmor mailing list