GCC Code Coverage Report


Directory: src/gate/
File: src/gate/tests/gatecore_cpp_special_test/gatecore_cpp_special.cpp
Date: 2026-12-03 19:36:00
Exec Total Coverage
Lines: 32 37 86.5%
Functions: 4 4 100.0%
Branches: 27 56 48.2%

Line Branch Exec Source
1 #include "gate/gatemain.h"
2 #include "gate/applications.hpp"
3 #include "gate/debugging.h"
4 #include "gate/platforms.h"
5
6 extern "C" gate_bool_t GATE_CALL test_fault_guard(void);
7
8 namespace gate { namespace apps
9 {
10
11 1 static void test_panic()
12 {
13 1 gate::panic(results::Failed, "panic_app");
14 ✗ }
15
16 1 static void test_debugging_failure_messages()
17 {
18 1 char const* const dbg_msg = "debug-test-trace-message";
19 1 char const* const dbg_file = "debug-test-file";
20 1 char const* const dbg_origin = "debug-test-trace-origin";
21
22 1 gate_debug_trace_platform_error(dbg_msg, dbg_file, 666);
23 1 gate_debug_trace_result(GATE_RESULT_FAILED, dbg_origin, dbg_msg, 666, dbg_file, 666);
24 1 gate_debug_assert(true, dbg_msg, dbg_file, 666);
25 /* notice: some platforms call an attached debugger or fail without one,
26 some platforms have no debugger-binding, so we need to simulate failing */
27 1 gate::panic(results::Failed, "panic_app");
28 ✗ }
29
30
31
32 class GATE_API_LOCAL SpecialTestsApp : public App
33 {
34 public:
35 5 virtual void run() override
36 {
37
3/8
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 5 times.
✗ Branch 7 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
5 static AppOptionDef panic = AppOptionDef::createSwitch("panic", "P", "panic", "Call panic()");
38
3/8
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 5 times.
✗ Branch 7 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
5 static AppOptionDef debugmessages = AppOptionDef::createSwitch("debugmessages", "DM", "debugmessages", "Write debug messages");
39
3/8
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 5 times.
✗ Branch 7 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
5 static AppOptionDef faultguard = AppOptionDef::createSwitch("faultguard", "FG", "faultguard", "Call bad code (e.g. segfaults) with fault guard");
40
3/8
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 5 times.
✗ Branch 7 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
5 static AppOptionDef raise_signal = AppOptionDef::createSwitch("signal", "S", "raisesignal", "Raises a signal");
41
3/8
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 5 times.
✗ Branch 7 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
5 static AppOptionDef raise_error = AppOptionDef::createSwitch("raise-error", "RE", "raise_error", "Raises an error condition");
42
43 static AppOptionDef* options[] =
44 {
45 &panic,
46 &debugmessages,
47 &faultguard,
48 &raise_signal,
49 &raise_error
50 };
51
52 static size_t const optionsCount = sizeof(options) / sizeof(options[0]);
53
54 5 App::parseAppOptions(this->getArgs(), options, optionsCount);
55
56
2/2
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 4 times.
5 if (panic)
57 {
58 1 test_panic();
59 ✗ return;
60 }
61
2/2
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 3 times.
4 else if(debugmessages)
62 {
63 1 test_debugging_failure_messages();
64 ✗ return;
65 }
66
2/2
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 2 times.
3 else if(faultguard)
67 {
68 1 const gate_bool_t succeeded = test_fault_guard();
69
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if (!succeeded)
70 {
71 ✗ this->setExitCode(GATE_RESULT_TO_EXITCODE(GATE_RESULT_FAILED));
72 }
73 1 return;
74 }
75
2/2
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 1 times.
2 else if(raise_signal)
76 {
77 1 gate_platform_raise_signal(GATE_PLATFORM_SIGNAL_CONTINUE);
78 }
79
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 else if(raise_error)
80 {
81 1 gate::raiseError(results::OutOfMemory);
82 }
83 }
84 };
85
86 } } // end of namespace gate/apps
87
88
89 5 int gate_main(char const* program, char const* const* arguments, gate_size_t argcount, gate_uintptr_t apphandle)
90 {
91
1/2
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
8 gate::apps::SpecialTestsApp app;
92
1/2
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
8 return gate::App::runApp(app, program, arguments, argcount, apphandle);
93 }
94