GCC Code Coverage Report


Directory: src/gate/
File: src/gate/tests/gatecore_cpp_special_test/gatecore_cpp_special.cpp
Date: 2026-09-21 06:26:40
Exec Total Coverage
Lines: 29 34 85.3%
Functions: 4 4 100.0%
Branches: 22 46 47.8%

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 4 virtual void run() override
36 {
37
3/8
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 4 times.
✗ Branch 7 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
4 static AppOptionDef panic = AppOptionDef::createSwitch("panic", "P", "panic", "Call panic()");
38
3/8
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 4 times.
✗ Branch 7 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
4 static AppOptionDef debugmessages = AppOptionDef::createSwitch("debugmessages", "DM", "debugmessages", "Write debug messages");
39
3/8
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 4 times.
✗ Branch 7 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
4 static AppOptionDef faultguard = AppOptionDef::createSwitch("faultguard", "FG", "faultguard", "Call bad code (e.g. segfaults) with fault guard");
40
3/8
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 4 times.
✗ Branch 7 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
4 static AppOptionDef raise_signal = AppOptionDef::createSwitch("signal", "S", "raisesignal", "Raises a signal");
41
42 static AppOptionDef* options[] =
43 {
44 &panic,
45 &debugmessages,
46 &faultguard,
47 &raise_signal
48 };
49
50 static size_t const optionsCount = sizeof(options) / sizeof(options[0]);
51
52 4 App::parseAppOptions(this->getArgs(), options, optionsCount);
53
54
2/2
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 3 times.
4 if (panic)
55 {
56 1 test_panic();
57 return;
58 }
59
2/2
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 2 times.
3 else if(debugmessages)
60 {
61 1 test_debugging_failure_messages();
62 return;
63 }
64
2/2
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 1 times.
2 else if(faultguard)
65 {
66 1 const gate_bool_t succeeded = test_fault_guard();
67
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if (!succeeded)
68 {
69 this->setExitCode(GATE_RESULT_TO_EXITCODE(GATE_RESULT_FAILED));
70 }
71 1 return;
72 }
73
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 else if(raise_signal)
74 {
75 1 gate_platform_raise_signal(GATE_PLATFORM_SIGNAL_CONTINUE);
76 }
77 }
78 };
79
80 } } // end of namespace gate/apps
81
82
83 4 int gate_main(char const* program, char const* const* arguments, gate_size_t argcount, gate_uintptr_t apphandle)
84 {
85
1/2
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
6 gate::apps::SpecialTestsApp app;
86
1/2
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
6 return gate::App::runApp(app, program, arguments, argcount, apphandle);
87 }
88