| 132 | |
| 133 | static void child_body(Child *child) __attribute__((noreturn)); |
| 134 | static void child_body(Child *child) { |
| 135 | if (close(child->ack[0]) != 0 || close(child->gate[1]) != 0 || !send_byte(child->ack[1], 'R') || |
| 136 | !expect_byte(child->gate[0], 'G')) |
| 137 | _exit(90); |
| 138 | char ack[32], gate[32]; |
| 139 | (void)snprintf(ack, sizeof(ack), "%d", child->ack[1]); |
| 140 | (void)snprintf(gate, sizeof(gate), "%d", child->gate[0]); |
| 141 | char *args[] = {(char *)child_runner, "--coverage-child-receiver", ack, gate, NULL}; |
| 142 | if (child->operation >= EXEC_VE && child->operation <= EXEC_L) { |
| 143 | if (unsetenv("CBM_TEST_COVERAGE_DIR") != 0 || |
| 144 | setenv("LLVM_PROFILE_FILE", child->receiver_profile, 1) != 0) |
| 145 | _exit(91); |
| 146 | (void)execute(child->operation, child_runner, args); |
| 147 | _exit(92); |
| 148 | } |
| 149 | if (child->operation == FAILED_EXEC) { |
| 150 | for (int i = 0; i < 4; i++) { |
| 151 | errno = 0; |
| 152 | int result = execute((enum ChildOperation)(EXEC_VE + i), child->missing, args); |
| 153 | if (result != -1 || errno != ENOENT || !send_byte(child->ack[1], (char)('0' + i)) || |
| 154 | !expect_byte(child->gate[0], 'G')) |
| 155 | _exit(93); |
| 156 | } |
| 157 | cbm_cov_child_count_failed_exec(); |
| 158 | _exit(0); |
| 159 | } |
| 160 | switch (child->operation) { |
| 161 | case LOWER: |
| 162 | cbm_cov_child_count_lower(); |
| 163 | _exit(0); |
| 164 | case UPPER: |
| 165 | cbm_cov_child_count_upper(); |
| 166 | _Exit(0); |
| 167 | case NORMAL: |
| 168 | cbm_cov_child_count_normal(); |
| 169 | exit(0); |
| 170 | case SETUP_SUCCESS: |
| 171 | cbm_cov_child_count_setup(); |
| 172 | _exit(0); |
| 173 | default: |
| 174 | _exit(94); |
| 175 | } |
| 176 | } |
| 177 | |
| 178 | static bool close_fd(int *fd) { |
| 179 | if (*fd < 0) |
no test coverage detected