GCC Code Coverage Report


Directory: ./
File: Fw/Types/fputs_assert_hook.cpp
Date: 2026-11-23 21:16:24
Exec Total Coverage
Lines: 32 34 94.1%
Functions: 2 3 66.7%
Branches: 12 16 75.0%

Line Branch Exec Source
1 // ======================================================================
2 // \title fputs_assert_hook.cpp
3 // \author Andrei Tumbar
4 // \brief cpp file for assert hook functions using fputs implementation
5 // ======================================================================
6 #include <Fw/Types/assert_hook.hpp>
7 #include <Fw/Types/format.hpp>
8 #include <cassert>
9 #include <cstdio>
10
11 #if FW_ASSERT_LEVEL == FW_FILEID_ASSERT
12 #define fileIdFs "Assert: 0x%08" PRIx32 ":%" PRI_FwSizeType ""
13 #else
14 #define fileIdFs "Assert: \"%s:%" PRI_FwSizeType "\""
15 #endif
16
17 ✗ void Fw::terminateOnAssert() {
18 ✗ assert(false);
19 }
20
21 1 void Fw::printAssertMessage(const CHAR* msg) {
22 // Write to stderr w/o formatting
23
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 (void)fputs(msg, stderr);
24
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 (void)fputs("\n", stderr);
25 1 }
26
27 20 void Fw::formatAssertMessage(FILE_NAME_ARG file,
28 FwSizeType lineNo,
29 FwSizeType numArgs,
30 FwAssertArgType arg1,
31 FwAssertArgType arg2,
32 FwAssertArgType arg3,
33 FwAssertArgType arg4,
34 FwAssertArgType arg5,
35 FwAssertArgType arg6,
36 CHAR* destBuffer,
37 FwSizeType buffSize) {
38 // Format status is discarded: a truncated assert message is still useful and there is no better recourse here
39
8/8
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 2 times.
✓ Branch 6 taken 2 times.
✓ Branch 7 taken 2 times.
20 switch (numArgs) {
40 4 case 0:
41 4 (void)stringFormat(destBuffer, buffSize, fileIdFs, file, lineNo);
42 4 break;
43 3 case 1:
44 3 (void)stringFormat(destBuffer, buffSize, fileIdFs " %" PRI_FwAssertArgType, file, lineNo, arg1);
45 3 break;
46 2 case 2:
47 2 (void)stringFormat(destBuffer, buffSize, fileIdFs " %" PRI_FwAssertArgType " %" PRI_FwAssertArgType, file,
48 lineNo, arg1, arg2);
49 2 break;
50 3 case 3:
51 3 (void)stringFormat(destBuffer, buffSize,
52 fileIdFs " %" PRI_FwAssertArgType " %" PRI_FwAssertArgType " %" PRI_FwAssertArgType,
53 file, lineNo, arg1, arg2, arg3);
54 3 break;
55 2 case 4:
56 2 (void)stringFormat(destBuffer, buffSize,
57 fileIdFs " %" PRI_FwAssertArgType " %" PRI_FwAssertArgType " %" PRI_FwAssertArgType
58 " %" PRI_FwAssertArgType,
59 file, lineNo, arg1, arg2, arg3, arg4);
60 2 break;
61 2 case 5:
62 2 (void)stringFormat(destBuffer, buffSize,
63 fileIdFs " %" PRI_FwAssertArgType " %" PRI_FwAssertArgType " %" PRI_FwAssertArgType
64 " %" PRI_FwAssertArgType " %" PRI_FwAssertArgType,
65 file, lineNo, arg1, arg2, arg3, arg4, arg5);
66 2 break;
67 2 case 6:
68 2 (void)stringFormat(destBuffer, buffSize,
69 fileIdFs " %" PRI_FwAssertArgType " %" PRI_FwAssertArgType " %" PRI_FwAssertArgType
70 " %" PRI_FwAssertArgType " %" PRI_FwAssertArgType " %" PRI_FwAssertArgType,
71 file, lineNo, arg1, arg2, arg3, arg4, arg5, arg6);
72 2 break;
73 2 default: // in an assert already, what can we do?
74
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if (buffSize > 0) {
75 2 destBuffer[0] = '\0';
76 }
77 2 break;
78 }
79 20 }
80