Skip to content

Commit e6768c4

Browse files
davidlyclaude
andcommitted
test86: tracing off by default, add -t to opt in
Previously every invocation unconditionally enabled tracing to the hardcoded "test86.log", which is both pure overhead when nobody's reading it and actively broken under runall.sh -- all 32 parallel workers raced to write the same file. -t now opts into tracing for one-off single-file debugging; the parallel suite runtime dropped from 5.9s to 2.0s with it off by default. All 327 tests still pass. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
1 parent 9739404 commit e6768c4

1 file changed

Lines changed: 28 additions & 8 deletions

File tree

‎test86/test86.cxx‎

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -445,19 +445,39 @@ void run_tests( const char * path )
445445

446446
int main( int argc, char * argv[] )
447447
{
448-
tracer.Enable( true, "test86.log", true );
449-
tracer.SetQuiet( true );
450-
cpu.trace_instructions( true );
448+
// Tracing is off by default: every parallel worker in runall.sh would otherwise
449+
// enable it and race to write the same hardcoded "test86.log", which is both wasted
450+
// I/O (nobody's reading it during a bulk run) and produces a corrupted/interleaved
451+
// log anyway. Pass -t for one-off single-file debugging.
452+
453+
bool trace = false;
454+
const char * path = 0;
455+
for ( int i = 1; i < argc; i++ )
456+
{
457+
if ( !strcmp( argv[ i ], "-t" ) )
458+
trace = true;
459+
else if ( 0 == path )
460+
path = argv[ i ];
461+
else
462+
path = 0; // too many non-flag arguments; fall through to the usage error below
463+
}
464+
465+
if ( 0 == path )
466+
fail( "usage: %s [-t] filename.json\n -t enable instruction tracing to test86.log (single-file runs only --\n don't use this under runall.sh, every parallel worker would race to\n write the same log)\n", argv[ 0 ] );
451467

452-
if ( 2 != argc )
453-
fail( "usage: %s filename.json\n", argv[0] );
468+
if ( trace )
469+
{
470+
tracer.Enable( true, "test86.log", true );
471+
tracer.SetQuiet( true );
472+
cpu.trace_instructions( true );
473+
}
454474

455-
run_tests( argv[ 1 ] );
475+
run_tests( path );
456476

457477
if ( 0 == tests_failed )
458-
printf( "test86 completed %llu tests in %s with great success\n", tests_run, argv[ 1 ] );
478+
printf( "test86 completed %llu tests in %s with great success\n", tests_run, path );
459479
else
460-
printf( "test86 completed %llu tests with %llu failures in %s\n", tests_run, tests_failed, argv[ 1 ] );
480+
printf( "test86 completed %llu tests with %llu failures in %s\n", tests_run, tests_failed, path );
461481

462482
return ( 0 == tests_failed ) ? 0 : 1; // so callers can trust the exit code instead of having to parse stdout
463483
} //main

0 commit comments

Comments
 (0)