| 52 | // Just stand up MPI before running all tests; teardown after. |
| 53 | using namespace unit_test::utilities; |
| 54 | int main(int argc, char* argv[]) |
| 55 | { |
| 56 | lbann::construct_all_options(); |
| 57 | |
| 58 | // Set up the communication domain |
| 59 | auto world_comm = lbann::initialize(argc, argv); |
| 60 | lbann::init_random(13); |
| 61 | expert::register_world_comm(*world_comm); |
| 62 | |
| 63 | // Initialize Catch2 |
| 64 | Catch::Session session; |
| 65 | |
| 66 | int hang_rank = -1; |
| 67 | auto cli = |
| 68 | session.cli() | Opt(hang_rank, "Rank to hang")["--hang-rank"]( |
| 69 | "Hang this rank to attach a debugger."); |
| 70 | session.cli(cli); |
| 71 | |
| 72 | // Parse the command line |
| 73 | int return_code = session.applyCommandLine(argc, argv); |
| 74 | if (return_code != 0) // Indicates a command line error |
| 75 | return return_code; |
| 76 | |
| 77 | // Handle a debugger hang. |
| 78 | // |
| 79 | // Note (trb 02/10/2022): We should NOT use the default Catch2 flag |
| 80 | // for this as that will hang every rank. I personally find it more |
| 81 | // effective when using GDB in a parallel setting to just attach to |
| 82 | // one rank. It's rare that I need more than one rank to run in GDB, |
| 83 | // but this block does not preclude that. If that's the intention, |
| 84 | // only the hang_rank needs to release the spin lock. |
| 85 | if (world_comm->get_rank_in_world() == hang_rank) { |
| 86 | #ifdef LBANN_HAS_UNISTD_H |
| 87 | char hostname[1024]; |
| 88 | gethostname(hostname, 1024); |
| 89 | std::cerr << "[hang]: (hostname: " << hostname << ", pid: " << getpid() |
| 90 | << ")" << std::endl; |
| 91 | #endif |
| 92 | int volatile wait = 1; |
| 93 | while (wait) { |
| 94 | } |
| 95 | } |
| 96 | // This should hang the other ranks |
| 97 | world_comm->global_barrier(); |
| 98 | |
| 99 | // Manipulate output file if needed. |
| 100 | auto& config_data = session.configData(); |
| 101 | #ifdef LBANN_USE_CATCH2_V3 |
| 102 | auto& output_file = config_data.defaultOutputFilename; |
| 103 | #else |
| 104 | auto& output_file = config_data.outputFilename; |
| 105 | #endif |
| 106 | if (output_file.size() > 0) { |
| 107 | lbann::utils::SystemInfo sys_info; |
| 108 | output_file = replace_escapes(output_file, sys_info); |
| 109 | } |
| 110 | |
| 111 | // Run the catch tests, outputting to the given file. |
nothing calls this directly
no test coverage detected