test/wcc: carrier ownership repair and driver-contract adaptation
Every surviving carrier now owns its artifacts: checked mkdir/mkdtemp/ fopen acquisition, one all-exit cleanup funnel per carrier, ENOENT- tolerant checked unlinks, exact-path deletion (rm -rf only for an owned pid-keyed dir or a .sepwork beneath one), and cleanup failure fails a passing carrier without overwriting its diagnostic. In the same pass the carriers adapt to the driver contract this branch lands: --sep and WW_PKGCACHE are gone, -S and the /tmp/ww_run_<pid> scratch contract are asserted, and rows whose runtime or reject coverage moved to test/wcc/data fixtures or test/lang @test owners are trimmed to the byte/artifact/diagnostic observations only they can make. Repair and adaptation ride together because most files interleave both in the same hunks; splitting would manufacture intermediate carrier states that never existed and cannot run against either driver.
This commit is contained in:
@@ -20,6 +20,7 @@
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/wait.h>
|
||||
@@ -146,40 +147,74 @@ main(void)
|
||||
/* NON-VACUITY self-check: the grep must FIRE on a literal asserttyped
|
||||
* line. A grep that never matches would pass every row vacuously. */
|
||||
{
|
||||
char probe[80], cmd[160];
|
||||
snprintf(probe, sizeof probe, "/tmp/wwtupf_probe_%d.txt", getpid());
|
||||
FILE *p = fopen(probe, "wb");
|
||||
if (!p) { fprintf(stderr, "tuprecv_f64: probe open failed\n"); return 1; }
|
||||
fputs("error: asserttyped: e.type_ nil\n", p);
|
||||
fclose(p);
|
||||
snprintf(cmd, sizeof cmd, "grep -q asserttyped %s", probe);
|
||||
if (runwait(cmd) != 0) {
|
||||
fprintf(stderr, "tuprecv_f64: grep self-check FAILED — the "
|
||||
"asserttyped gate is vacuous\n");
|
||||
unlink(probe);
|
||||
char probedir[] = "/tmp/wwtupf_probe_XXXXXX";
|
||||
if (mkdtemp(probedir) == NULL) {
|
||||
fprintf(stderr, "tuprecv_f64: probe mkdtemp failed\n");
|
||||
return 1;
|
||||
}
|
||||
unlink(probe);
|
||||
char probe[128], cmd[256];
|
||||
snprintf(probe, sizeof probe, "%s/probe.txt", probedir);
|
||||
int probe_fail = 0;
|
||||
FILE *p = fopen(probe, "wb");
|
||||
if (!p) {
|
||||
fprintf(stderr, "tuprecv_f64: probe open failed\n");
|
||||
probe_fail = 1;
|
||||
} else {
|
||||
int writefail =
|
||||
fputs("error: asserttyped: e.type_ nil\n", p) == EOF;
|
||||
if (fclose(p) != 0) writefail = 1;
|
||||
if (writefail) {
|
||||
fprintf(stderr, "tuprecv_f64: probe write failed\n");
|
||||
probe_fail = 1;
|
||||
} else {
|
||||
snprintf(cmd, sizeof cmd, "grep -q asserttyped %s", probe);
|
||||
if (runwait(cmd) != 0) {
|
||||
fprintf(stderr, "tuprecv_f64: grep self-check FAILED — the "
|
||||
"asserttyped gate is vacuous\n");
|
||||
probe_fail = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
int cleanfail = 0;
|
||||
if (unlink(probe) != 0 && errno != ENOENT) cleanfail = 1;
|
||||
if (rmdir(probedir) != 0) cleanfail = 1;
|
||||
if (cleanfail)
|
||||
fprintf(stderr, "tuprecv_f64: probe cleanup failed\n");
|
||||
if (probe_fail || cleanfail) return 1;
|
||||
}
|
||||
|
||||
for (int i = 0; rows[i].src; i++, n++) {
|
||||
char tmpdir[64], src[128], errf[128], rmcmd[160], cmd[2048];
|
||||
snprintf(tmpdir, sizeof tmpdir, "/tmp/wwtupf_%d_d_%d",
|
||||
getpid(), i);
|
||||
mkdir(tmpdir, 0755);
|
||||
snprintf(src, sizeof src, "%s/wwtupf_%d_%d.ww",
|
||||
tmpdir, getpid(), i);
|
||||
char tmpdir[] = "/tmp/wwtupf_XXXXXX";
|
||||
if (mkdtemp(tmpdir) == NULL) {
|
||||
fprintf(stderr, "row[%s]: mkdtemp failed\n", rows[i].label);
|
||||
fail++;
|
||||
continue;
|
||||
}
|
||||
char src[128], errf[128], cmd[2048];
|
||||
snprintf(src, sizeof src, "%s/case.ww", tmpdir);
|
||||
snprintf(errf, sizeof errf, "%s/err", tmpdir);
|
||||
snprintf(rmcmd, sizeof rmcmd, "rm -rf %s", tmpdir);
|
||||
|
||||
FILE *f = fopen(src, "wb");
|
||||
if (f == NULL) { runwait(rmcmd); fail++; continue; }
|
||||
fputs(rows[i].src, f);
|
||||
fclose(f);
|
||||
if (f == NULL) {
|
||||
fprintf(stderr, "row[%s]: source open failed\n", rows[i].label);
|
||||
fail++;
|
||||
goto row_cleanup;
|
||||
}
|
||||
int writefail = fputs(rows[i].src, f) == EOF;
|
||||
if (fclose(f) != 0) writefail = 1;
|
||||
if (writefail) {
|
||||
fprintf(stderr, "row[%s]: source write failed\n", rows[i].label);
|
||||
fail++;
|
||||
goto row_cleanup;
|
||||
}
|
||||
|
||||
snprintf(cmd, sizeof cmd, "%s -o /dev/null %s 2>%s",
|
||||
w6c_ww, src, errf);
|
||||
runwait(cmd);
|
||||
if (runwait(cmd) != 0) {
|
||||
fprintf(stderr, "row[%s]: w6c_ww stamp probe failed\n",
|
||||
rows[i].label);
|
||||
fail++;
|
||||
}
|
||||
snprintf(cmd, sizeof cmd, "grep -q asserttyped %s", errf);
|
||||
if (runwait(cmd) == 0) {
|
||||
fprintf(stderr, "row[%s]: w6c_ww emitted asserttyped "
|
||||
@@ -187,7 +222,19 @@ main(void)
|
||||
rows[i].label);
|
||||
fail++;
|
||||
}
|
||||
runwait(rmcmd);
|
||||
|
||||
row_cleanup:
|
||||
{
|
||||
int cleanfail = 0;
|
||||
if (unlink(errf) != 0 && errno != ENOENT) cleanfail = 1;
|
||||
if (unlink(src) != 0 && errno != ENOENT) cleanfail = 1;
|
||||
if (rmdir(tmpdir) != 0) cleanfail = 1;
|
||||
if (cleanfail) {
|
||||
fprintf(stderr, "row[%s]: temporary cleanup failed\n",
|
||||
rows[i].label);
|
||||
fail++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (fail) {
|
||||
|
||||
Reference in New Issue
Block a user