The main function. Return: int: The process return code.
()
| 456 | |
| 457 | |
| 458 | def main() -> int: |
| 459 | ''' |
| 460 | The main function. |
| 461 | |
| 462 | Return: |
| 463 | int: The process return code. |
| 464 | ''' |
| 465 | # Parse command lines |
| 466 | args = parse_command_line() |
| 467 | |
| 468 | test_set_count = 0 |
| 469 | worst_result = ResultStatus.NOT_RUN |
| 470 | |
| 471 | for quality in args.test_qual: |
| 472 | for test_set_name in args.test_sets: |
| 473 | for encoder_name in args.encoders: |
| 474 | (encoder, name, out_dir, reference_name) = \ |
| 475 | get_encoder_params( |
| 476 | encoder_name, args.reference, test_set_name) |
| 477 | |
| 478 | test_dir = f'Test/Images/{test_set_name}' |
| 479 | test_csv = f'{out_dir}/astc_{name}_{quality}_results.csv' |
| 480 | |
| 481 | reference = None |
| 482 | if reference_name: |
| 483 | ref_csv = f'astc_{reference_name}_{quality}_results.csv' |
| 484 | ref_csv = f'{test_dir}/{ref_csv}' |
| 485 | reference = ResultSet(test_set_name) |
| 486 | reference.load_from_file(Path(ref_csv)) |
| 487 | |
| 488 | test_set_count += 1 |
| 489 | test_set = TestSet( |
| 490 | test_set_name, Path(test_dir), |
| 491 | args.profiles, args.formats, args.test_image) |
| 492 | |
| 493 | result_set = run_test_set( |
| 494 | encoder, reference, test_set, quality, |
| 495 | args.block_sizes, args.repeats, |
| 496 | args.keep_output, args.threads) |
| 497 | |
| 498 | result_set.save_to_file(Path(test_csv)) |
| 499 | |
| 500 | if reference_name: |
| 501 | summary = result_set.get_results_summary() |
| 502 | this_result = summary.get_worst_result() |
| 503 | worst_result = max(this_result, worst_result) |
| 504 | print(summary) |
| 505 | |
| 506 | if (test_set_count > 1) and (worst_result != ResultStatus.NOT_RUN): |
| 507 | print(f'OVERALL STATUS: {worst_result.name}') |
| 508 | |
| 509 | if worst_result == ResultStatus.FAIL: |
| 510 | return 1 |
| 511 | |
| 512 | return 0 |
| 513 | |
| 514 | |
| 515 | if __name__ == '__main__': |
no test coverage detected