test: retire 911_attest_record; record-continue owned by test/package
This commit is contained in:
@@ -616,6 +616,24 @@ fn runtimepath(relative: str) str = {
|
||||
(30i64 * (time.second: i64)): time.duration, &out);
|
||||
expectexit(&out, 1);
|
||||
assert(has(out.stdout, "signal_is_not_exit ... FAIL (signal 15)\n"));
|
||||
|
||||
// Record-and-continue past every fault class: the runner reports
|
||||
// hardware faults with their literal signal numbers and still
|
||||
// reaches the trailing test (retired 911_attest_record).
|
||||
let recav: []str = [driver("ww"), "test",
|
||||
runtimepath("record_continue_test.ww")];
|
||||
runcommand(root, "sf-record", recav,
|
||||
(30i64 * (time.second: i64)): time.duration, &out);
|
||||
expectexit(&out, 1);
|
||||
assert(has(out.stdout, "rec_pass_a ... ok\n"));
|
||||
assert(has(out.stdout, "rec_assert ... FAIL (exit 1)\n"));
|
||||
assert(has(out.stdout, "rec_segv ... FAIL (signal 11)\n"));
|
||||
assert(has(out.stdout, "rec_div0 ... FAIL (signal 8)\n"));
|
||||
assert(has(out.stdout, "rec_pass_b ... ok\n"));
|
||||
assert(has(out.stdout,
|
||||
"2 passed, 3 failed, 0 skipped, 0 harness errors\n"));
|
||||
assert(has(out.stdout,
|
||||
"5 discovered, 5 selected, 5 started, 5 completed\n"));
|
||||
clean(root);
|
||||
};
|
||||
|
||||
|
||||
30
test/package/runtime/record_continue_test.ww
Normal file
30
test/package/runtime/record_continue_test.ww
Normal file
@@ -0,0 +1,30 @@
|
||||
// Record-and-continue: one passing test, then the three runtime fault
|
||||
// classes the lib/test fork+wait4 runner must each catch and PROCEED
|
||||
// past (failed assert, nil deref -> SIGSEGV, divide-by-zero -> SIGFPE),
|
||||
// then a final passing test to prove the run reaches the tail after
|
||||
// every failure. Ported from the retired 911_attest_record carrier and
|
||||
// its test/wcc/data/attest_record.ww fixture.
|
||||
|
||||
package runtime_record_continue_test;
|
||||
|
||||
@test fn rec_pass_a() void = {
|
||||
assert(1 + 1 == 2);
|
||||
};
|
||||
|
||||
@test fn rec_assert() void = {
|
||||
assert(1 == 2);
|
||||
};
|
||||
|
||||
@test fn rec_segv() void = {
|
||||
let p: *i32 = nil: *i32;
|
||||
*p = 7i32;
|
||||
};
|
||||
|
||||
@test fn rec_div0() void = {
|
||||
let z: i32 = 0;
|
||||
let _: i32 = 1 / z;
|
||||
};
|
||||
|
||||
@test fn rec_pass_b() void = {
|
||||
assert(true);
|
||||
};
|
||||
@@ -1,227 +0,0 @@
|
||||
/*
|
||||
* 911_attest_record — #17 record-and-continue harness (lib/test + the
|
||||
* table-synth -T entry). Sibling of 989_septest_run + 911_attest_drop
|
||||
* (which pin the synth entry itself + the #6 non-T drop); this one pins
|
||||
* the RUNTIME behaviour the fork+wait4 runner adds:
|
||||
*
|
||||
* 1. RECORD-AND-CONTINUE — `ww test` the mixed fixture (one pass, then
|
||||
* assert-fail/SIGSEGV/SIGFPE, then a final pass). The runner must
|
||||
* proceed past every failure, emit the right per-test `name ... ok/
|
||||
* FAIL` line (table-driven below), print the right `P passed, F
|
||||
* failed` summary, and clamp any failure set to exit 1.
|
||||
* 2. ALL-PASS — `ww test` the all-pass fixture exits 0 (no false
|
||||
* failure from the new runner).
|
||||
* 3. BYTE-ID (rule 10) — `ww test -c` the mixed fixture into a
|
||||
* lib/test-inclusive combined, then `w6c -T` and `w6c_ww -T` must
|
||||
* emit byte-identical asm (the table + fork loop, both stages).
|
||||
*
|
||||
* The fork changes failure OUTPUT, not pass behaviour: a passing fixture
|
||||
* still exits 0, so the 35 converted lib tests stay green (904/967/...).
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/wait.h>
|
||||
|
||||
static int
|
||||
runwait(const char *cmd)
|
||||
{
|
||||
int rc = system(cmd);
|
||||
if (rc == -1) return -1;
|
||||
if (WIFEXITED(rc)) return WEXITSTATUS(rc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static const char *
|
||||
absbin(void)
|
||||
{
|
||||
const char *b = getenv("BIN");
|
||||
if (!b) b = "out/bin";
|
||||
if (b[0] == '/') return b;
|
||||
static char buf[2048];
|
||||
char cwd[1024];
|
||||
if (getcwd(cwd, sizeof cwd) == NULL) return NULL;
|
||||
snprintf(buf, sizeof buf, "%s/%s", cwd, b);
|
||||
return buf;
|
||||
}
|
||||
|
||||
static int
|
||||
slurp(const char *path, char *out, size_t outsz)
|
||||
{
|
||||
FILE *f = fopen(path, "rb");
|
||||
if (!f) return -1;
|
||||
size_t n = fread(out, 1, outsz - 1, f);
|
||||
out[n] = '\0';
|
||||
fclose(f);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Each expected per-test verdict line, in source/collection order. */
|
||||
static const char *expect_lines[] = {
|
||||
"rec_pass_a ... ok",
|
||||
"rec_assert ... FAIL",
|
||||
"rec_segv ... FAIL",
|
||||
"rec_div0 ... FAIL",
|
||||
"rec_pass_b ... ok",
|
||||
"2 passed, 3 failed, 0 skipped, 0 harness errors",
|
||||
"5 discovered, 5 selected, 5 started, 5 completed",
|
||||
};
|
||||
|
||||
static int
|
||||
record_continue(const char *bin)
|
||||
{
|
||||
char dir[] = "/tmp/at911_record_XXXXXX";
|
||||
char out[256], cmd[4096], buf[8192];
|
||||
int result = 1;
|
||||
if (mkdtemp(dir) == NULL) {
|
||||
fprintf(stderr, "911 FAIL: record workspace acquisition failed\n");
|
||||
return 1;
|
||||
}
|
||||
snprintf(out, sizeof out, "%s/output", dir);
|
||||
|
||||
/* `ww test` builds the fixture (auto-bundling lib/test) and runs it;
|
||||
* three failures remain visible in output while the public exit clamps. */
|
||||
snprintf(cmd, sizeof cmd,
|
||||
"%s/ww test test/wcc/data/attest_record.ww > %s 2>/dev/null",
|
||||
bin, out);
|
||||
int rc = runwait(cmd);
|
||||
if (rc != 1) {
|
||||
fprintf(stderr, "911 FAIL: record-and-continue exit %d "
|
||||
"(expected canonical failure exit 1)\n", rc);
|
||||
goto done;
|
||||
}
|
||||
if (slurp(out, buf, sizeof buf) != 0) {
|
||||
fprintf(stderr, "911 FAIL: cannot read runner output\n");
|
||||
goto done;
|
||||
}
|
||||
for (size_t i = 0; i < sizeof expect_lines / sizeof expect_lines[0]; i++) {
|
||||
if (strstr(buf, expect_lines[i]) == NULL) {
|
||||
fprintf(stderr, "911 FAIL: missing runner line '%s'\n"
|
||||
"--- got ---\n%s\n", expect_lines[i], buf);
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
result = 0;
|
||||
|
||||
done:
|
||||
{
|
||||
int cleanfail = 0;
|
||||
if (unlink(out) != 0 && errno != ENOENT) cleanfail = 1;
|
||||
if (rmdir(dir) != 0) cleanfail = 1;
|
||||
if (cleanfail) {
|
||||
fprintf(stderr, "911 FAIL: record workspace cleanup failed\n");
|
||||
result = 1;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
static int
|
||||
all_pass(const char *bin)
|
||||
{
|
||||
char cmd[4096];
|
||||
snprintf(cmd, sizeof cmd,
|
||||
"%s/ww test test/wcc/data/attest_pass.ww > /dev/null 2>&1", bin);
|
||||
int rc = runwait(cmd);
|
||||
if (rc != 0) {
|
||||
fprintf(stderr, "911 FAIL: all-pass fixture exit %d "
|
||||
"(expected 0)\n", rc);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
byteid(const char *bin)
|
||||
{
|
||||
char dir[] = "/tmp/at911_bid_XXXXXX";
|
||||
char stemc[256], stemw[256], cs[256], ws[256], cmd[4096];
|
||||
char scratchc[288], scratchw[288];
|
||||
int rc = 1;
|
||||
if (mkdtemp(dir) == NULL) {
|
||||
fprintf(stderr, "911 FAIL: byteid workspace acquisition failed\n");
|
||||
return 1;
|
||||
}
|
||||
snprintf(stemc, sizeof stemc, "%s/cstage", dir);
|
||||
snprintf(stemw, sizeof stemw, "%s/wwstage", dir);
|
||||
snprintf(cs, sizeof cs, "%s/cstage.s", dir);
|
||||
snprintf(ws, sizeof ws, "%s/wwstage.s", dir);
|
||||
snprintf(scratchc, sizeof scratchc, "%s.sepwork", stemc);
|
||||
snprintf(scratchw, sizeof scratchw, "%s.sepwork", stemw);
|
||||
|
||||
/* #94 sep layout: `ww test -c -o <stem>` carries -T to the root
|
||||
* so w6c synthesizes the test table + fork loop, and emits per-package
|
||||
* asm to <stem>.sepwork/ (compile-only, no harness run). The cstage
|
||||
* build (w6c) and wwstage build (w6c_ww)
|
||||
* must produce byte-identical asm across all packages. */
|
||||
snprintf(cmd, sizeof cmd,
|
||||
"%s/ww test -c -o %s "
|
||||
"test/wcc/data/attest_record.ww > /dev/null 2>&1", bin, stemc);
|
||||
if (runwait(cmd) != 0) {
|
||||
fprintf(stderr, "911 FAIL: cstage ww test -c \n");
|
||||
goto done;
|
||||
}
|
||||
snprintf(cmd, sizeof cmd,
|
||||
"%s/ww_ww test -c -o %s "
|
||||
"test/wcc/data/attest_record.ww > /dev/null 2>&1", bin, stemw);
|
||||
if (runwait(cmd) != 0) {
|
||||
fprintf(stderr, "911 FAIL: wwstage ww_ww test -c \n");
|
||||
goto done;
|
||||
}
|
||||
snprintf(cmd, sizeof cmd, "cat %s.sepwork/*.s > %s 2>/dev/null", stemc, cs);
|
||||
if (runwait(cmd) != 0) {
|
||||
fprintf(stderr, "911 FAIL: cstage asm aggregation failed\n");
|
||||
goto done;
|
||||
}
|
||||
snprintf(cmd, sizeof cmd, "cat %s.sepwork/*.s > %s 2>/dev/null", stemw, ws);
|
||||
if (runwait(cmd) != 0) {
|
||||
fprintf(stderr, "911 FAIL: wwstage asm aggregation failed\n");
|
||||
goto done;
|
||||
}
|
||||
|
||||
char bc[262144], bw[262144];
|
||||
rc = 0;
|
||||
if (slurp(cs, bc, sizeof bc) < 0 || slurp(ws, bw, sizeof bw) < 0) {
|
||||
fprintf(stderr, "911 FAIL: slurp byteid asm\n");
|
||||
rc = 1;
|
||||
} else if (strcmp(bc, bw) != 0) {
|
||||
fprintf(stderr, "911 FAIL: -T asm differs between stages\n");
|
||||
rc = 1;
|
||||
}
|
||||
done:
|
||||
{
|
||||
int cleanfail = 0;
|
||||
if (unlink(cs) != 0 && errno != ENOENT) cleanfail = 1;
|
||||
if (unlink(ws) != 0 && errno != ENOENT) cleanfail = 1;
|
||||
if (unlink(stemc) != 0 && errno != ENOENT) cleanfail = 1;
|
||||
if (unlink(stemw) != 0 && errno != ENOENT) cleanfail = 1;
|
||||
snprintf(cmd, sizeof cmd, "rm -rf %s", scratchc);
|
||||
if (runwait(cmd) != 0) cleanfail = 1;
|
||||
snprintf(cmd, sizeof cmd, "rm -rf %s", scratchw);
|
||||
if (runwait(cmd) != 0) cleanfail = 1;
|
||||
if (rmdir(dir) != 0) cleanfail = 1;
|
||||
if (cleanfail) {
|
||||
fprintf(stderr, "911 FAIL: byteid workspace cleanup failed\n");
|
||||
rc = 1;
|
||||
}
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
const char *bin = absbin();
|
||||
if (!bin) { fprintf(stderr, "911 FAIL: getcwd\n"); return 1; }
|
||||
|
||||
if (record_continue(bin) != 0) return 1;
|
||||
if (all_pass(bin) != 0) return 1;
|
||||
if (byteid(bin) != 0) return 1;
|
||||
|
||||
printf("@test record-and-continue: 3 fault classes recorded + run "
|
||||
"proceeds + exact counts + failure exit clamps to 1 + all-pass "
|
||||
"exit 0 + cs/ww byte-id (#17)\n");
|
||||
return 0;
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
// @test fixture for #17 record-and-continue: a mix of one passing test,
|
||||
// then the three runtime fault classes the lib/test fork+wait4 runner
|
||||
// must each catch and PROCEED past (failed assert → SIGABRT, nil deref →
|
||||
// SIGSEGV, divide-by-zero → SIGFPE), then a final passing test to prove
|
||||
// the run reaches the tail after every failure. Driver:
|
||||
// test/wcc/911_attest_record.c. The runner reports in source order, so
|
||||
// the expected per-test verdicts are pinned positionally there.
|
||||
|
||||
package data;
|
||||
|
||||
@test fn rec_pass_a() void = {
|
||||
assert(1 + 1 == 2);
|
||||
};
|
||||
|
||||
@test fn rec_assert() void = {
|
||||
assert(1 == 2);
|
||||
};
|
||||
|
||||
@test fn rec_segv() void = {
|
||||
let p: *i32 = nil: *i32;
|
||||
*p = 7i32;
|
||||
};
|
||||
|
||||
@test fn rec_div0() void = {
|
||||
let z: i32 = 0;
|
||||
let _: i32 = 1 / z;
|
||||
};
|
||||
|
||||
@test fn rec_pass_b() void = {
|
||||
assert(true);
|
||||
};
|
||||
Reference in New Issue
Block a user