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