[apparmor] [PATCH 6/8] utils: Set parser base path according to USE_SYSTEM make variable
Seth Arnold
seth.arnold at canonical.com
Thu Feb 9 00:22:42 UTC 2017
On Wed, Feb 08, 2017 at 10:01:43PM +0000, Tyler Hicks wrote:
> 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
> profiles/apparmor.d directory to aa-easyprof as the parser base
> directory.
>
> If USE_SYSTEM is set, the default base directory (/etc/apparmor.d) is
> used.
>
> The test-aa-easyprof.py script receives the base path by checking the
> __AA_BASEDIR 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 <tyhicks at canonical.com>
> Cc: Christian Boltz <apparmor at cboltz.de>
> Cc: Jamie Strandboge <jamie at ubuntu.com>
Acked-by: Seth Arnold <seth.arnold at canonical.com>
Thanks
> ---
> utils/test/Makefile | 6 ++++--
> utils/test/test-aa-easyprof.py | 10 ++++++++++
> 2 files changed, 14 insertions(+), 2 deletions(-)
>
> diff --git a/utils/test/Makefile b/utils/test/Makefile
> index f5273e3..0b56a0a 100644
> --- a/utils/test/Makefile
> +++ b/utils/test/Makefile
> @@ -24,12 +24,14 @@ ifdef USE_SYSTEM
> LD_LIBRARY_PATH=
> PYTHONPATH=
> CONFDIR=
> + BASEDIR=
> 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]))")
> LD_LIBRARY_PATH=../../libraries/libapparmor/src/.libs/
> PYTHONPATH=..:$(PYTHON_DIST_BUILD_PATH)
> CONFDIR=$(CURDIR)
> + BASEDIR=../../profiles/apparmor.d
> endif
>
> .PHONY: __libapparmor
> @@ -64,10 +66,10 @@ clean:
> rm -rf __pycache__/ .coverage htmlcov
>
> check: __libapparmor
> - export PYTHONPATH=$(PYTHONPATH) LD_LIBRARY_PATH=$(LD_LIBRARY_PATH) LC_ALL=C APPARMOR_PY_CONFDIR=$(CONFDIR) ; $(foreach test, $(wildcard test-*.py), echo ; echo === $(test) === ; $(call pyalldo, $(test)))
> + export PYTHONPATH=$(PYTHONPATH) LD_LIBRARY_PATH=$(LD_LIBRARY_PATH) LC_ALL=C APPARMOR_PY_CONFDIR=$(CONFDIR) __AA_BASEDIR=$(BASEDIR) ; $(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 APPARMOR_PY_CONFDIR=$(CONFDIR) ; $(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 APPARMOR_PY_CONFDIR=$(CONFDIR) __AA_BASEDIR=$(BASEDIR) ; $(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 3ebfec6..8f7e916 100755
> --- a/utils/test/test-aa-easyprof.py
> +++ b/utils/test/test-aa-easyprof.py
> @@ -163,6 +163,16 @@ TEMPLATES_DIR="%s/templates"
> self.binary = "/opt/bin/foo"
> self.full_args = ['-c', self.conffile, self.binary]
>
> + # Check __AA_BASEDIR, which may be set by the Makefile, to see if
> + # we should use a non-default base directory path to find
> + # abstraction files
> + #
> + # NOTE: Individual tests can append another --base path to the
> + # args list and override a base path set here
> + base = os.getenv('__AA_BASEDIR')
> + if base:
> + self.full_args.append('--base=%s' % base)
> +
> if debugging:
> self.full_args.append('-d')
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: not available
URL: <https://lists.ubuntu.com/archives/apparmor/attachments/20170208/7af17e30/attachment.pgp>
More information about the AppArmor
mailing list