GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
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

unit_tests/test-framework/unit_test_logger.cpp
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 1695490 size_t writeInternal(const char *buffer, size_t count) override {
12 1695490 return fwrite(buffer, 1, count, mslFile);
13 }
14 };
15
16 static UnitTestLogBufferWriter unitTestLogWriter;
17
18 531078 void writeUnitTestLogLine() {
19
1/2
✓ Branch 0 taken 531078 times.
✗ Branch 1 not taken.
1/2
✓ Decision 'true' taken 531078 times.
✗ Decision 'false' not taken.
531078 if (mslFile != nullptr) {
20 531078 MLG::writeSdLogLine(unitTestLogWriter);
21 }
22 531078 }
23
24 598 void createUnitTestLog() {
25
2/2
✓ Branch 1 taken 598 times.
✓ Branch 4 taken 598 times.
598 auto testInfo = ::testing::UnitTest::GetInstance()->current_test_info();
26
1/1
✓ Branch 2 taken 598 times.
598 std::stringstream filePath;
27 filePath << TEST_RESULTS_DIR << "/unittest_" << testInfo->test_case_name()
28
6/6
✓ Branch 1 taken 598 times.
✓ Branch 4 taken 598 times.
✓ Branch 8 taken 598 times.
✓ Branch 11 taken 598 times.
✓ Branch 15 taken 598 times.
✓ Branch 18 taken 598 times.
598 << "_" << 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 598 times.
✓ Branch 6 taken 598 times.
598 mslFile = fopen(filePath.str().c_str(), "wb");
31
2/2
✓ Branch 0 taken 572 times.
✓ Branch 1 taken 26 times.
2/2
✓ Decision 'true' taken 572 times.
✓ Decision 'false' taken 26 times.
598 if (mslFile != nullptr) {
32
2/2
✓ Branch 2 taken 572 times.
✓ Branch 6 taken 572 times.
572 printf("Writing [%s]\n", filePath.str().c_str());
33
1/1
✓ Branch 1 taken 572 times.
572 MLG::resetFileLogging();
34
1/1
✓ Branch 1 taken 572 times.
572 MLG::writeSdLogLine(unitTestLogWriter);
35 }
36 1196 }
37
38 598 void closeUnitTestLog() {
39
2/2
✓ Branch 0 taken 572 times.
✓ Branch 1 taken 26 times.
2/2
✓ Decision 'true' taken 572 times.
✓ Decision 'false' taken 26 times.
598 if (mslFile != nullptr) {
40 572 unitTestLogWriter.flush();
41 572 fclose(mslFile);
42 572 mslFile = nullptr;
43 }
44 598 }
45