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