From f56cc4939a815b36cb7544642cc4de2f82edcfef Mon Sep 17 00:00:00 2001 From: Andrey Date: Thu, 21 Mar 2024 10:16:03 -0400 Subject: [PATCH 1/2] dedicated output_logicdata folder --- unit_tests/.gitignore | 1 - unit_tests/output_logicdata/.gitignore | 1 + unit_tests/test-framework/engine_test_helper.cpp | 5 ++++- 3 files changed, 5 insertions(+), 2 deletions(-) create mode 100644 unit_tests/output_logicdata/.gitignore diff --git a/unit_tests/.gitignore b/unit_tests/.gitignore index aee357234fa..60bd15a2c8c 100644 --- a/unit_tests/.gitignore +++ b/unit_tests/.gitignore @@ -2,4 +2,3 @@ build*/ gcov_working_area triggers -unittest*.logicdata diff --git a/unit_tests/output_logicdata/.gitignore b/unit_tests/output_logicdata/.gitignore new file mode 100644 index 00000000000..0e32eaea652 --- /dev/null +++ b/unit_tests/output_logicdata/.gitignore @@ -0,0 +1 @@ +unittest*.logicdata diff --git a/unit_tests/test-framework/engine_test_helper.cpp b/unit_tests/test-framework/engine_test_helper.cpp index 0bcb24fea70..5f465c0d9ea 100644 --- a/unit_tests/test-framework/engine_test_helper.cpp +++ b/unit_tests/test-framework/engine_test_helper.cpp @@ -133,12 +133,15 @@ EngineTestHelper::EngineTestHelper(engine_type_e engineType, configuration_callb rememberCurrentConfiguration(); } +#define LOGICDATA_OUTPUT "output_logicdata" + EngineTestHelper::~EngineTestHelper() { // Write history to file extern bool hasInitGtest; if (hasInitGtest) { + mkdir(LOGICDATA_OUTPUT, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH); std::stringstream filePath; - filePath << "unittest_" << ::testing::UnitTest::GetInstance()->current_test_info()->name() << ".logicdata"; + filePath << LOGICDATA_OUTPUT << "/unittest_" << ::testing::UnitTest::GetInstance()->current_test_info()->name() << ".logicdata"; writeEvents(filePath.str().c_str()); } From 3cb207bb1260405a3a39eff6a032a2121314c56f Mon Sep 17 00:00:00 2001 From: Andrey Date: Thu, 21 Mar 2024 12:21:05 -0400 Subject: [PATCH 2/2] only:portable mkdir? --- unit_tests/test-framework/engine_test_helper.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/unit_tests/test-framework/engine_test_helper.cpp b/unit_tests/test-framework/engine_test_helper.cpp index 5f465c0d9ea..c300291e8f9 100644 --- a/unit_tests/test-framework/engine_test_helper.cpp +++ b/unit_tests/test-framework/engine_test_helper.cpp @@ -15,6 +15,8 @@ #include "tooth_logger.h" #include "logicdata.h" #include "hardware.h" +#include +namespace fs = std::filesystem; #if EFI_ENGINE_SNIFFER #include "engine_sniffer.h" @@ -139,7 +141,7 @@ EngineTestHelper::~EngineTestHelper() { // Write history to file extern bool hasInitGtest; if (hasInitGtest) { - mkdir(LOGICDATA_OUTPUT, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH); + fs::create_directories(LOGICDATA_OUTPUT); std::stringstream filePath; filePath << LOGICDATA_OUTPUT << "/unittest_" << ::testing::UnitTest::GetInstance()->current_test_info()->name() << ".logicdata"; writeEvents(filePath.str().c_str());