diff options
author | Gabe Black <gabeblack@google.com> | 2018-06-15 15:52:23 -0700 |
---|---|---|
committer | Gabe Black <gabeblack@google.com> | 2018-08-22 00:59:09 +0000 |
commit | d3abc7e7243406a6b9ac5632939a97882d75dcdf (patch) | |
tree | 66a62fc0176db0021d05cff2e3300b88e56ec578 /src/systemc | |
parent | 84c1b3b3ed6d5f03e23efb2efa3fd04b3fab4b35 (diff) | |
download | gem5-d3abc7e7243406a6b9ac5632939a97882d75dcdf.tar.xz |
systemc: Add a filter-file option.
The --filter option is very useful, but can get to be long and complex
and a bit too cumbersome to use from the command line. This change
adds a --filter-file option which is mutually exclusive with --filter
and which reads the filter expression from a file instead of accepting
it on the command line.
Change-Id: I381c92ddf0d9fe62acd20432fa4868e2121405b8
Reviewed-on: https://gem5-review.googlesource.com/11257
Reviewed-by: Gabe Black <gabeblack@google.com>
Maintainer: Gabe Black <gabeblack@google.com>
Diffstat (limited to 'src/systemc')
-rwxr-xr-x | src/systemc/tests/verify.py | 35 |
1 files changed, 23 insertions, 12 deletions
diff --git a/src/systemc/tests/verify.py b/src/systemc/tests/verify.py index d46e3cc82..9cf344316 100755 --- a/src/systemc/tests/verify.py +++ b/src/systemc/tests/verify.py @@ -158,9 +158,13 @@ parser.add_argument('--flavor', choices=['debug', 'opt', 'fast'], parser.add_argument('--list', action='store_true', help='List the available tests') -parser.add_argument('--filter', default='True', - help='Python expression which filters tests based on ' - 'their properties') +filter_opts = parser.add_mutually_exclusive_group() +filter_opts.add_argument('--filter', default='True', + help='Python expression which filters tests based ' + 'on their properties') +filter_opts.add_argument('--filter-file', default=None, + type=argparse.FileType('r'), + help='Same as --filter, but read from a file') def collect_phases(args): phase_groups = [list(g) for k, g in @@ -196,20 +200,27 @@ if main_args.update_json: with open(json_path) as f: test_data = json.load(f) + if main_args.filter_file: + f = main_args.filter_file + filt = compile(f.read(), f.name, 'eval') + else: + filt = compile(main_args.filter, '<string>', 'eval') + + filtered_tests = { + target: props for (target, props) in + test_data.iteritems() if eval(filt, dict(props)) + } + if main_args.list: - for target, props in test_data.iteritems(): - if not eval(main_args.filter, dict(props)): - continue + for target, props in sorted(filtered_tests.iteritems()): print('%s.%s' % (target, main_args.flavor)) for key, val in props.iteritems(): print(' %s: %s' % (key, val)) else: - tests_to_run = [] - for target, props in test_data.iteritems(): - if not eval(main_args.filter, props): - continue - tests_to_run.append(Test(target, main_args.flavor, - main_args.build_dir, props)) + tests_to_run = list([ + Test(target, main_args.flavor, main_args.build_dir, props) for + target, props in sorted(filtered_tests.iteritems()) + ]) for phase in phases: phase.run(tests_to_run) |