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

Method SetUpTestSuite

lib/mdflib/mdflib_test/src/testchannelarray.cpp:71–118  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 7

RootDirMethod · 0.80
BaseNameMethod · 0.80
CreateDefaultLoggerMethod · 0.80
GetLogFileMethod · 0.80
AddLoggerMethod · 0.80
appendMethod · 0.45
TypeMethod · 0.45

Tested by

no test coverage detected