| 904 | } |
| 905 | |
| 906 | int run_cycle( |
| 907 | const std::string& name, |
| 908 | ProcessManagerPtr process_manager, |
| 909 | DDS::DomainParticipant_var participant, |
| 910 | StatusDataWriter_var status_writer_impl, |
| 911 | AllocatedScenarioDataReader_var allocated_scenario_reader_impl, |
| 912 | ReportDataWriter_var report_writer_impl) |
| 913 | { |
| 914 | OpenDDS::DCPS::DomainParticipantImpl* part_impl = dynamic_cast<OpenDDS::DCPS::DomainParticipantImpl*>(participant.in()); |
| 915 | if (!part_impl) { |
| 916 | std::cerr << "Invalid Participant\n" << std::flush; |
| 917 | return 1; |
| 918 | } |
| 919 | |
| 920 | const NodeId this_node_id = part_impl->get_id(); |
| 921 | |
| 922 | // Wait for Status Publication with Test Controller and Write Status |
| 923 | if (!write_status(name, this_node_id, AVAILABLE, *status_writer_impl)) { |
| 924 | std::cerr << "Write status (available) failed\n" << std::flush; |
| 925 | return 1; |
| 926 | } |
| 927 | |
| 928 | Bench::TestController::AllocatedScenario scenario; |
| 929 | wait_for_full_scenario(name, this_node_id, status_writer_impl, allocated_scenario_reader_impl, scenario); |
| 930 | |
| 931 | // This constructor traps signals, wait until we really need it. |
| 932 | auto spawned_process_manager = std::make_shared<SpawnedProcessManager>(name, this_node_id, process_manager); |
| 933 | |
| 934 | Bench::NodeController::Configs& configs = scenario.configs; |
| 935 | for (CORBA::ULong node = 0; node < configs.length(); ++node) { |
| 936 | if (configs[node].node_id == this_node_id) { |
| 937 | spawned_process_manager->timeout(configs[node].timeout); |
| 938 | const CORBA::ULong allocated_scenario_count = configs[node].spawned_processes.length(); |
| 939 | for (CORBA::ULong config = 0; config < allocated_scenario_count; config++) { |
| 940 | SpawnedProcessId& id = configs[node].spawned_processes[config].spawned_process_id; |
| 941 | const SpawnedProcessId end = id + configs[node].spawned_processes[config].count; |
| 942 | for (; id < end; id++) { |
| 943 | if (spawned_process_manager->add_spawned_process(configs[node].spawned_processes[config])) { |
| 944 | return 1; |
| 945 | } |
| 946 | } |
| 947 | } |
| 948 | break; |
| 949 | } |
| 950 | } |
| 951 | |
| 952 | using Builder::ZERO; |
| 953 | |
| 954 | if (scenario.launch_time < ZERO) { |
| 955 | const auto duration = -1 * get_duration(scenario.launch_time); |
| 956 | if (duration > std::chrono::milliseconds(100)) { |
| 957 | std::this_thread::sleep_until(std::chrono::steady_clock::now() + duration); |
| 958 | } |
| 959 | } else { |
| 960 | const auto now = std::chrono::system_clock::now(); |
| 961 | const auto duration = std::chrono::system_clock::time_point(get_duration(scenario.launch_time)) - now; |
| 962 | if (duration > std::chrono::milliseconds(100)) { |
| 963 | std::this_thread::sleep_until(std::chrono::steady_clock::now() + duration); |
no test coverage detected