MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / SetUpTestSuite

Method SetUpTestSuite

lib/mdflib/mdflib_test/src/testethlogger.cpp:67–109  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

65namespace mdf::test {
66
67void TestEthLogger::SetUpTestSuite() {
68
69 try {
70 // Create the root asn log directory. Note that this directory
71 // exists in the temp dir of the operating system and is not
72 // deleted by this test program. May be deleted at restart
73 // of the operating system.
74 auto temp_dir = temp_directory_path();
75 temp_dir.append("test");
76 kTestRootDir = temp_dir.string();
77 create_directories(temp_dir); // Not deleted
78
79
80 // Log to the console instead of as normally to a file
81 auto& log_config = LogConfig::Instance();
82 log_config.Type(LogType::LogToConsole);
83 log_config.CreateDefaultLogger();
84
85 // Connect MDF library to the util logging functionality
86 MdfLogStream::SetLogFunction1(LogFunc);
87
88 LOG_TRACE() << "Log file created. File: " << log_config.GetLogFile();
89
90 // Create the test directory. Note that this directory is deleted before
91 // running the test, not after. This give the
92 temp_dir.append("mdf");
93 temp_dir.append("eth");
94 std::error_code err;
95 remove_all(temp_dir, err);
96 if (err) {
97 LOG_TRACE() << "Remove error. Message: " << err.message();
98 }
99 create_directories(temp_dir);
100 kTestDir = temp_dir.string();
101
102 LOG_TRACE() << "Created the test directory. Dir: " << kTestDir;
103 kSkipTest = false;
104
105 } catch (const std::exception& err) {
106 LOG_ERROR() << "Failed to create test directories. Error: " << err.what();
107 kSkipTest = true;
108 }
109}
110
111void TestEthLogger::TearDownTestSuite() {
112 LOG_TRACE() << "Tear down the test suite.";

Callers

nothing calls this directly

Calls 4

CreateDefaultLoggerMethod · 0.80
GetLogFileMethod · 0.80
appendMethod · 0.45
TypeMethod · 0.45

Tested by

no test coverage detected