| 85 | return ok; |
| 86 | } |
| 87 | static bool pc_fixture_open(pc_fixture_t *f, bool parallel) { |
| 88 | memset(f, 0, sizeof(*f)); |
| 89 | const char *home = th_mktempdir("cbm-pipeline-conventions"); |
| 90 | if (!home || strlen(home) >= sizeof(f->home)) return false; |
| 91 | memcpy(f->home, home, strlen(home) + 1); |
| 92 | bool ok = pc_path(f->repo, sizeof(f->repo), home, "repo") && |
| 93 | pc_path(f->db, sizeof(f->db), home, "published.db") && |
| 94 | pc_path(f->saved, sizeof(f->saved), home, "saved.db") && |
| 95 | pc_path(f->config, sizeof(f->config), f->repo, ".codebase-memory.json") && |
| 96 | th_mkdir_p(f->repo) == 0 && |
| 97 | pc_source_write(f, "aux.c", "void auxiliary(void) {}\n"); |
| 98 | /* The existing full driver needs >50 filtered files as well as >1 worker. */ |
| 99 | for (int i = 0; ok && parallel && i < 51; i++) { |
| 100 | char leaf[40], body[80]; |
| 101 | int a = snprintf(leaf, sizeof(leaf), "filler_%02d.c", i); |
| 102 | int b = snprintf(body, sizeof(body), "void filler_%02d(void) {}\n", i); |
| 103 | ok = a > 0 && (size_t)a < sizeof(leaf) && b > 0 && (size_t)b < sizeof(body) && |
| 104 | pc_source_write(f, leaf, body); |
| 105 | } |
| 106 | if (!ok) { (void)th_rmtree(f->home); f->home[0] = '\0'; } |
| 107 | return ok; |
| 108 | } |
| 109 | static bool pc_env_restore(pc_env_t *env) { |
| 110 | bool ok = true; |
| 111 | if (!env->saved) return true; |
no test coverage detected