diff --git a/src/lib/tecs/TECSControlClosedLoopTest.cpp b/src/lib/tecs/TECSControlClosedLoopTest.cpp index e1bcfeca85d..117d207c10d 100644 --- a/src/lib/tecs/TECSControlClosedLoopTest.cpp +++ b/src/lib/tecs/TECSControlClosedLoopTest.cpp @@ -57,6 +57,8 @@ #include "TECS.hpp" #include #include +#include +#include #include #include @@ -311,9 +313,19 @@ protected: if (log_dir) { const auto *test_info = ::testing::UnitTest::GetInstance()->current_test_info(); - std::string path = std::string(log_dir) + "/" + test_info->name() + ".csv"; + + // Parameterized tests are named "Test/Param": flatten to one file name + std::string name = test_info->name(); + std::replace(name.begin(), name.end(), '/', '_'); + + mkdir(log_dir, 0755); // fails harmlessly if it exists + std::string path = std::string(log_dir) + "/" + name + ".csv"; _output_csv_file = std::fopen(path.c_str(), "w"); + if (!_output_csv_file) { + std::fprintf(stderr, "TECS_TEST_LOG_DIR: cannot write %s\n", path.c_str()); + } + if (_output_csv_file) { std::fprintf(_output_csv_file, "t,V,h,V_sp,alt_sp,pitch_cmd,throttle,"