| 66 | #include "common/utils.h" |
| 67 | |
| 68 | nlohmann::ordered_json run_singleinstance_tests_offline(nlohmann::ordered_json config, std::string input_path1, std::string output_path1) |
| 69 | { |
| 70 | nlohmann::ordered_json report; |
| 71 | |
| 72 | // std::string excutable = config["config"]["command"]; |
| 73 | // bool catch_logs = config["config"]["catch_logs"]; |
| 74 | |
| 75 | for (auto pipeline_test : config["pipeline_tests"].items()) |
| 76 | { |
| 77 | std::string name = pipeline_test.key(); |
| 78 | std::string pipeline = pipeline_test.value()["pipeline"]; |
| 79 | std::string input_file = pipeline_test.value()["input_file"]; |
| 80 | std::string input_level = pipeline_test.value()["input_level"]; |
| 81 | std::string parameters = pipeline_test.value()["parameters"]; |
| 82 | |
| 83 | std::string input_path = input_path1 + "/" + input_file; |
| 84 | std::string output_path = output_path1 + "/" + name; |
| 85 | |
| 86 | if (!std::filesystem::exists(output_path)) |
| 87 | std::filesystem::create_directories(output_path); |
| 88 | |
| 89 | logger->info("Running %s", name.c_str()); |
| 90 | // logger->trace("Command %s", command.c_str()); |
| 91 | |
| 92 | auto test_start = std::chrono::system_clock::now(); |
| 93 | // int return_value = system(command.c_str()); |
| 94 | |
| 95 | { |
| 96 | std::optional<satdump::Pipeline> pipeliner = satdump::getPipelineFromName(pipeline); |
| 97 | |
| 98 | std::vector<std::string> split_str = splitString(parameters, ' '); |
| 99 | std::vector<char *> v; |
| 100 | for (std::string str : split_str) |
| 101 | { |
| 102 | char *arg = new char[str.size() + 1]; |
| 103 | copy(str.begin(), str.end(), arg); |
| 104 | arg[str.size()] = '\0'; |
| 105 | v.push_back(arg); |
| 106 | } |
| 107 | |
| 108 | auto params = parse_common_flags(v.size(), &v[0]); |
| 109 | |
| 110 | for (size_t i = 0; i < v.size(); i++) |
| 111 | delete[] v[i]; |
| 112 | |
| 113 | pipeliner->run(input_path, output_path, params, input_level); |
| 114 | } |
| 115 | |
| 116 | auto test_time = (std::chrono::system_clock::now() - test_start); |
| 117 | |
| 118 | // if (return_value == 256) |
| 119 | // return_value = 0; |
| 120 | |
| 121 | logger->info("Done! Time was %f", test_time.count() / 1e9); |
| 122 | |
| 123 | // report[name]["command"] = command; |
| 124 | report[name]["time"] = test_time.count() / 1e9; |
| 125 | // report[name]["return"] = return_value; |
no test coverage detected