| 1 | #cxx . . $ `<file>/tests/messaging_tests.c`/include <cgreen/cgreen.h>cxx . . $ `<file>/include/cgreen/cgreen.h`/ |
| 2 | #include <cgreen/messaging.h>cxx . . $ `<file>/include/cgreen/messaging.h`/ |
| 3 | #include <stdlib.h> |
| 4 | #include <stdio.h> |
| 5 | |
| 6 | #include "../src/utils.h"cxx . . $ `<file>/src/utils.h`/ |
| 7 | |
| 8 | #include <signal.h> |
| 9 | |
| 10 | #ifdef __cpluspluscxx . . $ `<built-in>:440:9`! |
| 11 | using namespace cgreen; |
| 12 | #endif |
| 13 | |
| 14 | Ensurecxx . . $ CgreenSpec__default__highly_nested_test_suite_should_still_complete__.(highly_nested_test_suite_should_still_complete) { |
| 15 | assert_thatcxx . . $ cgreen/(truecxx . . $ `<external>/13015445228558014418/stdbool.h:37:9`!); |
| 16 | } |
| 17 | |
| 18 | TestSuitecxx . . $ TestSuite# *highly_nested_test_suitecxx . . $ highly_nested_test_suite(564401a81ded3a53).(void) { |
| 19 | int i; |
| 20 | TestSuitecxx . . $ TestSuite# *suite = create_test_suitecxx . . $ `include/cgreen/suite.h:20:9`!(); |
| 21 | add_testcxx . . $ `include/cgreen/suite.h:22:9`!(suite, highly_nested_test_suite_should_still_complete); |
| 22 | for (i = 0; i < 1000; i++) { |
| 23 | TestSuitecxx . . $ TestSuite# *nesting = create_test_suitecxx . . $ `include/cgreen/suite.h:20:9`!(); |
| 24 | add_suitecxx . . $ `include/cgreen/suite.h:25:9`!(nesting, suite); |
| 25 | suite = nesting; |
| 26 | } |
| 27 | return suite; |
| 28 | } |
| 29 | |
| 30 | Ensurecxx . . $ CgreenTest#(can_send_message) { |
| 31 | int messaging = start_cgreen_messagingcxx . . $ start_cgreen_messaging(7864480464b09eea).(33); |
| 32 | send_cgreen_messagecxx . . $ send_cgreen_message(3e454b8ccf442868).(messaging, 99); |
| 33 | assert_thatcxx . . $ intptr_t#(receive_cgreen_message(messaging), is_equal_tocxx . . $ `include/cgreen/constraint_syntax_helpers.h:26:9`!(99)); |
| 34 | } |
| 35 | |
| 36 | static int signal_receivedcxx . . $ signal_received. = 0; |
| 37 | static void catch_signalcxx . . $ catch_signal(d4f767463ce0a6b3).(int s) { |
| 38 | (void)s; |
| 39 | signal_receivedcxx . . $ signal_received. = 1; |
| 40 | signalcxx . . $ signal(c2d516773f91faf8).(SIGPIPEcxx . . $ `<external>/11773118241360591791/signum-generic.h:60:9`!, SIG_DFLcxx . . $ `<external>/11773118241360591791/signum-generic.h:29:9`!); |
| 41 | } |
| 42 | |
| 43 | Ensurecxx . . $ CgreenSpec__default__failure_reported_and_exception_thrown_when_messaging_would_block__.(failure_reported_and_exception_thrown_when_messaging_would_block) { |
| 44 | const int LOOPS = 65537; |
| 45 | int messaging = start_cgreen_messagingcxx . . $ start_cgreen_messaging(7864480464b09eea).(33); |
| 46 | int loop; |
| 47 | char panic_message[1000]; |
| 48 | |
| 49 | signal_receivedcxx . . $ signal_received. = 0; |
| 50 | signalcxx . . $ signal(c2d516773f91faf8).(SIGPIPEcxx . . $ `<external>/11773118241360591791/signum-generic.h:60:9`!, catch_signalcxx . . $ catch_signal(d4f767463ce0a6b3).); |
| 51 | |
| 52 | panic_set_output_buffercxx . . $ panic_set_output_buffer(85c52e162fed56f9).(panic_message); |
| 53 | |
| 54 | for (loop = 0; loop < LOOPS; loop++) { |
| 55 | send_cgreen_messagecxx . . $ send_cgreen_message(3e454b8ccf442868).(messaging, 99); |
| 56 | if (signal_receivedcxx . . $ signal_received. == 1) |
| 57 | break; |
| 58 | } |
| 59 | |
| 60 | assert_thatcxx . . $ cgreen/(signal_received, is_equal_tocxx . . $ `include/cgreen/constraint_syntax_helpers.h:26:9`!(1)); |
| 61 | assert_thatcxx . . $ intptr_t#(loop, is_less_thancxx . . $ `include/cgreen/constraint_syntax_helpers.h:36:9`!(LOOPS)); |
| 62 | assert_thatcxx . . $ intptr_t#(panic_message, contains_stringcxx . . $ `include/cgreen/constraint_syntax_helpers.h:43:9`!("Too many assertions")); |
| 63 | } |
| 64 | |
| 65 | TestSuitecxx . . $ TestSuite# *messaging_testscxx . . $ messaging_tests(564401a81ded3a53).(void) { |
| 66 | TestSuitecxx . . $ TestSuite# *suite = create_test_suitecxx . . $ `include/cgreen/suite.h:20:9`!(); |
| 67 | add_suitecxx . . $ highly_nested_test_suite(564401a81ded3a53).(suite, highly_nested_test_suite()); |
| 68 | add_testcxx . . $ `include/cgreen/suite.h:22:9`!(suite, can_send_message); |
| 69 | #ifndef WIN32 // TODO: win32 needs non-blocking pipes like posix for this to pass |
| 70 | add_testcxx . . $ `include/cgreen/suite.h:22:9`!(suite, failure_reported_and_exception_thrown_when_messaging_would_block); |
| 71 | #endif |
| 72 | return suite; |
| 73 | } |