fix(v4.0.0): POST leaves nothing, as v3 really does; and what the review of step 6b found
Captain Bob was told that v3 leaves the words POST's cases define in the
dictionary, and ruled that v4 should. That was false: v3's run_test_suite
puts the dictionary back after each word's cases (test_common.c:333,
:365). Shown that, he ruled that POST leaves nothing. The boot now
seals the system, runs POST, and has the node do COLD, whose printing is
not shown; PARITY:V4_SYSTEM is the system as sealed.
A case the node does not come back from ends POST there, named, with how
many were not run: it would have stalled the boot for hours, where the
capsule had ended it. The runner's test of it now uses a word that
really never ends.
hosted-check also requires that RS1 and T{ are unknown after boot, and
boots a program whose POST has failing cases (tests/post_cases_fail.c):
PARITY:FAIL, POST: FAILED, no prompt, none of a case's printing shown.
Comments and documents that still named the POST capsule or its two
hooks are brought up to date; NUCLEUS.md 6.3 says what v3 does, with the
lines, and how the wrong ruling came about.
make -C v4 test, sanitize and hosted-check pass; amd64, aarch64 and
riscv64 boot, POST 538 of 538, word_count=314, dict_hash
0x220ab283a504a3b3 on all six: logs/20261007-112638, -112901, -113220.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
eda6577a53
commit
18adf59091
@@ -0,0 +1,24 @@
|
||||
/* post_cases_fail.c -- a table of cases for the boot to fail on.
|
||||
* docs/v4.0.0/MESH.md step 6b, acceptance 4; v4/Makefile, hosted-check.
|
||||
*
|
||||
* Linked into a hosted program in the place of v4/system/post_cases.c, so
|
||||
* that the boot itself (v4/system/boot.c) is seen to stop on a failing
|
||||
* case, to keep what a case prints off the console, and to hold no more of
|
||||
* it than it has room for. It is not a test program of its own: the suite
|
||||
* does not build it.
|
||||
*/
|
||||
#include "v4/post.h"
|
||||
|
||||
static const char *const l_right[] = { "5 DUP . . CR" };
|
||||
static const char *const l_wrong[] = { "5 DUP . . CR" };
|
||||
static const char *const l_many[] = { ": MANY 2000 0 DO 81 EMIT LOOP ;", "MANY" };
|
||||
static const char *const l_two[] = { "65 EMIT", "66 EMIT" };
|
||||
|
||||
const v4_post_case v4_post_cases[] = {
|
||||
{ "fail.right", l_right, 1u, V4_POST_STACK, 0, 0u, "5 5 \012", 5u },
|
||||
{ "fail.wrong", l_wrong, 1u, V4_POST_STACK, 0, 0u, "5 6 \012", 5u },
|
||||
{ "fail.many", l_many, 2u, V4_POST_STACK, 0, 0u, "Q", 1u },
|
||||
{ "fail.twoline", l_two, 2u, V4_POST_STACK, 0, 0u, "AB", 2u },
|
||||
};
|
||||
|
||||
const unsigned v4_post_case_count = 4u;
|
||||
+23
-15
@@ -361,10 +361,11 @@ static const char *say(const char *input)
|
||||
}
|
||||
/* POST's RUNNER (v4/system/post.c), with these tests as its host: a line is
|
||||
* sent to the node as the console sends one, and what the node prints is
|
||||
* handed back and not shown. `post_lost` is the text of a line that is
|
||||
* never to come back, and `post_state_fails` makes the line that sets the
|
||||
* state end in an error; `post_said` is what the runner printed. */
|
||||
static const char *post_lost;
|
||||
* handed back and not shown. `post_step_limit` is how long a line may
|
||||
* take before the node is given up on, and `post_state_fails` makes the
|
||||
* line that sets the state end in an error; `post_said` is what the runner
|
||||
* printed. */
|
||||
static long post_step_limit = 40000000;
|
||||
static int post_state_fails;
|
||||
static char post_said[4096];
|
||||
static unsigned post_said_len;
|
||||
@@ -373,12 +374,11 @@ static int post_line(void *self, const char *text, unsigned text_len, char *o, u
|
||||
int ended;
|
||||
(void)self;
|
||||
*len = 0;
|
||||
if (post_lost && strlen(post_lost) == text_len && memcmp(post_lost, text, text_len) == 0) return -1;
|
||||
if (post_state_fails && text_len == 25 && memcmp(text, "DECIMAL FORTH DEFINITIONS", 25) == 0) text = "NOSUCHWORD-FOR-STATE ";
|
||||
if (!v4_message_text(&to_node, 0, 1, V4_MSG_TEXT, text, text_len)) return -1;
|
||||
to_sent = 0; from_node.count = 0;
|
||||
shown_len = 0; shown_dropped = 0;
|
||||
ended = run_line(40000000);
|
||||
ended = run_line(post_step_limit);
|
||||
if (ended != 1) return -1;
|
||||
*len = shown_dropped ? (unsigned)sizeof shown + 1u : shown_len;
|
||||
memcpy(o, shown, shown_len < cap ? shown_len : cap);
|
||||
@@ -1259,22 +1259,30 @@ int main(void)
|
||||
CHECK(post_one("many", "MANY", 0, V4_POST_STACK, 0, 0, big) == 0 && strstr(post_said, "POST FAIL: many ") != NULL, "a case that prints more than the runner keeps fails, by name");
|
||||
CHECK(post_one("after.many", "1 2 +", 0, V4_POST_STACK, three, 1, "") == 1, "and the next case is judged as usual");
|
||||
|
||||
/* a line that never comes back */
|
||||
post_lost = "LOST-LINE";
|
||||
/* output on more than one line of a case */
|
||||
CHECK(post_one("two.out", "65 EMIT", "66 EMIT", V4_POST_STACK, 0, 0, "AB") == 1 && post_one("two.out2", "65 EMIT", "66 EMIT", V4_POST_STACK, 0, 0, "AA") == 0,
|
||||
"what a case prints on its second line follows what it printed on its first");
|
||||
|
||||
/* a case the node does not come back from: POST stops there */
|
||||
CHECK(is(say(": SPIN BEGIN 0 UNTIL ;\n"), " ok\nok> "), "a word that never ends");
|
||||
{
|
||||
static const char *const la[] = { "1 2 +" }, *const lb[] = { "LOST-LINE" }, *const lc[] = { "65 EMIT" };
|
||||
static const char *const la[] = { "1 2 +" }, *const lb[] = { "SPIN" }, *const lc[] = { "65 EMIT" };
|
||||
static const v4_post_case three_cases[] = {
|
||||
{ "first", la, 1u, V4_POST_STACK, three, 1u, "", 0u },
|
||||
{ "lost", lb, 1u, V4_POST_STACK, 0, 0u, "", 0u },
|
||||
{ "last", lc, 1u, V4_POST_STACK, 0, 0u, "A", 1u },
|
||||
{ "spins", lb, 1u, V4_POST_STACK, 0, 0u, "", 0u },
|
||||
{ "never.run", lc, 1u, V4_POST_STACK, 0, 0u, "A", 1u },
|
||||
};
|
||||
v4_post_tally t;
|
||||
post_said_len = 0; post_said[0] = 0;
|
||||
CHECK(v4_post_run(&post_host, three_cases, 3, &t) == 0 && t.tests == 3 && t.pass == 2 && t.fail == 1
|
||||
&& strstr(post_said, "POST FAIL: lost ") != NULL && strstr(post_said, "PARITY:V4_POST tests=3 pass=2 fail=1\n") != NULL,
|
||||
"a line that does not come back fails its case; the others are still judged, and the run is not a pass: \"%s\"", post_said);
|
||||
post_step_limit = 2000000;
|
||||
CHECK(v4_post_run(&post_host, three_cases, 3, &t) == 0 && t.tests == 2 && t.pass == 1 && t.fail == 1,
|
||||
"the run is not a pass, and the case after it is not run: %u run, %u passed, %u failed", t.tests, t.pass, t.fail);
|
||||
CHECK(strstr(post_said, "POST FAIL: spins ") != NULL && strstr(post_said, "POST: the node did not come back from spins; 1 not run\n") != NULL
|
||||
&& strstr(post_said, "never.run") == NULL && strstr(post_said, "PARITY:V4_POST tests=2 pass=1 fail=1\n") != NULL,
|
||||
"it is named as the case the node did not come back from, with how many were not run: \"%s\"", post_said);
|
||||
post_step_limit = 40000000;
|
||||
}
|
||||
post_lost = 0;
|
||||
boot(); /* the node was left spinning */
|
||||
}
|
||||
|
||||
/* ---- nothing of POST is on the node (NUCLEUS.md 6.3) ---- */
|
||||
|
||||
@@ -344,7 +344,7 @@ int main(void)
|
||||
printf("v4 unit tests: V4_CELL_BITS=%d, V4_NODE_WORDS=%u\n", V4_CELL_BITS, (unsigned)V4_NODE_WORDS);
|
||||
if (V4_CELL_BITS != 64) {
|
||||
/* The capsules the unit is built from are the 64-bit products': the
|
||||
* expected results in post79.4th are v3's, on 64-bit cells, and the
|
||||
* expected results in POST's table are v3's, on 64-bit cells, and the
|
||||
* nucleus capsule is nucleus-64. POST has never been run on 32-bit
|
||||
* cells (docs/v4.0.0/MESH.md, step 5). */
|
||||
printf(" not run at this width: the capsules are the 64-bit products'\n");
|
||||
@@ -400,16 +400,30 @@ int main(void)
|
||||
}
|
||||
CHECK(strcmp(tell(10, "NODE-ME ."), "0 ") == 0 && refused == 0, "it asks where it is, and is answered");
|
||||
CHECK(load(10, "forth79.4th") == 0, "it takes in FORTH-79");
|
||||
CHECK(told(10, "(SEAL)"), "the nucleus and FORTH-79 are the system POST is run on");
|
||||
{
|
||||
static v4_cell before[V4_NODE_WORDS];
|
||||
v4_post_host host;
|
||||
v4_post_tally tally;
|
||||
host.self = 0; host.n = node_numbered(10); host.line = post_line; host.say = post_say;
|
||||
v4_node *hera = node_numbered(10);
|
||||
v4_cell here = hera->mem[DP] / 4, k, changed = 0, first = -1;
|
||||
uint64_t hash = v4_image_dict_hash(hera, &im);
|
||||
memcpy(before, hera->mem, sizeof before);
|
||||
host.self = 0; host.n = hera; host.line = post_line; host.say = post_say;
|
||||
CHECK(v4_post_run(&host, v4_post_cases, v4_post_case_count, &tally) && tally.tests == 538 && tally.pass == 538 && tally.fail == 0
|
||||
&& strstr(post_said, "PARITY:V4_POST tests=538 pass=538 fail=0\n") != NULL && strstr(post_said, "POST FAIL") == NULL,
|
||||
"and passes POST, which the kernel runs on her: %u of %u, %u failed; \"%s\"", tally.pass, tally.tests, tally.fail, post_said);
|
||||
CHECK(strcmp(tell(10, "RS1"), "42 42 \n") == 0, "while POST runs, what its cases define is on her: \"%s\"", printed);
|
||||
CHECK(strstr(tell(10, "COLD"), "Cold Start") != NULL, "the kernel puts her back to the system as it was sealed");
|
||||
CHECK(hera->mem[DP] == before[DP] && hera->mem[LATEST] == before[LATEST], "HERE and LATEST are where they were before POST");
|
||||
for (k = 0; k < here; k++) if (hera->mem[k] != before[k]) { if (first < 0) first = k; changed++; }
|
||||
/* What differs is the TTL in the entry of each word POST had interpreted: a count of uses left before
|
||||
* the word's access is checked again, which every use counts down (compile.v4, (ACL?)), as in v3. */
|
||||
printf(" after POST and COLD: %ld of the %ld cells below HERE differ from before POST (the first at %ld); dict_hash %s\n",
|
||||
(long)changed, (long)here, (long)first, v4_image_dict_hash(hera, &im) == hash ? "the same" : "differs");
|
||||
}
|
||||
CHECK(strstr(tell(10, "T{"), "UNKNOWN WORD") != NULL, "nothing of POST's harness is on her: \"%s\"", printed);
|
||||
CHECK(strcmp(tell(10, "RS1"), "42 42 \n") == 0, "what POST's cases defined is: \"%s\"", printed);
|
||||
CHECK(strstr(tell(10, "RS1"), "UNKNOWN WORD") != NULL && strstr(tell(10, "ZERO"), "UNKNOWN WORD") != NULL, "nor anything POST's cases defined: POST leaves nothing, as in v3: \"%s\"", printed);
|
||||
CHECK(load(10, "hera.4th") == 0, "and its own capsule, which makes it Hera");
|
||||
CHECK(told(10, "(SEAL)"), "that is the system it comes back to");
|
||||
|
||||
@@ -423,7 +437,6 @@ int main(void)
|
||||
CHECK(post_passed[10] == 0 && post_passed[11] == 0 && post_passed[12] == 0 && post_passed[13] == 0 && post_passed[14] == 0 && post_other == 0,
|
||||
"a node she births is not POSTed, and no node prints a POST tally: POST is the kernel's, once, on Hera: %u %u %u %u %u, %u failed",
|
||||
post_passed[10], post_passed[11], post_passed[12], post_passed[13], post_passed[14], post_other);
|
||||
CHECK(strstr(tell(10, "COLD"), "Cold Start") != NULL && strcmp(tell(10, "RS1"), "42 42 \n") == 0, "COLD on Hera comes back to a system that has what POST's cases defined: \"%s\"", printed);
|
||||
CHECK(parity_count == 4 && parity_number[0] == 11 && parity_number[1] == 12 && parity_number[2] == 13 && parity_number[3] == 14, "the parity of each was recorded: %u", parity_count);
|
||||
CHECK(parity_hash[0] == parity_hash[1] && parity_hash[1] == parity_hash[2] && parity_hash[2] == parity_hash[3],
|
||||
"and their dictionary hashes are the same: %016llx %016llx %016llx %016llx",
|
||||
|
||||
Reference in New Issue
Block a user