From: Jeff Lucovsky Date: Tue, 20 Oct 2020 12:25:12 +0000 (-0400) Subject: tests: Add exact match argument X-Git-Tag: suricata-6.0.4~225 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=579f52eb31b4eb03ac55fbed820510720ef481f7;p=thirdparty%2Fsuricata-verify.git tests: Add exact match argument This commit extends the CLI with a flag to treat the "pattern" argument(s) as an exact match instead of a substring match. --- diff --git a/run.py b/run.py index bf047c1ac..45d836c47 100755 --- a/run.py +++ b/run.py @@ -836,6 +836,8 @@ def main(): help="Exit on test failure") parser.add_argument("--testdir", action="store", help="Runs tests from custom directory") + parser.add_argument("--exact", dest="exact", action="store_true", + help="Use supplied name to make an exact match") parser.add_argument("--skip-tests", nargs="?", default=None, help="Skip tests with a given pattern") parser.add_argument("--outdir", action="store", @@ -881,11 +883,16 @@ def main(): continue if dirpath == tdir: continue + basename = os.path.basename(dirpath) if args.skip_tests: skip_tests_opt = False patterns = args.skip_tests.split(",") for pattern in patterns: - if os.path.basename(dirpath).find(pattern) > -1: + if args.exact: + if pattern == basename: + skip_tests_opt = True + break + elif basename.find(pattern) > -1: skip_tests_opt = True break if skip_tests_opt: @@ -902,7 +909,10 @@ def main(): tests.append(dirpath) else: for pattern in args.patterns: - if os.path.basename(dirpath).find(pattern) > -1: + if args.exact: + if pattern == basename: + tests.append(dirpath) + elif basename.find(pattern) > -1: tests.append(dirpath) # Sort alphabetically.