scripts: test.py/bench.py: Added i field to test/bench marks

For consistent ordering in later scripts. The previous
-F=min(enumerate()) trick mostly worked, but would get messed up by
running things in parallel (-j).

I've already confused myself a couple times looking at script output,
which is never a good sign.
This commit is contained in:
Christopher Haster
2026-02-10 15:06:54 -06:00
parent 1a98d8089b
commit 34026948ef
3 changed files with 48 additions and 33 deletions
+17 -10
View File
@@ -1134,7 +1134,8 @@ class TestFailure(Exception):
self.stdout = stdout
self.assert_ = assert_
def run_stage(name, runner, test_ids, stdout_, trace_, output_, **args):
def run_stage(offset, name, runner, test_ids,
stdout_, trace_, output_, **args):
# get expected suite/case/perm counts
(case_suites,
expected_suite_perms,
@@ -1228,6 +1229,9 @@ def run_stage(name, runner, test_ids, stdout_, trace_, output_, **args):
defines = find_defines(
runner, m.group('id'), **args)
output_.writerow({
'i': offset
+ locals.start
+ locals.seen_perms*locals.step,
'suite': suite,
'case': case,
**defines,
@@ -1265,14 +1269,16 @@ def run_stage(name, runner, test_ids, stdout_, trace_, output_, **args):
nonlocal killed
nonlocal locals
start = start or 0
step = step or 1
while start < total_perms:
locals.start = start or 0
locals.step = step or 1
while locals.start < total_perms:
runner_ = find_runner(runner, main=main, **args)
if args.get('isolate') or args.get('valgrind'):
runner_.append('--step=%s,%s,%s' % (start, start+step, step))
elif start != 0 or step != 1:
runner_.append('--step=%s,,%s' % (start, step))
runner_.append('--step=%s,%s,%s' % (
locals.start, locals.start+locals.step, locals.step))
elif locals.start != 0 or locals.step != 1:
runner_.append('--step=%s,,%s' % (
locals.start, locals.step))
runner_.extend(test_ids)
@@ -1281,7 +1287,7 @@ def run_stage(name, runner, test_ids, stdout_, trace_, output_, **args):
locals.seen_perms = 0
run_runner(runner_)
assert locals.seen_perms > 0
start += locals.seen_perms*step
locals.start += locals.seen_perms*locals.step
except TestFailure as failure:
# keep track of failures
@@ -1310,7 +1316,7 @@ def run_stage(name, runner, test_ids, stdout_, trace_, output_, **args):
if args.get('keep_going') and not killed:
# resume after failed test
assert locals.seen_perms > 0
start += locals.seen_perms*step
locals.start += locals.seen_perms*locals.step
continue
else:
# stop other tests
@@ -1428,7 +1434,7 @@ def run(runner, test_ids=[], **args):
output = None
if args.get('output'):
output = TestOutput(args['output'],
['suite', 'case'],
['i', 'suite', 'case'],
# defines go here
['test_passed', 'test_runtime'])
@@ -1449,6 +1455,7 @@ def run(runner, test_ids=[], **args):
powerlosses_,
failures_,
killed) = run_stage(
expected,
by or 'tests',
runner,
[by] if by is not None else [],