GCC Code Coverage Report


Directory: ./
File: unit_tests/test-framework/unit_test_logger.cpp
Date: 2025-10-03 00:57:22
Coverage Exec Excl Total
Lines: 100.0% 22 0 22
Functions: 100.0% 4 0 4
Branches: 95.2% 20 0 21
Decisions: 83.3% 5 - 6

Line Branch Decision Exec Source
1 #include "pch.h"
2
3 #include "unit_test_logger.h"
4 #include "binary_mlg_logging.h"
5
6 FILE *mslFile = nullptr;
7
8 struct UnitTestLogBufferWriter final : public BufferedWriter<512> {
9 bool failed = false;
10
11 1654918 size_t writeInternal(const char *buffer, size_t count) override {
12 1654918 return fwrite(buffer, 1, count, mslFile);
13 }
14 };
15
16 static UnitTestLogBufferWriter unitTestLogWriter;
17
18 522954 void writeUnitTestLogLine() {
19
1/2
✓ Branch 0 taken 522954 times.
✗ Branch 1 not taken.
1/2
✓ Decision 'true' taken 522954 times.
✗ Decision 'false' not taken.
522954 if (mslFile != nullptr) {
20 522954 MLG::writeSdLogLine(unitTestLogWriter);
21 }
22 522954 }
23
24 583 void createUnitTestLog() {
25
2/2
✓ Branch 1 taken 583 times.
✓ Branch 4 taken 583 times.
583 auto testInfo = ::testing::UnitTest::GetInstance()->current_test_info();
26
1/1
✓ Branch 2 taken 583 times.
583 std::stringstream filePath;
27 filePath << TEST_RESULTS_DIR << "/unittest_" << testInfo->test_case_name()
28
6/6
✓ Branch 1 taken 583 times.
✓ Branch 4 taken 583 times.
✓ Branch 8 taken 583 times.
✓ Branch 11 taken 583 times.
✓ Branch 15 taken 583 times.
✓ Branch 18 taken 583 times.
583 << "_" << testInfo->name() << ".msl";
29 // fun fact: ASAN says not to extracjsonTracet 'fileName' into a variable, we must be doing something a bit not right?
30
2/2
✓ Branch 2 taken 583 times.
✓ Branch 6 taken 583 times.
583 mslFile = fopen(filePath.str().c_str(), "wb");
31
2/2
✓ Branch 0 taken 557 times.
✓ Branch 1 taken 26 times.
2/2
✓ Decision 'true' taken 557 times.
✓ Decision 'false' taken 26 times.
583 if (mslFile != nullptr) {
32
2/2
✓ Branch 2 taken 557 times.
✓ Branch 6 taken 557 times.
557 printf("Writing [%s]\n", filePath.str().c_str());
33
1/1
✓ Branch 1 taken 557 times.
557 MLG::resetFileLogging();
34
1/1
✓ Branch 1 taken 557 times.
557 MLG::writeSdLogLine(unitTestLogWriter);
35 }
36 1166 }
37
38 583 void closeUnitTestLog() {
39
2/2
✓ Branch 0 taken 557 times.
✓ Branch 1 taken 26 times.
2/2
✓ Decision 'true' taken 557 times.
✓ Decision 'false' taken 26 times.
583 if (mslFile != nullptr) {
40 557 unitTestLogWriter.flush();
41 557 fclose(mslFile);
42 557 mslFile = nullptr;
43 }
44 583 }
45