From 6daedeb36da31a030ae63c54dc4996cfa6b3e712 Mon Sep 17 00:00:00 2001 From: RomanBapst Date: Mon, 16 Nov 2026 10:47:28 +0300 Subject: [PATCH] test(tecs): write a log file per parameterized closed-loop test Parameterized test names contain '/', so TECS_TEST_LOG_DIR pointed fopen at a missing subdirectory and the TECSControlClosedLoopWeightTest cases wrote nothing. Flatten the name, create the log directory if needed and report a file that cannot be opened. Assisted-by: Claude:claude-opus-5-5 Signed-off-by: RomanBapst --- src/lib/tecs/TECSControlClosedLoopTest.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) 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,"