MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / tf_coverage_init

Function tf_coverage_init

tests/test_main.c:1455–1500  ·  view source on GitHub ↗

False when the run asked for coverage and cannot have it. Children run in * other working directories, so they are handed an absolute name. */

Source from the content-addressed store, hash-verified

1453/* False when the run asked for coverage and cannot have it. Children run in
1454 * other working directories, so they are handed an absolute name. */
1455static bool tf_coverage_init(void) {
1456 const char *dir = getenv("CBM_TEST_COVERAGE_DIR");
1457 if (!dir || !dir[0]) {
1458 return true;
1459 }
1460#ifndef _WIN32
1461 /* A binary built for continuous profiles starts in that mode unless
1462 * LLVM_PROFILE_FILE names a plain file, and then ignores every name this
1463 * runner gives it: all tests would land in one default.profraw. */
1464 const char *initial = getenv("LLVM_PROFILE_FILE");
1465 if (!initial || !initial[0] || tf_coverage_continuous) {
1466 fprintf(stderr,
1467 "a coverage run starts with LLVM_PROFILE_FILE=/dev/null "
1468 "(got: %s)\n",
1469 initial && initial[0] ? initial : "unset");
1470 return false;
1471 }
1472 if (!tf_coverage_atfork_attempted || tf_coverage_atfork_status != 0) {
1473 fprintf(stderr, "coverage child accounting unavailable: reason=atfork code=%d\n",
1474 tf_coverage_atfork_status);
1475 return false;
1476 }
1477#endif
1478 if (!cbm_mkdir_p(dir, 0755) ||
1479 !cbm_canonical_path(dir, tf_coverage_dir, sizeof(tf_coverage_dir))) {
1480 tf_coverage_dir[0] = '\0';
1481 fprintf(stderr, "cannot use coverage directory: %s\n", dir);
1482 return false;
1483 }
1484#ifndef _WIN32
1485 if (!tf_coverage_channel_activate()) {
1486 tf_coverage_dir[0] = '\0';
1487 return false;
1488 }
1489#endif
1490 /* Routing sets the environment, which may move what `dir` points at. */
1491 if (!tf_coverage_route(tf_coverage_dir, "_runner.%p", "_runner.child")) {
1492 fprintf(stderr, "cannot route coverage profiles under: %s\n", tf_coverage_dir);
1493 tf_coverage_dir[0] = '\0';
1494#ifndef _WIN32
1495 tf_coverage_channel_finish();
1496#endif
1497 return false;
1498 }
1499 return true;
1500}
1501
1502#ifndef _WIN32
1503/* ── Children ────────────────────────────────────────────────────────

Callers 1

mainFunction · 0.85

Calls 5

cbm_mkdir_pFunction · 0.85
cbm_canonical_pathFunction · 0.85
tf_coverage_routeFunction · 0.85

Tested by

no test coverage detected