test/wcc: extend carrier ownership to the bootstrap and platform gates
Same contract as the 27 repaired byte/artifact survivors: checked acquisition, one all-exit cleanup funnel per carrier, ENOENT-tolerant checked unlinks, exact-path deletion, and cleanup failure fails a passing carrier without overwriting its diagnostic. Also closes the vacuous-green channels: empty-artifact pairs no longer byte-compare equal, capture and staging failures fail their row loudly, 950 requires a clean checker exit on no-error rows and hard-fails on a missing wwdump_ww, 992 keys its scratch per invocation so a failed cleanup cannot leak stale objects into the next tool's compare, and 995 no longer pre-sweeps a workdir it never created. No assertion is weakened; 990_selfhost is retired in the next commit rather than repaired.
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/wait.h>
|
||||
#include <dirent.h>
|
||||
@@ -65,6 +66,9 @@ static int
|
||||
diff_one(const char *bin, const char *label, const char *src)
|
||||
{
|
||||
char ws[64], cs[64], cmd[2048];
|
||||
char *bw = NULL, *bc = NULL;
|
||||
size_t nw = 0, nc = 0;
|
||||
int rc = -1;
|
||||
snprintf(ws, sizeof ws, "/tmp/wwc6_%d_w.s", getpid());
|
||||
snprintf(cs, sizeof cs, "/tmp/wwc6_%d_c.s", getpid());
|
||||
|
||||
@@ -72,28 +76,37 @@ diff_one(const char *bin, const char *label, const char *src)
|
||||
bin, src, ws);
|
||||
if (runwait(cmd) != 0) {
|
||||
fprintf(stderr, "w6c_ww FAIL: wwdump_ww -c errored on %s\n", label);
|
||||
unlink(ws);
|
||||
return -1;
|
||||
goto cleanup;
|
||||
}
|
||||
snprintf(cmd, sizeof cmd, "timeout 180 %s/w6c_ww -o %s %s 2>/dev/null", bin, cs, src);
|
||||
if (runwait(cmd) != 0) {
|
||||
fprintf(stderr, "w6c_ww FAIL: w6c_ww errored on %s\n", label);
|
||||
unlink(ws); unlink(cs);
|
||||
return -1;
|
||||
goto cleanup;
|
||||
}
|
||||
char *bw = NULL, *bc = NULL;
|
||||
size_t nw = 0, nc = 0;
|
||||
int rc = 0;
|
||||
if (slurp(ws, &bw, &nw) < 0 || slurp(cs, &bc, &nc) < 0) {
|
||||
fprintf(stderr, "w6c_ww FAIL: cannot read .s for %s\n", label);
|
||||
rc = -1;
|
||||
} else if (nw == 0) {
|
||||
fprintf(stderr, "w6c_ww FAIL: empty .s for %s\n", label);
|
||||
} else if (nw != nc || memcmp(bw, bc, nw) != 0) {
|
||||
fprintf(stderr, "w6c_ww FAIL: %s — wwdump_ww %zu vs w6c_ww %zu bytes\n",
|
||||
label, nw, nc);
|
||||
rc = -1;
|
||||
}
|
||||
} else
|
||||
rc = 0;
|
||||
|
||||
cleanup:
|
||||
free(bw); free(bc);
|
||||
unlink(ws); unlink(cs);
|
||||
/* cs may not exist when w6c_ww never ran or died before -o. */
|
||||
int cleanfail = 0;
|
||||
if (unlink(ws) != 0 && errno != ENOENT) {
|
||||
perror(ws);
|
||||
cleanfail = 1;
|
||||
}
|
||||
if (unlink(cs) != 0 && errno != ENOENT) {
|
||||
perror(cs);
|
||||
cleanfail = 1;
|
||||
}
|
||||
if (cleanfail && rc == 0)
|
||||
rc = -1;
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -103,7 +116,15 @@ write_file(const char *path, const char *content)
|
||||
FILE *f = fopen(path, "wb");
|
||||
if (!f) return -1;
|
||||
wwtest_fputs(content, f);
|
||||
fclose(f);
|
||||
/* wwtest_fputs is void; ferror is the only short-write witness. */
|
||||
int bad = ferror(f);
|
||||
if (fclose(f) != 0) bad = 1;
|
||||
if (bad) {
|
||||
perror(path);
|
||||
if (unlink(path) != 0 && errno != ENOENT)
|
||||
perror(path);
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -282,7 +303,10 @@ main(void)
|
||||
snprintf(src, sizeof src, "/tmp/wwc6_%d_%d.ww", getpid(), i);
|
||||
if (write_file(src, progs[i].src) != 0) { fail++; n++; continue; }
|
||||
if (diff_one(bin, progs[i].label, src) != 0) fail++;
|
||||
unlink(src);
|
||||
if (unlink(src) != 0 && errno != ENOENT) {
|
||||
perror(src);
|
||||
fail++;
|
||||
}
|
||||
n++;
|
||||
}
|
||||
|
||||
@@ -321,7 +345,14 @@ main(void)
|
||||
bad[i].label);
|
||||
fail++;
|
||||
}
|
||||
unlink(src); unlink(s);
|
||||
if (unlink(src) != 0 && errno != ENOENT) {
|
||||
perror(src);
|
||||
fail++;
|
||||
}
|
||||
if (unlink(s) != 0 && errno != ENOENT) {
|
||||
perror(s);
|
||||
fail++;
|
||||
}
|
||||
n++;
|
||||
}
|
||||
|
||||
@@ -371,7 +402,11 @@ main(void)
|
||||
for (int s = 0; s < 2; s++) {
|
||||
snprintf(cmd, sizeof cmd, "rm -rf %s %s.sepwork %s.cache",
|
||||
stg[s].prog, stg[s].prog, stg[s].prog);
|
||||
runwait(cmd);
|
||||
if (runwait(cmd) != 0) {
|
||||
fprintf(stderr, "Tier-C: cleanup %s failed\n",
|
||||
stg[s].prog);
|
||||
fail++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user