| 1 | #cxx . . $ `<file>/src/posix_runner_platform.c`/ifndef _GNU_SOURCE |
| 2 | #define _GNU_SOURCEcxx . . $ `src/posix_runner_platform.c:2:9`! |
| 3 | #endif |
| 4 | |
| 5 | #ifndef __ANDROID__ |
| 6 | #include "config.h"cxx . . $ `<file>/build/config.h`/ |
| 7 | #endif // #ifdef __ANDROID__ |
| 8 | #include "runner.h"cxx . . $ `<file>/src/runner.h`/ |
| 9 | #include "cgreen/internal/runner_platform.h"cxx . . $ `<file>/include/cgreen/internal/runner_platform.h`/ |
| 10 | #include <stdio.h> |
| 11 | #include <stdint.h> |
| 12 | #include <unistd.h> |
| 13 | #include <sys/wait.h> |
| 14 | #include <signal.h> |
| 15 | #include <stdlib.h> |
| 16 | #include <string.h> |
| 17 | #include <cgreen/internal/cgreen_time.h>cxx . . $ `<file>/include/cgreen/internal/cgreen_time.h`/ |
| 18 | |
| 19 | #ifdef __ANDROID__ |
| 20 | #include "cgreen/internal/android_headers/androidcompat.h" |
| 21 | #endif // #ifdef __ANDROID__ |
| 22 | |
| 23 | |
| 24 | typedef void (*sighandler_tcxx . . $ sighandler_t#)(int); |
| 25 | |
| 26 | static int in_child_processcxx . . $ in_child_process(b126dc7c1de90089).(void); |
| 27 | static int wait_for_child_processcxx . . $ wait_for_child_process(b126dc7c1de90089).(void); |
| 28 | static void stopcxx . . $ stop(49f6e7a06ebc5aa8).(void); |
| 29 | static void ignore_ctrl_ccxx . . $ ignore_ctrl_c(49f6e7a06ebc5aa8).(void); |
| 30 | static void allow_ctrl_ccxx . . $ allow_ctrl_c(49f6e7a06ebc5aa8).(void); |
| 31 | |
| 32 | |
| 33 | void run_test_in_its_own_processcxx . . $ run_test_in_its_own_process(3d0ff4d36cb88b8a).(TestSuitecxx . . $ TestSuite# *suite, CgreenTestcxx . . $ CgreenTest# *test, TestReportercxx . . $ TestReporter# *reporter) { |
| 34 | uint32_tcxx . . $ uint32_t# test_starting_milliseconds = cgreen_time_get_current_millisecondscxx . . $ cgreen_time_get_current_milliseconds(db52760e79bf9054).(); |
| 35 | |
| 36 | (*reporter->start_testcxx . . $ TestReporter_#start_test.)(reporter, test->namecxx . . $ $anonymous_type_2148a7db88bac269_1#name.); |
| 37 | if (test->skipcxx . . $ $anonymous_type_2148a7db88bac269_1#skip.) { |
| 38 | send_reporter_skipped_notificationcxx . . $ send_reporter_skipped_notification(1083e9dac9de8fd0).(reporter); |
| 39 | (*reporter->finish_testcxx . . $ TestReporter_#finish_test.)(reporter, test->filenamecxx . . $ $anonymous_type_2148a7db88bac269_1#filename., test->linecxx . . $ $anonymous_type_2148a7db88bac269_1#line., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!); |
| 40 | } else if (in_child_processcxx . . $ in_child_process(b126dc7c1de90089).()) { |
| 41 | run_the_test_codecxx . . $ run_the_test_code(3d0ff4d36cb88b8a).(suite, test, reporter); |
| 42 | send_reporter_completion_notificationcxx . . $ send_reporter_completion_notification(1083e9dac9de8fd0).(reporter); |
| 43 | stopcxx . . $ stop(49f6e7a06ebc5aa8).(); |
| 44 | } else { |
| 45 | const int status = wait_for_child_processcxx . . $ wait_for_child_process(b126dc7c1de90089).(); |
| 46 | reporter->durationcxx . . $ TestReporter_#duration. = cgreen_time_duration_in_millisecondscxx . . $ cgreen_time_duration_in_milliseconds(83f10ac8959d5577).(test_starting_milliseconds, |
| 47 | cgreen_time_get_current_millisecondscxx . . $ cgreen_time_get_current_milliseconds(db52760e79bf9054).()); |
| 48 | if (WIFSIGNALEDcxx . . $ `<external>/3791503621068212355/wait.h:58:10`!(status)) { |
| 49 | /* a C++ exception generates SIGABRT. Only print our special message for other signals. */ |
| 50 | const int sig = WTERMSIGcxx . . $ `<external>/3791503621068212355/wait.h:55:10`!(status); |
| 51 | if (sig != SIGABRTcxx . . $ `<external>/11773118241360591791/signum-generic.h:50:9`!) { |
| 52 | char buf[128]; |
| 53 | snprintfcxx . . $ snprintf(ea502d73e74c754c).(buf, sizeof(buf), "Test terminated with signal: %s", (const char *)strsignalcxx . . $ strsignal(ff224f080444ee45).(sig)); |
| 54 | (*reporter->finish_testcxx . . $ TestReporter_#finish_test.)(reporter, test->filenamecxx . . $ $anonymous_type_2148a7db88bac269_1#filename., test->linecxx . . $ $anonymous_type_2148a7db88bac269_1#line., buf); |
| 55 | return; |
| 56 | } |
| 57 | } |
| 58 | |
| 59 | (*reporter->finish_testcxx . . $ TestReporter_#finish_test.)(reporter, test->filenamecxx . . $ $anonymous_type_2148a7db88bac269_1#filename., test->linecxx . . $ $anonymous_type_2148a7db88bac269_1#line., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!); |
| 60 | } |
| 61 | } |
| 62 | |
| 63 | static int in_child_processcxx . . $ in_child_process(b126dc7c1de90089).(void) { |
| 64 | fflushcxx . . $ fflush(89bc1efcdac0ca22).(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!); /* Flush all buffers before forking */ |
| 65 | pid_tcxx . . $ pid_t# child = forkcxx . . $ fork(b126dc7c1de90089).(); |
| 66 | if (child < 0) { |
| 67 | diecxx . . $ die(326aeb464d16410c).("Could not fork process\n"); |
| 68 | } |
| 69 | return ! child; |
| 70 | } |
| 71 | |
| 72 | static int wait_for_child_processcxx . . $ wait_for_child_process(b126dc7c1de90089).(void) { |
| 73 | int status = 0; |
| 74 | ignore_ctrl_ccxx . . $ ignore_ctrl_c(49f6e7a06ebc5aa8).(); |
| 75 | waitcxx . . $ wait(a5f7824ee4986326).(&status); |
| 76 | allow_ctrl_ccxx . . $ allow_ctrl_c(49f6e7a06ebc5aa8).(); |
| 77 | return status; |
| 78 | } |
| 79 | |
| 80 | void die_incxx . . $ die_in(cb2f890c2fdad230).(unsigned int seconds) { |
| 81 | sighandler_tcxx . . $ sighandler_t# signal_result = signalcxx . . $ signal(c2d516773f91faf8).(SIGALRMcxx . . $ `<external>/11773118241360591791/signum-generic.h:61:9`!, (sighandler_tcxx . . $ sighandler_t#)&stopcxx . . $ stop(49f6e7a06ebc5aa8).); |
| 82 | if (SIG_ERRcxx . . $ `<external>/11773118241360591791/signum-generic.h:28:9`! == signal_result) { |
| 83 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "could not set alarm signal handler\n"); |
| 84 | return; |
| 85 | } |
| 86 | |
| 87 | alarmcxx . . $ alarm(2141b656ce2cc063).(seconds); |
| 88 | } |
| 89 | |
| 90 | void run_specified_test_if_childcxx . . $ run_specified_test_if_child(fd56715dd2ba0781).(TestSuitecxx . . $ TestSuite# *suite, TestReportercxx . . $ TestReporter# *reporter){ |
| 91 | //not needed for systems that support fork() |
| 92 | (void)suite; |
| 93 | (void)reporter; |
| 94 | } |
| 95 | |
| 96 | static void stopcxx . . $ stop(49f6e7a06ebc5aa8).(void) { |
| 97 | #ifdef CGREEN_INTERNAL_WITH_GCOV |
| 98 | if (1) |
| 99 | #else |
| 100 | if (getenvcxx . . $ getenv(a8b8e32347182212).("CGREEN_CHILD_EXIT_WITH__EXIT") == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!) |
| 101 | #endif |
| 102 | exitcxx . . $ exit(3ca292c338df9bb3).(EXIT_SUCCESScxx . . $ `<external>/10696550936717951914/stdlib.h:97:9`!); |
| 103 | else |
| 104 | _exitcxx . . $ _exit(3ca292c338df9bb3).(EXIT_SUCCESScxx . . $ `<external>/10696550936717951914/stdlib.h:97:9`!); |
| 105 | } |
| 106 | |
| 107 | static void ignore_ctrl_ccxx . . $ ignore_ctrl_c(49f6e7a06ebc5aa8).(void) { |
| 108 | signalcxx . . $ signal(c2d516773f91faf8).(SIGINTcxx . . $ `<external>/11773118241360591791/signum-generic.h:48:9`!, SIG_IGNcxx . . $ `<external>/11773118241360591791/signum-generic.h:30:9`!); |
| 109 | } |
| 110 | |
| 111 | static void allow_ctrl_ccxx . . $ allow_ctrl_c(49f6e7a06ebc5aa8).(void) { |
| 112 | signalcxx . . $ signal(c2d516773f91faf8).(SIGINTcxx . . $ `<external>/11773118241360591791/signum-generic.h:48:9`!, SIG_DFLcxx . . $ `<external>/11773118241360591791/signum-generic.h:29:9`!); |
| 113 | } |
| 114 | |
| 115 | /* vim: set ts=4 sw=4 et cindent: */ |