27
27
28
28
29
29
class Input :
30
- filename : str
30
+ filenames : list [ str ]
31
31
write_individual_files : bool
32
32
write_dir : str
33
33
verbose : bool
@@ -121,7 +121,8 @@ def parse_args() -> Input:
121
121
),
122
122
)
123
123
p .add_argument (
124
- "filename" ,
124
+ "filenames" ,
125
+ nargs = "+" ,
125
126
help = "The path to the suspend logs or the stress test submission .tar" ,
126
127
)
127
128
p .add_argument (
@@ -143,7 +144,7 @@ def parse_args() -> Input:
143
144
"Where to write the individual logs. "
144
145
"If not specified and the -w flag is true, "
145
146
"it will create a new local directory called "
146
- "{your original file name}-split"
147
+ "{your original file name}-split. "
147
148
),
148
149
)
149
150
p .add_argument (
@@ -190,7 +191,7 @@ def parse_args() -> Input:
190
191
191
192
out = p .parse_args ()
192
193
# have to wait until out.filename is populated
193
- out .write_dir = out .write_dir or f"{ out .filename } -split"
194
+ # out.write_dir = out.write_dir or f"{out.filename}-split"
194
195
return cast (Input , out )
195
196
196
197
@@ -262,6 +263,7 @@ def open_log_file(filename: str, num_boots: int, num_suspends: int) -> tuple[
262
263
"test_output/com.canonical.certification__stress-tests_"
263
264
+ f"suspend_cycles_{ suspend_i } _reboot{ boot_i } "
264
265
)
266
+
265
267
try :
266
268
extracted = tarball .extractfile (individual_file_name )
267
269
assert extracted , f"Failed to extract { individual_file_name } "
@@ -418,50 +420,27 @@ def write_suspend_output(
418
420
f .writelines (lines )
419
421
420
422
421
- def main ():
422
- args = parse_args ()
423
- C .no_color = args .no_color
424
-
425
- if args .no_transform :
426
- # idk why tox doesn't like this, this is super common
427
- transform_err_msg : Callable [[str ], str ] = lambda msg : msg .strip ()
428
- else :
429
- transform_err_msg = default_err_msg_transform
430
-
431
- print (
432
- C .medium ("[ WARN ]" ),
433
- "The summary file might not match" ,
434
- "the number of failures found by this script." ,
435
- )
436
- print (
437
- C .medium ("[ WARN ]" ),
438
- "Please double check since the original test case" ,
439
- "may consider some failures to be not worth reporting" ,
440
- )
441
-
423
+ def print_summary_for_1_submission (
424
+ args : Input , filename : str , transform_err_msg : Callable [[str ], str ]
425
+ ) -> None :
442
426
expected_num_results = args .num_boots * args .num_suspends # noqa: N806
443
-
444
- print (
445
- C .low ("[ INFO ]" ),
446
- f"Expecting ({ args .num_boots } boots * { args .num_suspends } suspends) = "
447
- f"{ expected_num_results } results" ,
448
- )
427
+ write_dir = f"{ args .write_dir } /{ filename .replace ("/" , '-' )} -split"
449
428
450
429
if args .write_individual_files :
451
430
print (
452
431
C .low ("[ INFO ]" ),
453
- f'Individual results will be in "{ args . write_dir } "' ,
432
+ f'Individual results will be in "{ write_dir } "' ,
454
433
)
455
- if not os .path .exists (args .write_dir ):
456
- os .mkdir (args .write_dir )
457
-
434
+ if not os .path .exists (write_dir ):
435
+ os .makedirs (write_dir , exist_ok = True )
458
436
log_files , summary_file , missing_runs = open_log_file (
459
- args . filename , args .num_boots , args .num_suspends
437
+ filename , args .num_boots , args .num_suspends
460
438
)
461
439
462
440
if not args .no_summary :
463
441
if summary_file :
464
- print (f"\n { C .gray (' Begin Summary File ' .center (80 , '-' ))} \n " )
442
+ print (C .gray (" Begin Summary File " .center (80 , "-" )))
443
+ print (C .gray (f"In { filename } \n " ))
465
444
466
445
for line in summary_file .readlines ():
467
446
clean_line = line .strip ()
@@ -478,16 +457,16 @@ def main():
478
457
479
458
# failed_runs[fail_type][boot_i][suspend_i] = set of messages
480
459
failed_runs : RunsGroupedByIndex = {
481
- k : defaultdict (lambda : defaultdict (set )) for k in FAIL_TYPES
460
+ ft : defaultdict (lambda : defaultdict (set )) for ft in FAIL_TYPES
482
461
}
483
462
# actual_suspend_counts[boot_i] = num files actually found
484
463
actual_suspend_counts : dict [int , int ] = {}
485
464
486
465
for boot_i in log_files :
487
466
actual_suspend_counts [boot_i ] = len (log_files [boot_i ])
488
467
for suspend_i in log_files [boot_i ]:
489
- log_file_lines = log_files [boot_i ][suspend_i ]. readlines ()
490
- log_files [ boot_i ][ suspend_i ]. close ()
468
+ with log_files [boot_i ][suspend_i ] as f :
469
+ log_file_lines = f . readlines ()
491
470
492
471
curr_meta : Meta | None = None
493
472
for i , line in enumerate (log_file_lines ):
@@ -531,7 +510,7 @@ def main():
531
510
end = "\r " ,
532
511
)
533
512
write_suspend_output (
534
- args . write_dir ,
513
+ write_dir ,
535
514
boot_i ,
536
515
suspend_i ,
537
516
curr_meta ,
@@ -546,7 +525,7 @@ def main():
546
525
print (
547
526
C .ok ("[ OK ]" ),
548
527
f"Found all { expected_num_results } " ,
549
- "expected log files!" ,
528
+ f "expected log files in { filename } !" ,
550
529
)
551
530
if n_failed_runs == 0 :
552
531
print (
@@ -565,12 +544,46 @@ def main():
565
544
for boot_i , suspend_indicies in missing_runs .items ():
566
545
print (f"- Reboot { boot_i } , suspend { str (suspend_indicies )} " )
567
546
568
- print (f"\n { C .gray (' Begin Parsed Output ' .center (80 , '-' ))} \n " )
547
+ print (f"\n { C .gray (' Begin Parsed Output ' .center (80 , '-' ))} " )
548
+ print (C .gray (f"In { filename } \n " ))
569
549
570
550
print_by_err (
571
551
group_by_err (failed_runs ), actual_suspend_counts , args .num_suspends
572
552
)
573
553
574
554
555
+ def main ():
556
+ args = parse_args ()
557
+ C .no_color = args .no_color
558
+
559
+ expected_num_results = args .num_boots * args .num_suspends # noqa: N806
560
+ print (
561
+ C .low ("[ INFO ]" ),
562
+ f"Expecting ({ args .num_boots } boots * { args .num_suspends } suspends) = "
563
+ f"{ expected_num_results } results" ,
564
+ )
565
+
566
+ if args .no_transform :
567
+ # idk why tox doesn't like this, this is super common
568
+ transform_err_msg : Callable [[str ], str ] = lambda msg : msg .strip ()
569
+ else :
570
+ transform_err_msg = default_err_msg_transform
571
+
572
+ print (
573
+ C .medium ("[ WARN ]" ),
574
+ "The summary file might not match" ,
575
+ "the number of failures found by this script." ,
576
+ )
577
+ print (
578
+ C .medium ("[ WARN ]" ),
579
+ "Please double check since the original test case" ,
580
+ "may consider some failures to be not worth reporting" ,
581
+ )
582
+ print ()
583
+
584
+ for filename in args .filenames :
585
+ print_summary_for_1_submission (args , filename , transform_err_msg )
586
+
587
+
575
588
if __name__ == "__main__" :
576
589
main ()
0 commit comments