[apparmor] [patch] parser tests: abort valgrind test if valgrind is missing
The valgrind test script would happily chug along even if if valgrind was not installed, not doing anything of use. This patch fixes that, and offers up the ability to specify an alternate location for valgrind if it does not exist in the usual /usr/bin location. Signed-off-by: Steve Beattie st...@nxnw.org --- parser/tst/valgrind_simple.py | 13 +++-- 1 file changed, 11 insertions(+), 2 deletions(-) Index: b/parser/tst/valgrind_simple.py === --- a/parser/tst/valgrind_simple.py +++ b/parser/tst/valgrind_simple.py @@ -15,6 +15,7 @@ from argparse import ArgumentParser # requires python 2.7 or newer import os +import sys import tempfile import unittest import testlib @@ -43,7 +44,7 @@ class AAParserValgrindTests(testlib.AATe def _runtest(self, testname, config): parser_args = ['-Q', '-I', config.testdir] failure_rc = [VALGRIND_ERROR_CODE, testlib.TIMEOUT_ERROR_CODE] -command = ['valgrind'] +command = [config.valgrind] command.extend(VALGRIND_ARGS) command.append(config.parser) command.extend(parser_args) @@ -75,8 +76,11 @@ def create_suppressions(): def main(): rc = 0 p = ArgumentParser() -p.add_argument('-p', '--parser', default=testlib.DEFAULT_PARSER, action=store, dest='parser') +p.add_argument('-p', '--parser', default=testlib.DEFAULT_PARSER, action=store, dest='parser', + help=Specify path of apparmor parser to use [default = %(default)s]) p.add_argument('-v', '--verbose', action=store_true, dest=verbose) +p.add_argument('-V', '--valgrind', default='/usr/bin/valgrind', action=store, dest=valgrind, + help=Specify path of valgrind to use [default = %(default)s]) p.add_argument('-s', '--skip-suppressions', action=store_true, dest=skip_suppressions, help=Don't use valgrind suppressions to skip false positives) p.add_argument('--dump-suppressions', action=store_true, dest=dump_suppressions, @@ -89,6 +93,11 @@ def main(): print(VALGRIND_SUPPRESSIONS) return rc +if not os.path.exists(config.valgrind): +print(Unable to find valgrind at '%s', ensure that it is installed % (config.valgrind), + file=sys.stderr) +exit(1) + verbosity = 1 if config.verbose: verbosity = 2 -- Steve Beattie sbeat...@ubuntu.com http://NxNW.org/~steve/ signature.asc Description: Digital signature -- AppArmor mailing list AppArmor@lists.ubuntu.com Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/apparmor
Re: [apparmor] [patch] parser tests: abort valgrind test if valgrind is missing
On Tue, Mar 25, 2014 at 02:14:36PM -0700, Steve Beattie wrote: The valgrind test script would happily chug along even if if valgrind was not installed, not doing anything of use. This patch fixes that, and offers up the ability to specify an alternate location for valgrind if it does not exist in the usual /usr/bin location. Signed-off-by: Steve Beattie st...@nxnw.org Acked-by: Seth Arnold seth.arn...@canonical.com Thanks --- parser/tst/valgrind_simple.py | 13 +++-- 1 file changed, 11 insertions(+), 2 deletions(-) Index: b/parser/tst/valgrind_simple.py === --- a/parser/tst/valgrind_simple.py +++ b/parser/tst/valgrind_simple.py @@ -15,6 +15,7 @@ from argparse import ArgumentParser # requires python 2.7 or newer import os +import sys import tempfile import unittest import testlib @@ -43,7 +44,7 @@ class AAParserValgrindTests(testlib.AATe def _runtest(self, testname, config): parser_args = ['-Q', '-I', config.testdir] failure_rc = [VALGRIND_ERROR_CODE, testlib.TIMEOUT_ERROR_CODE] -command = ['valgrind'] +command = [config.valgrind] command.extend(VALGRIND_ARGS) command.append(config.parser) command.extend(parser_args) @@ -75,8 +76,11 @@ def create_suppressions(): def main(): rc = 0 p = ArgumentParser() -p.add_argument('-p', '--parser', default=testlib.DEFAULT_PARSER, action=store, dest='parser') +p.add_argument('-p', '--parser', default=testlib.DEFAULT_PARSER, action=store, dest='parser', + help=Specify path of apparmor parser to use [default = %(default)s]) p.add_argument('-v', '--verbose', action=store_true, dest=verbose) +p.add_argument('-V', '--valgrind', default='/usr/bin/valgrind', action=store, dest=valgrind, + help=Specify path of valgrind to use [default = %(default)s]) p.add_argument('-s', '--skip-suppressions', action=store_true, dest=skip_suppressions, help=Don't use valgrind suppressions to skip false positives) p.add_argument('--dump-suppressions', action=store_true, dest=dump_suppressions, @@ -89,6 +93,11 @@ def main(): print(VALGRIND_SUPPRESSIONS) return rc +if not os.path.exists(config.valgrind): +print(Unable to find valgrind at '%s', ensure that it is installed % (config.valgrind), + file=sys.stderr) +exit(1) + verbosity = 1 if config.verbose: verbosity = 2 signature.asc Description: Digital signature -- AppArmor mailing list AppArmor@lists.ubuntu.com Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/apparmor