| 246 | } |
| 247 | |
| 248 | static int fixture(const char *test) { |
| 249 | Fixture f = {.pid = -1, .ack = {-1, -1}, .gate = {-1, -1}}; |
| 250 | const char *root = getenv("CBM_TEST_COVERAGE_DIR"); |
| 251 | if (!root || root[0] != '/' || !tf_current_suite) |
| 252 | return 1; |
| 253 | struct sigaction ignore = {.sa_handler = SIG_IGN}, previous; |
| 254 | (void)sigemptyset(&ignore.sa_mask); |
| 255 | if (sigaction(SIGPIPE, &ignore, &previous) != 0) |
| 256 | return 1; |
| 257 | bool ok = setup(&f, root) && launch(&f) && observe_and_release(&f, root, test); |
| 258 | if (f.parent_restore_pending && !restore_parent(&f)) |
| 259 | ok = false; |
| 260 | if (!reap(&f, true)) |
| 261 | ok = false; |
| 262 | if (!close_fd(&f.ack[0])) |
| 263 | ok = false; |
| 264 | if (!close_fd(&f.ack[1])) |
| 265 | ok = false; |
| 266 | if (!close_fd(&f.gate[0])) |
| 267 | ok = false; |
| 268 | if (!close_fd(&f.gate[1])) |
| 269 | ok = false; |
| 270 | if (sigaction(SIGPIPE, &previous, NULL) != 0) |
| 271 | ok = false; |
| 272 | if (!ok || f.parent_restore_failed) |
| 273 | fprintf(stderr, "coverage parent fixture failed: native protocol or restoration\n"); |
| 274 | if (f.parent_restore_failed) { |
| 275 | (void)fflush(stderr); |
| 276 | _Exit(2); /* Never continue the runner with an unverified parent limit. */ |
| 277 | } |
| 278 | return ok ? 0 : 1; |
| 279 | } |
| 280 | |
| 281 | TEST(coverage_marker_creation) { |
| 282 | fixture_entered = true; |
no test coverage detected