| 1 | #cxx . . $ `<file>/tests/cdash_reporter_tests.c`/include <cgreen/breadcrumb.h>cxx . . $ `<file>/include/cgreen/breadcrumb.h`/ |
| 2 | #include <cgreen/cgreen.h>cxx . . $ `<file>/include/cgreen/cgreen.h`/ |
| 3 | #include <cgreen/messaging.h>cxx . . $ `<file>/include/cgreen/messaging.h`/ |
| 4 | |
| 5 | #include <stdio.h> |
| 6 | #include <string.h> |
| 7 | |
| 8 | #include <cgreen/cdash_reporter.h>cxx . . $ `<file>/include/cgreen/cdash_reporter.h`/ |
| 9 | #include "src/cdash_reporter_internal.h"cxx . . $ `<file>/src/cdash_reporter_internal.h`/ |
| 10 | |
| 11 | #ifdef __cpluspluscxx . . $ `<built-in>:440:9`! |
| 12 | using namespace cgreen; |
| 13 | #endif |
| 14 | |
| 15 | static const int linecxx . . $ line.=666; |
| 16 | static char *outputcxx . . $ output. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!; |
| 17 | |
| 18 | static void clear_outputcxx . . $ clear_output(49f6e7a06ebc5aa8).(void) |
| 19 | { |
| 20 | if (NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`! != outputcxx . . $ output.) { |
| 21 | freecxx . . $ free(5d22bdacc48458e8).(outputcxx . . $ output.); |
| 22 | } |
| 23 | |
| 24 | outputcxx . . $ output. = (char*)malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(1); |
| 25 | *outputcxx . . $ output. = '\0'; |
| 26 | } |
| 27 | |
| 28 | static char *concatcxx . . $ concat(5bd1a890f71b1efd).(char *output, char *buffer) { |
| 29 | output = (char *) realloccxx . . $ realloc(417ab160f6baadc6).(output, strlencxx . . $ strlen(751346f8406fd082).(output)+strlencxx . . $ strlen(751346f8406fd082).(buffer)+1); |
| 30 | strcatcxx . . $ strcat(b7b3a83273496486).(output, buffer); |
| 31 | return output; |
| 32 | } |
| 33 | |
| 34 | static int mocked_vprintercxx . . $ mocked_vprinter(bded311e54d67f9c).(FILEcxx . . $ FILE# *stream, const char *format, va_listcxx . . $ va_list# ap) { |
| 35 | (void)stream; /* Unused */ |
| 36 | |
| 37 | char buffer[10000]; |
| 38 | vsnprintfcxx . . $ vsnprintf(a85eea89d1bd834f).(buffer, sizeof(buffer), format, ap); |
| 39 | |
| 40 | outputcxx . . $ output. = concatcxx . . $ concat(5bd1a890f71b1efd).(outputcxx . . $ output., buffer); |
| 41 | return strlencxx . . $ strlen(751346f8406fd082).(outputcxx . . $ output.); |
| 42 | } |
| 43 | |
| 44 | static int mocked_printercxx . . $ mocked_printer(bc216f8e5b1ebeac).(FILEcxx . . $ FILE# *stream, const char *format, ...) { |
| 45 | int result = 0; |
| 46 | |
| 47 | va_listcxx . . $ va_list# ap; |
| 48 | va_startcxx . . $ `<external>/8293021631987149590/stdarg.h:51:9`!(ap, format); |
| 49 | result = mocked_vprintercxx . . $ mocked_vprinter(bded311e54d67f9c).(stream, format, ap); |
| 50 | va_endcxx . . $ `<external>/8293021631987149590/stdarg.h:53:9`!(ap); |
| 51 | |
| 52 | return result; |
| 53 | } |
| 54 | |
| 55 | static TestReportercxx . . $ TestReporter# *reportercxx . . $ reporter.; |
| 56 | |
| 57 | static CDashInfocxx . . $ CDashInfo# infocxx . . $ info.; |
| 58 | |
| 59 | static void setup_cdash_reporter_testscxx . . $ setup_cdash_reporter_tests(49f6e7a06ebc5aa8).(void) { |
| 60 | reportercxx . . $ reporter. = create_cdash_reportercxx . . $ create_cdash_reporter(fb929db595dc89d6).(&infocxx . . $ info.); |
| 61 | |
| 62 | // We can not use setup_reporting() since we are running |
| 63 | // inside a test suite which needs the real reporting |
| 64 | // So we'll have to set up the messaging explicitly |
| 65 | reportercxx . . $ reporter.->ipccxx . . $ TestReporter_#ipc. = start_cgreen_messagingcxx . . $ start_cgreen_messaging(7864480464b09eea).(666); |
| 66 | |
| 67 | clear_outputcxx . . $ clear_output(49f6e7a06ebc5aa8).(); |
| 68 | set_cdash_reporter_printercxx . . $ set_cdash_reporter_printer(5ae1a2e3eabb5e05).(reportercxx . . $ reporter., mocked_printercxx . . $ mocked_printer(bc216f8e5b1ebeac).); |
| 69 | set_cdash_reporter_vprintercxx . . $ set_cdash_reporter_vprinter(386cb8d14b61c110).(reportercxx . . $ reporter., mocked_vprintercxx . . $ mocked_vprinter(bded311e54d67f9c).); |
| 70 | } |
| 71 | |
| 72 | static void teardown_cdash_reporter_testscxx . . $ teardown_cdash_reporter_tests(49f6e7a06ebc5aa8).(void) { |
| 73 | reportercxx . . $ reporter.->destroycxx . . $ TestReporter_#destroy.(reportercxx . . $ reporter.); |
| 74 | |
| 75 | //bad mojo when running tests in same process, as destroy_reporter also sets |
| 76 | //context.reporter = NULL, thus breaking the next test to run |
| 77 | if (NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`! != outputcxx . . $ output.) { |
| 78 | freecxx . . $ free(5d22bdacc48458e8).(outputcxx . . $ output.); |
| 79 | //need to set output to NULL to avoid second free in subsequent call to setup_cdash_reporter_tests->clear_output |
| 80 | //when running tests in same process |
| 81 | outputcxx . . $ output. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!; |
| 82 | } |
| 83 | } |
| 84 | |
| 85 | |
| 86 | Describecxx . . $ Dummy_CDashReporter#(CDashReporter); |
| 87 | BeforeEachcxx . . $ BeforeEach_For_CDashReporter.(CDashReporter) { |
| 88 | setup_cdash_reporter_testscxx . . $ setup_cdash_reporter_tests(49f6e7a06ebc5aa8).(); |
| 89 | } |
| 90 | AfterEachcxx . . $ AfterEach_For_CDashReporter.(CDashReporter) { |
| 91 | teardown_cdash_reporter_testscxx . . $ teardown_cdash_reporter_tests(49f6e7a06ebc5aa8).(); |
| 92 | } |
| 93 | |
| 94 | Ensurecxx . . $ CDashReporter__will_report_nothing_for_suites(49f6e7a06ebc5aa8).(CDashReporter, will_report_nothing_for_suites) { |
| 95 | reportercxx . . $ reporter.->start_suitecxx . . $ TestReporter_#start_suite.(reportercxx . . $ reporter., "suite_name", 2); |
| 96 | reportercxx . . $ reporter.->finish_suitecxx . . $ TestReporter_#finish_suite.(reportercxx . . $ reporter., "filename", linecxx . . $ line.); |
| 97 | } |
| 98 | |
| 99 | Ensurecxx . . $ CgreenTest#(CDashReporter, will_report_passed_for_test_with_one_pass) { |
| 100 | va_listcxx . . $ va_list# arguments; |
| 101 | |
| 102 | reportercxx . . $ reporter.->start_testcxx . . $ TestReporter_#start_test.(reportercxx . . $ reporter., "test_name"); |
| 103 | |
| 104 | memsetcxx . . $ memset(d1de1e4fb215f1c6).(&arguments, 0, sizeof(va_listcxx . . $ va_list#)); |
| 105 | reportercxx . . $ reporter.->show_passcxx . . $ TestReporter_#show_pass.(reportercxx . . $ reporter., "file", 2, "test_name", arguments); |
| 106 | |
| 107 | // Must indicate test case completion before calling finish_test() |
| 108 | send_reporter_completion_notificationcxx . . $ send_reporter_completion_notification(1083e9dac9de8fd0).(reportercxx . . $ reporter.); |
| 109 | reportercxx . . $ reporter.->finish_testcxx . . $ TestReporter_#finish_test.(reportercxx . . $ reporter., "filename", linecxx . . $ line., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!); |
| 110 | |
| 111 | assert_thatcxx . . $ output.(output, contains_stringcxx . . $ `include/cgreen/constraint_syntax_helpers.h:43:9`!("<Test Status=\"passed\">")); |
| 112 | } |
| 113 | |
| 114 | Ensurecxx . . $ CgreenTest#(CDashReporter, will_report_failed_once_for_each_fail) { |
| 115 | va_listcxx . . $ va_list# arguments; |
| 116 | |
| 117 | reportercxx . . $ reporter.->start_testcxx . . $ TestReporter_#start_test.(reportercxx . . $ reporter., "test_name"); |
| 118 | |
| 119 | reportercxx . . $ reporter.->failurescxx . . $ TestReporter_#failures.++; // Simulating a failed assert |
| 120 | memsetcxx . . $ memset(d1de1e4fb215f1c6).(&arguments, 0, sizeof(va_listcxx . . $ va_list#)); |
| 121 | reportercxx . . $ reporter.->show_failcxx . . $ TestReporter_#show_fail.(reportercxx . . $ reporter., "file", 2, "test_name", arguments); |
| 122 | |
| 123 | assert_thatcxx . . $ output.(output, contains_stringcxx . . $ `include/cgreen/constraint_syntax_helpers.h:43:9`!("<Test Status=\"failed\">")); |
| 124 | assert_thatcxx . . $ cgreen/assert_that_(b064aa216885589).(output, contains_stringcxx . . $ `include/cgreen/constraint_syntax_helpers.h:43:9`!("<Name>test_name</Name>")); |
| 125 | assert_thatcxx . . $ output.(output, contains_stringcxx . . $ `include/cgreen/constraint_syntax_helpers.h:43:9`!("<FullName>file</FullName>")); |
| 126 | assert_thatcxx . . $ `include/cgreen/assertions.h:30:9`!(output, contains_stringcxx . . $ `include/cgreen/constraint_syntax_helpers.h:43:9`!("<FullCommandLine>at [file] line [2]</FullCommandLine>")); |
| 127 | |
| 128 | clear_outputcxx . . $ clear_output(49f6e7a06ebc5aa8).(); |
| 129 | |
| 130 | reportercxx . . $ reporter.->failurescxx . . $ TestReporter_#failures.++; // Simulating another failed assert |
| 131 | reportercxx . . $ reporter.->show_failcxx . . $ TestReporter_#show_fail.(reportercxx . . $ reporter., "file", 3, "test_name", arguments); |
| 132 | assert_thatcxx . . $ `include/cgreen/assertions.h:30:9`!(output, contains_stringcxx . . $ `include/cgreen/constraint_syntax_helpers.h:43:9`!("<Test Status=\"failed\">")); |
| 133 | assert_thatcxx . . $ `include/cgreen/assertions.h:30:9`!(output, contains_stringcxx . . $ `include/cgreen/constraint_syntax_helpers.h:43:9`!("<Name>test_name</Name>")); |
| 134 | assert_thatcxx . . $ cgreen/(output, contains_stringcxx . . $ `include/cgreen/constraint_syntax_helpers.h:43:9`!("<FullCommandLine>at [file] line [3]</FullCommandLine>")); |
| 135 | |
| 136 | clear_outputcxx . . $ clear_output(49f6e7a06ebc5aa8).(); |
| 137 | |
| 138 | // Must indicate test case completion before calling finish_test() |
| 139 | send_reporter_completion_notificationcxx . . $ send_reporter_completion_notification(1083e9dac9de8fd0).(reportercxx . . $ reporter.); |
| 140 | reportercxx . . $ reporter.->finish_testcxx . . $ TestReporter_#finish_test.(reportercxx . . $ reporter., "filename", linecxx . . $ line., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!); |
| 141 | assert_thatcxx . . $ `include/cgreen/assertions.h:30:9`!(output, is_equal_to_stringcxx . . $ `include/cgreen/constraint_syntax_helpers.h:41:9`!("")); |
| 142 | } |
| 143 | |
| 144 | static void wrapped_show_failcxx . . $ wrapped_show_fail(f41b995409722d28).(TestReportercxx . . $ TestReporter# *reporter, const char *file, int line, |
| 145 | const char *message, ...) { |
| 146 | va_listcxx . . $ va_list# arguments; |
| 147 | va_startcxx . . $ `<external>/8293021631987149590/stdarg.h:51:9`!(arguments, message); |
| 148 | reporter->show_failcxx . . $ TestReporter_#show_fail.(reporter, file, line, message, arguments); |
| 149 | va_endcxx . . $ `<external>/8293021631987149590/stdarg.h:53:9`!(arguments); |
| 150 | } |
| 151 | |
| 152 | Ensurecxx . . $ CgreenSpec__CDashReporter__will_use_arguments_for_show_fail__.(CDashReporter, will_use_arguments_for_show_fail) { |
| 153 | reportercxx . . $ reporter.->start_testcxx . . $ TestReporter_#start_test.(reportercxx . . $ reporter., "test_name"); |
| 154 | |
| 155 | reportercxx . . $ reporter.->failurescxx . . $ TestReporter_#failures.++; // Simulating a failed assert |
| 156 | wrapped_show_failcxx . . $ wrapped_show_fail(f41b995409722d28).(reportercxx . . $ reporter., "file", 2, "test_case %i is %s", 5, "alive"); |
| 157 | |
| 158 | assert_thatcxx . . $ cgreen/assert_that_(b064aa216885589).(output, contains_stringcxx . . $ `include/cgreen/constraint_syntax_helpers.h:43:9`!("<Value>test_case 5 is alive</Value>")); |
| 159 | |
| 160 | clear_outputcxx . . $ clear_output(49f6e7a06ebc5aa8).(); |
| 161 | |
| 162 | // Must indicate test case completion before calling finish_test() |
| 163 | send_reporter_completion_notificationcxx . . $ send_reporter_completion_notification(1083e9dac9de8fd0).(reportercxx . . $ reporter.); |
| 164 | reportercxx . . $ reporter.->finish_testcxx . . $ TestReporter_#finish_test.(reportercxx . . $ reporter., "filename", linecxx . . $ line., NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!); |
| 165 | assert_thatcxx . . $ `include/cgreen/assertions.h:30:9`!(output, is_equal_to_stringcxx . . $ `include/cgreen/constraint_syntax_helpers.h:41:9`!("")); |
| 166 | } |
| 167 | |
| 168 | Ensurecxx . . $ `include/cgreen/unit.h:25:9`!(CDashReporter, will_report_non_finishing_test) { |
| 169 | const int line = 666; |
| 170 | reportercxx . . $ reporter.->start_suitecxx . . $ TestReporter_#start_suite.(reportercxx . . $ reporter., "suite_name", 1); |
| 171 | |
| 172 | send_reporter_exception_notificationcxx . . $ send_reporter_exception_notification(1083e9dac9de8fd0).(reportercxx . . $ reporter.); |
| 173 | reportercxx . . $ reporter.->finish_suitecxx . . $ TestReporter_#finish_suite.(reportercxx . . $ reporter., "filename", line); |
| 174 | |
| 175 | assert_thatcxx . . $ intptr_t#(output, contains_stringcxx . . $ `include/cgreen/constraint_syntax_helpers.h:43:9`!("<Test Status=\"incomplete\">")); |
| 176 | } |
| 177 | |
| 178 | TestSuitecxx . . $ TestSuite# *cdash_reporter_testscxx . . $ cdash_reporter_tests(564401a81ded3a53).(void) { |
| 179 | TestSuitecxx . . $ TestSuite# *suite = create_test_suitecxx . . $ `include/cgreen/suite.h:20:9`!(); |
| 180 | set_setupcxx . . $ set_setup(375347ed146b1459).(suite, setup_cdash_reporter_testscxx . . $ setup_cdash_reporter_tests(49f6e7a06ebc5aa8).); |
| 181 | |
| 182 | add_test_with_contextcxx . . $ `include/cgreen/suite.h:23:9`!(suite, CDashReporter, will_report_nothing_for_suites); |
| 183 | add_test_with_contextcxx . . $ `include/cgreen/suite.h:23:9`!(suite, CDashReporter, will_report_passed_for_test_with_one_pass); |
| 184 | add_test_with_contextcxx . . $ `include/cgreen/suite.h:23:9`!(suite, CDashReporter, will_report_failed_once_for_each_fail); |
| 185 | add_test_with_contextcxx . . $ `include/cgreen/suite.h:23:9`!(suite, CDashReporter, will_report_non_finishing_test); |
| 186 | |
| 187 | set_teardowncxx . . $ set_teardown(375347ed146b1459).(suite, teardown_cdash_reporter_testscxx . . $ teardown_cdash_reporter_tests(49f6e7a06ebc5aa8).); |
| 188 | return suite; |
| 189 | } |