| 527 | }; |
| 528 | |
| 529 | int main(int argc, const char ** argv) |
| 530 | { |
| 531 | |
| 532 | #if !defined(NDEBUG) && defined(_WIN32) |
| 533 | // Disable the 'assert' dialog box in debug mode. |
| 534 | _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_DEBUG); |
| 535 | #endif |
| 536 | |
| 537 | bool printHelp = false; |
| 538 | bool useMetalRenderer = false; |
| 539 | bool verbose = false; |
| 540 | bool stopOnFirstError = false; |
| 541 | |
| 542 | // Note that empty strings mean to run all the unit tests. |
| 543 | std::string filter, utestGroupAllowed, utestNameAllowed; |
| 544 | |
| 545 | ArgParse ap; |
| 546 | ap.options("\nCommand line arguments:\n", |
| 547 | "--help", &printHelp, "Print help message", |
| 548 | "--metal", &useMetalRenderer, "Run the GPU unit test with Metal", |
| 549 | "-v", &verbose, "Output the GPU shader program", |
| 550 | "--stop_on_error", &stopOnFirstError, "Stop on the first error", |
| 551 | "--run_only %s", &filter, "Run only some unit tests\n" |
| 552 | "\tex: --run_only ExponentOp/forward i.e. run only \"ExponentOp/forward\"\n" |
| 553 | "\tex: --run_only ExponentOp i.e. run \"ExponentOp/*\"\n" |
| 554 | "\tex: --run_only /forward i.e. run \"*/forward\"\n", |
| 555 | nullptr); |
| 556 | |
| 557 | if (ap.parse(argc, argv) < 0) |
| 558 | { |
| 559 | std::cerr << ap.geterror() << std::endl; |
| 560 | ap.usage(); |
| 561 | return 1; |
| 562 | } |
| 563 | |
| 564 | if (printHelp) |
| 565 | { |
| 566 | ap.usage(); |
| 567 | return 1; |
| 568 | } |
| 569 | |
| 570 | if (!filter.empty()) |
| 571 | { |
| 572 | const std::vector<std::string> results = StringUtils::Split(filter, '/'); |
| 573 | if (!results.empty()) |
| 574 | { |
| 575 | utestGroupAllowed = StringUtils::Lower(StringUtils::Trim(results[0])); |
| 576 | if (results.size() >= 2) |
| 577 | { |
| 578 | utestNameAllowed = StringUtils::Lower(StringUtils::Trim(results[1])); |
| 579 | |
| 580 | if (results.size() >= 3) |
| 581 | { |
| 582 | std::cerr << "Invalid value for the argument '--run_only'." << std::endl; |
| 583 | ap.usage(); |
| 584 | return 1; |
| 585 | } |
| 586 | } |
nothing calls this directly
no test coverage detected