| 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 | 1684863 | size_t writeInternal(const char *buffer, size_t count) override { | ||
| 12 | 1684863 | 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 | 584 | void createUnitTestLog() { | ||
| 25 |
2/2✓ Branch 1 taken 584 times.
✓ Branch 4 taken 584 times.
|
584 | auto testInfo = ::testing::UnitTest::GetInstance()->current_test_info(); | |
| 26 |
1/1✓ Branch 2 taken 584 times.
|
584 | std::stringstream filePath; | |
| 27 | filePath << TEST_RESULTS_DIR << "/unittest_" << testInfo->test_case_name() | |||
| 28 |
6/6✓ Branch 1 taken 584 times.
✓ Branch 4 taken 584 times.
✓ Branch 8 taken 584 times.
✓ Branch 11 taken 584 times.
✓ Branch 15 taken 584 times.
✓ Branch 18 taken 584 times.
|
584 | << "_" << 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 584 times.
✓ Branch 6 taken 584 times.
|
584 | mslFile = fopen(filePath.str().c_str(), "wb"); | |
| 31 |
2/2✓ Branch 0 taken 558 times.
✓ Branch 1 taken 26 times.
|
2/2✓ Decision 'true' taken 558 times.
✓ Decision 'false' taken 26 times.
|
584 | if (mslFile != nullptr) { |
| 32 |
2/2✓ Branch 2 taken 558 times.
✓ Branch 6 taken 558 times.
|
558 | printf("Writing [%s]\n", filePath.str().c_str()); | |
| 33 |
1/1✓ Branch 1 taken 558 times.
|
558 | MLG::resetFileLogging(); | |
| 34 |
1/1✓ Branch 1 taken 558 times.
|
558 | MLG::writeSdLogLine(unitTestLogWriter); | |
| 35 | } | |||
| 36 | 1168 | } | ||
| 37 | ||||
| 38 | 584 | void closeUnitTestLog() { | ||
| 39 |
2/2✓ Branch 0 taken 558 times.
✓ Branch 1 taken 26 times.
|
2/2✓ Decision 'true' taken 558 times.
✓ Decision 'false' taken 26 times.
|
584 | if (mslFile != nullptr) { |
| 40 | 558 | unitTestLogWriter.flush(); | ||
| 41 | 558 | fclose(mslFile); | ||
| 42 | 558 | mslFile = nullptr; | ||
| 43 | } | |||
| 44 | 584 | } | ||
| 45 |