runners: Added -Q/--query-define and friends

The fact that we don't include implicit defines in bench/test output
means we need to query the runner for these surprisingly often. So it'd
be nice to have an easier API than sedding the list output.

Some examples:

  $ ./scripts/test.py -QBLOCK_SIZE
  4096
  32768

  $ ./scripts/test.py --query-implicit-define=BLOCK_SIZE
  4096

  $ ./scripts/test.py --query-permutation-define=BLOCK_SIZE
  32768

  $ ./scripts/test.py -QBLOCK_SIZZLE
  (errors)

Unlike --list-*defines, --query-*defines:

- Separates by newline

- Errors if define is not found

Other than that, --query-*defines uses more-or-less the same code
internally.
This commit is contained in:
Christopher Haster
2026-02-12 18:16:47 -06:00
parent fb8d5a83aa
commit cb91b6b2a6
5 changed files with 465 additions and 58 deletions
+20 -1
View File
@@ -1096,6 +1096,13 @@ def list_(runner, bench_ids=[], **args):
cmd.append('--list-suite-probes')
if args.get('list_case_probes'):
cmd.append('--list-case-probes')
if args.get('query_define'): cmd.append('-Q%s' % args['query_define'])
if args.get('query_permutation_define'):
cmd.append('--query-permutation-define=%s'
% args['query_permutation_define'])
if args.get('query_implicit_define'):
cmd.append('--query-implicit-define=%s'
% args['query_implicit_define'])
if args.get('verbose'):
print(' '.join(shlex.quote(c) for c in cmd))
@@ -1689,7 +1696,10 @@ def main(**args):
or args.get('list_implicit_defines')
or args.get('list_probes')
or args.get('list_suite_probes')
or args.get('list_case_probes')):
or args.get('list_case_probes')
or args.get('query_define')
or args.get('query_permutation_define')
or args.get('query_implicit_define')):
return list_(**args)
else:
return run(**args)
@@ -1775,6 +1785,15 @@ if __name__ == "__main__":
'--list-case-probes',
action='store_true',
help="List estimated probes for each bench case.")
bench_parser.add_argument(
'-Q', '--query-define',
help="Query a bench define.")
bench_parser.add_argument(
'--query-permutation-define',
help="Query a permutation bench define.")
bench_parser.add_argument(
'--query-implicit-define',
help="Query an implicit bench define.")
bench_parser.add_argument(
'-D', '--define',
action='append',
+20 -1
View File
@@ -1084,6 +1084,13 @@ def list_(runner, test_ids=[], **args):
if args.get('list_implicit_defines'):
cmd.append('--list-implicit-defines')
if args.get('list_powerlosses'): cmd.append('--list-powerlosses')
if args.get('query_define'): cmd.append('-Q%s' % args['query_define'])
if args.get('query_permutation_define'):
cmd.append('--query-permutation-define=%s'
% args['query_permutation_define'])
if args.get('query_implicit_define'):
cmd.append('--query-implicit-define=%s'
% args['query_implicit_define'])
if args.get('verbose'):
print(' '.join(shlex.quote(c) for c in cmd))
@@ -1654,7 +1661,10 @@ def main(**args):
or args.get('list_defines')
or args.get('list_permutation_defines')
or args.get('list_implicit_defines')
or args.get('list_powerlosses')):
or args.get('list_powerlosses')
or args.get('query_define')
or args.get('query_permutation_define')
or args.get('query_implicit_define')):
return list_(**args)
else:
return run(**args)
@@ -1732,6 +1742,15 @@ if __name__ == "__main__":
'--list-powerlosses',
action='store_true',
help="List the available powerloss scenarios.")
test_parser.add_argument(
'-Q', '--query-define',
help="Query a test define.")
test_parser.add_argument(
'--query-permutation-define',
help="Query a permutation test define.")
test_parser.add_argument(
'--query-implicit-define',
help="Query an implicit test define.")
test_parser.add_argument(
'-D', '--define',
action='append',