| 1 | #cxx . . $ `<file>/src/reporter.c`/include <cgreen/reporter.h>cxx . . $ `<file>/include/cgreen/reporter.h`/ |
| 2 | #include <cgreen/messaging.h>cxx . . $ `<file>/include/cgreen/messaging.h`/ |
| 3 | #include <cgreen/breadcrumb.h>cxx . . $ `<file>/include/cgreen/breadcrumb.h`/ |
| 4 | #include <stdio.h> |
| 5 | #include <string.h> |
| 6 | #include <stdarg.h> |
| 7 | #include <stdbool.h> |
| 8 | #include <stdio.h> |
| 9 | #include <stdlib.h> |
| 10 | |
| 11 | enumcxx . . $ $anonymous_type_81511bd348df0409_0# { passcxx . . $ pass. = 1, failcxx . . $ fail., skippedcxx . . $ skipped. ,completioncxx . . $ completion., exceptioncxx . . $ exception. }; |
| 12 | enumcxx . . $ $anonymous_type_81511bd348df0409_1# { FINISH_NOTIFICATION_RECEIVEDcxx . . $ FINISH_NOTIFICATION_RECEIVED. = 0, FINISH_TEST_SKIPPEDcxx . . $ FINISH_TEST_SKIPPED., FINISH_NOTIFICATION_NOT_RECEIVEDcxx . . $ FINISH_NOTIFICATION_NOT_RECEIVED. }; |
| 13 | |
| 14 | struct TestContext_cxx . . $ TestContext_# { |
| 15 | TestReportercxx . . $ TestReporter# *reportercxx . . $ TestContext_#reporter.; |
| 16 | }; |
| 17 | typedef struct TestContext_cxx . . $ TestContext_# TestContextcxx . . $ TestContext#; |
| 18 | |
| 19 | static TestContextcxx . . $ TestContext# contextcxx . . $ context.; |
| 20 | |
| 21 | static void show_passcxx . . $ show_pass(fabf0cf23815ef65).(TestReportercxx . . $ TestReporter# *reporter, const char *file, int line, |
| 22 | const char *message, va_listcxx . . $ va_list# arguments); |
| 23 | static void show_skipcxx . . $ show_skip(8490445735e6bcce).(TestReportercxx . . $ TestReporter# *reporter, const char *file, int line); |
| 24 | static void show_failcxx . . $ show_fail(fabf0cf23815ef65).(TestReportercxx . . $ TestReporter# *reporter, const char *file, int line, |
| 25 | const char *message, va_listcxx . . $ va_list# arguments); |
| 26 | static void show_incompletecxx . . $ show_incomplete(fabf0cf23815ef65).(TestReportercxx . . $ TestReporter# *reporter, const char *file, int line, |
| 27 | const char *message, va_listcxx . . $ va_list# arguments); |
| 28 | static void assert_truecxx . . $ assert_true(4e0d7dbc4dd0b471).(TestReportercxx . . $ TestReporter# *reporter, const char *file, int line, |
| 29 | int result, const char *message, ...); |
| 30 | static int read_reporter_resultscxx . . $ read_reporter_results(82e618b18aa3c8e3).(TestReportercxx . . $ TestReporter# *reporter); |
| 31 | |
| 32 | TestReportercxx . . $ TestReporter# *get_test_reportercxx . . $ get_test_reporter(a6a8ef953e197a65).(void) { |
| 33 | return contextcxx . . $ context..reportercxx . . $ TestContext_#reporter.; |
| 34 | } |
| 35 | |
| 36 | void setup_reportingcxx . . $ setup_reporting(1083e9dac9de8fd0).(TestReportercxx . . $ TestReporter# *reporter) { |
| 37 | reporter->ipccxx . . $ TestReporter_#ipc. = start_cgreen_messagingcxx . . $ start_cgreen_messaging(7864480464b09eea).(45); |
| 38 | contextcxx . . $ context..reportercxx . . $ TestContext_#reporter. = reporter; |
| 39 | } |
| 40 | |
| 41 | void set_reporter_optionscxx . . $ set_reporter_options(803220dde5864e9d).(TestReportercxx . . $ TestReporter# *reporter, void *options) { |
| 42 | /* We should really copy the options locally to avoid caller to |
| 43 | free the area, but we don't know the size of it... */ |
| 44 | reporter->optionscxx . . $ TestReporter_#options. = options; |
| 45 | } |
| 46 | |
| 47 | TestReportercxx . . $ TestReporter# *create_reportercxx . . $ create_reporter(a6a8ef953e197a65).(void) { |
| 48 | CgreenBreadcrumbcxx . . $ CgreenBreadcrumb# *breadcrumb; |
| 49 | TestReportercxx . . $ TestReporter# *reporter = (TestReportercxx . . $ TestReporter# *) malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(sizeof(TestReportercxx . . $ TestReporter#)); |
| 50 | if (reporter == NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!) { |
| 51 | return NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!; |
| 52 | } |
| 53 | |
| 54 | breadcrumb = create_breadcrumbcxx . . $ create_breadcrumb(6b26f2ef1b00048a).(); |
| 55 | if (breadcrumb == NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!) { |
| 56 | freecxx . . $ free(5d22bdacc48458e8).(reporter); |
| 57 | return NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!; |
| 58 | } |
| 59 | |
| 60 | reporter->destroycxx . . $ TestReporter_#destroy. = &destroy_reportercxx . . $ destroy_reporter(1083e9dac9de8fd0).; |
| 61 | reporter->start_suitecxx . . $ TestReporter_#start_suite. = &reporter_start_suitecxx . . $ reporter_start_suite(8490445735e6bcce).; |
| 62 | reporter->start_testcxx . . $ TestReporter_#start_test. = &reporter_start_testcxx . . $ reporter_start_test(499118f5be74126f).; |
| 63 | reporter->show_passcxx . . $ TestReporter_#show_pass. = &show_passcxx . . $ show_pass(fabf0cf23815ef65).; |
| 64 | reporter->show_skipcxx . . $ TestReporter_#show_skip. = &show_skipcxx . . $ show_skip(8490445735e6bcce).; |
| 65 | reporter->show_failcxx . . $ TestReporter_#show_fail. = &show_failcxx . . $ show_fail(fabf0cf23815ef65).; |
| 66 | reporter->show_incompletecxx . . $ TestReporter_#show_incomplete. = &show_incompletecxx . . $ show_incomplete(fabf0cf23815ef65).; |
| 67 | reporter->assert_truecxx . . $ TestReporter_#assert_true. = &assert_truecxx . . $ assert_true(4e0d7dbc4dd0b471).; |
| 68 | reporter->finish_testcxx . . $ TestReporter_#finish_test. = &reporter_finish_testcxx . . $ reporter_finish_test(4c7a3a1bff8d25e8).; |
| 69 | reporter->finish_suitecxx . . $ TestReporter_#finish_suite. = &reporter_finish_suitecxx . . $ reporter_finish_suite(8490445735e6bcce).; |
| 70 | reporter->passescxx . . $ TestReporter_#passes. = 0; |
| 71 | reporter->skipscxx . . $ TestReporter_#skips. = 0; |
| 72 | reporter->failurescxx . . $ TestReporter_#failures. = 0; |
| 73 | reporter->exceptionscxx . . $ TestReporter_#exceptions. = 0; |
| 74 | reporter->durationcxx . . $ TestReporter_#duration. = 0; |
| 75 | reporter->total_passescxx . . $ TestReporter_#total_passes. = 0; |
| 76 | reporter->total_skipscxx . . $ TestReporter_#total_skips. = 0; |
| 77 | reporter->total_failurescxx . . $ TestReporter_#total_failures. = 0; |
| 78 | reporter->total_exceptionscxx . . $ TestReporter_#total_exceptions. = 0; |
| 79 | reporter->total_durationcxx . . $ TestReporter_#total_duration. = 0; |
| 80 | reporter->breadcrumbcxx . . $ TestReporter_#breadcrumb. = breadcrumb; |
| 81 | reporter->memocxx . . $ TestReporter_#memo. = NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!; |
| 82 | reporter->optionscxx . . $ TestReporter_#options. = NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!; |
| 83 | return reporter; |
| 84 | } |
| 85 | |
| 86 | void destroy_reportercxx . . $ destroy_reporter(1083e9dac9de8fd0).(TestReportercxx . . $ TestReporter# *reporter) { |
| 87 | destroy_breadcrumbcxx . . $ destroy_breadcrumb(4c0e27b58e807c96).((CgreenBreadcrumbcxx . . $ CgreenBreadcrumb# *)reporter->breadcrumbcxx . . $ TestReporter_#breadcrumb.); |
| 88 | destroy_memocxx . . $ destroy_memo(5d22bdacc48458e8).((TestReportMemocxx . . $ TestReportMemo# *)reporter->memocxx . . $ TestReporter_#memo.); |
| 89 | freecxx . . $ free(5d22bdacc48458e8).(reporter); |
| 90 | // hack to allow destroy_reporter to be called in reporter_tests when |
| 91 | // tests are running in same process |
| 92 | if (contextcxx . . $ context..reportercxx . . $ TestContext_#reporter. == reporter) |
| 93 | { |
| 94 | contextcxx . . $ context..reportercxx . . $ TestContext_#reporter. = NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!; |
| 95 | } |
| 96 | } |
| 97 | |
| 98 | void destroy_memocxx . . $ destroy_memo(5d22bdacc48458e8).(TestReportMemocxx . . $ TestReportMemo# *memo) { |
| 99 | if (NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`! != memo) { |
| 100 | freecxx . . $ free(5d22bdacc48458e8).(memo); |
| 101 | } |
| 102 | } |
| 103 | |
| 104 | void reporter_start_testcxx . . $ reporter_start_test(499118f5be74126f).(TestReportercxx . . $ TestReporter# *reporter, const char *name) { |
| 105 | push_breadcrumbcxx . . $ push_breadcrumb(b4ada4a07dddfd16).((CgreenBreadcrumbcxx . . $ CgreenBreadcrumb# *) reporter->breadcrumbcxx . . $ TestReporter_#breadcrumb., name); |
| 106 | } |
| 107 | |
| 108 | void reporter_start_suitecxx . . $ reporter_start_suite(8490445735e6bcce).(TestReportercxx . . $ TestReporter# *reporter, const char *name, const int count) { |
| 109 | (void) count; |
| 110 | push_breadcrumbcxx . . $ push_breadcrumb(b4ada4a07dddfd16).((CgreenBreadcrumbcxx . . $ CgreenBreadcrumb# *) reporter->breadcrumbcxx . . $ TestReporter_#breadcrumb., name); |
| 111 | } |
| 112 | |
| 113 | void reporter_finish_testcxx . . $ reporter_finish_test(4c7a3a1bff8d25e8).(TestReportercxx . . $ TestReporter# *reporter, const char *filename, int line, const char *message) { |
| 114 | int status = read_reporter_resultscxx . . $ read_reporter_results(82e618b18aa3c8e3).(reporter); |
| 115 | |
| 116 | if (status == FINISH_TEST_SKIPPEDcxx . . $ FINISH_TEST_SKIPPED.) { |
| 117 | (*reporter->show_skipcxx . . $ TestReporter_#show_skip.)(reporter, filename, line); |
| 118 | } else if (status == FINISH_NOTIFICATION_NOT_RECEIVEDcxx . . $ FINISH_NOTIFICATION_NOT_RECEIVED.) { |
| 119 | va_listcxx . . $ va_list# no_arguments; |
| 120 | memsetcxx . . $ memset(d1de1e4fb215f1c6).(&no_arguments, 0, sizeof(va_listcxx . . $ va_list#)); |
| 121 | reporter->exceptionscxx . . $ TestReporter_#exceptions.++; |
| 122 | (*reporter->show_incompletecxx . . $ TestReporter_#show_incomplete.)(reporter, filename, line, message, no_arguments); |
| 123 | } |
| 124 | |
| 125 | pop_breadcrumbcxx . . $ pop_breadcrumb(4c0e27b58e807c96).((CgreenBreadcrumbcxx . . $ CgreenBreadcrumb# *)reporter->breadcrumbcxx . . $ TestReporter_#breadcrumb.); |
| 126 | } |
| 127 | |
| 128 | void reporter_finish_suitecxx . . $ reporter_finish_suite(8490445735e6bcce).(TestReportercxx . . $ TestReporter# *reporter, const char *filename, int line) { |
| 129 | (void)filename; |
| 130 | (void)line; |
| 131 | |
| 132 | read_reporter_resultscxx . . $ read_reporter_results(82e618b18aa3c8e3).(reporter); |
| 133 | pop_breadcrumbcxx . . $ pop_breadcrumb(4c0e27b58e807c96).((CgreenBreadcrumbcxx . . $ CgreenBreadcrumb# *)reporter->breadcrumbcxx . . $ TestReporter_#breadcrumb.); |
| 134 | |
| 135 | } |
| 136 | |
| 137 | void add_reporter_resultcxx . . $ add_reporter_result(c3252aedd416e394).(TestReportercxx . . $ TestReporter# *reporter, int result) { |
| 138 | send_cgreen_messagecxx . . $ send_cgreen_message(3e454b8ccf442868).(reporter->ipccxx . . $ TestReporter_#ipc., result ? passcxx . . $ pass. : failcxx . . $ fail.); |
| 139 | } |
| 140 | |
| 141 | void send_reporter_exception_notificationcxx . . $ send_reporter_exception_notification(1083e9dac9de8fd0).(TestReportercxx . . $ TestReporter# *reporter) { |
| 142 | send_cgreen_messagecxx . . $ send_cgreen_message(3e454b8ccf442868).(reporter->ipccxx . . $ TestReporter_#ipc., exceptioncxx . . $ exception.); |
| 143 | } |
| 144 | |
| 145 | void send_reporter_skipped_notificationcxx . . $ send_reporter_skipped_notification(1083e9dac9de8fd0).(TestReportercxx . . $ TestReporter# *reporter) { |
| 146 | send_cgreen_messagecxx . . $ send_cgreen_message(3e454b8ccf442868).(reporter->ipccxx . . $ TestReporter_#ipc., skippedcxx . . $ skipped.); |
| 147 | } |
| 148 | |
| 149 | void send_reporter_completion_notificationcxx . . $ send_reporter_completion_notification(1083e9dac9de8fd0).(TestReportercxx . . $ TestReporter# *reporter) { |
| 150 | send_cgreen_messagecxx . . $ send_cgreen_message(3e454b8ccf442868).(reporter->ipccxx . . $ TestReporter_#ipc., completioncxx . . $ completion.); |
| 151 | } |
| 152 | |
| 153 | static void show_passcxx . . $ show_pass(fabf0cf23815ef65).(TestReportercxx . . $ TestReporter# *reporter, const char *file, int line, |
| 154 | const char *message, va_listcxx . . $ va_list# arguments) { |
| 155 | (void)reporter; |
| 156 | (void)file; |
| 157 | (void)line; |
| 158 | (void)message; |
| 159 | (void)arguments; |
| 160 | } |
| 161 | |
| 162 | static void show_skipcxx . . $ show_skip(8490445735e6bcce).(TestReportercxx . . $ TestReporter# *reporter, const char *file, int line) { |
| 163 | (void)reporter; |
| 164 | (void)file; |
| 165 | (void)line; |
| 166 | } |
| 167 | |
| 168 | static void show_failcxx . . $ show_fail(fabf0cf23815ef65).(TestReportercxx . . $ TestReporter# *reporter, const char *file, int line, |
| 169 | const char *message, va_listcxx . . $ va_list# arguments) { |
| 170 | (void)reporter; |
| 171 | (void)file; |
| 172 | (void)line; |
| 173 | (void)message; |
| 174 | (void)arguments; |
| 175 | } |
| 176 | |
| 177 | static void show_incompletecxx . . $ show_incomplete(fabf0cf23815ef65).(TestReportercxx . . $ TestReporter# *reporter, const char *file, int line, |
| 178 | const char *message, va_listcxx . . $ va_list# arguments) { |
| 179 | (void)reporter; |
| 180 | (void)file; |
| 181 | (void)line; |
| 182 | (void)message; |
| 183 | (void)arguments; |
| 184 | } |
| 185 | |
| 186 | static void assert_truecxx . . $ assert_true(4e0d7dbc4dd0b471).(TestReportercxx . . $ TestReporter# *reporter, const char *file, int line, |
| 187 | int result, const char *message, ...) { |
| 188 | va_listcxx . . $ va_list# arguments; |
| 189 | memsetcxx . . $ memset(d1de1e4fb215f1c6).(&arguments, 0, sizeof(va_listcxx . . $ va_list#)); |
| 190 | |
| 191 | va_startcxx . . $ `<external>/8293021631987149590/stdarg.h:51:9`!(arguments, message); |
| 192 | if (result) { |
| 193 | (*reporter->show_passcxx . . $ TestReporter_#show_pass.)(reporter, file, line, message, arguments); |
| 194 | } else { |
| 195 | (*reporter->show_failcxx . . $ TestReporter_#show_fail.)(reporter, file, line, message, arguments); |
| 196 | } |
| 197 | |
| 198 | add_reporter_resultcxx . . $ add_reporter_result(c3252aedd416e394).(reporter, result); |
| 199 | va_endcxx . . $ `<external>/8293021631987149590/stdarg.h:53:9`!(arguments); |
| 200 | } |
| 201 | |
| 202 | static int read_reporter_resultscxx . . $ read_reporter_results(82e618b18aa3c8e3).(TestReportercxx . . $ TestReporter# *reporter) { |
| 203 | int result; |
| 204 | while ((result = receive_cgreen_messagecxx . . $ receive_cgreen_message(7864480464b09eea).(reporter->ipccxx . . $ TestReporter_#ipc.)) > 0) { |
| 205 | if (result == passcxx . . $ pass.) { |
| 206 | reporter->passescxx . . $ TestReporter_#passes.++; |
| 207 | } else if (result == skippedcxx . . $ skipped.) { |
| 208 | reporter->skipscxx . . $ TestReporter_#skips.++; |
| 209 | return FINISH_TEST_SKIPPEDcxx . . $ FINISH_TEST_SKIPPED.; |
| 210 | } else if (result == failcxx . . $ fail.) { |
| 211 | reporter->failurescxx . . $ TestReporter_#failures.++; |
| 212 | } else if (result == exceptioncxx . . $ exception.) { |
| 213 | reporter->exceptionscxx . . $ TestReporter_#exceptions.++; |
| 214 | } else if (result == completioncxx . . $ completion.) { |
| 215 | /* TODO: this should always be the last message; if it's not, there's a bad race */ |
| 216 | return FINISH_NOTIFICATION_RECEIVEDcxx . . $ FINISH_NOTIFICATION_RECEIVED.; |
| 217 | } |
| 218 | } |
| 219 | |
| 220 | return FINISH_NOTIFICATION_NOT_RECEIVEDcxx . . $ FINISH_NOTIFICATION_NOT_RECEIVED.; |
| 221 | } |
| 222 | |
| 223 | /* vim: set ts=4 sw=4 et cindent: */ |