Artifact d96368e45f2db8686016c14010c05c4edc90f1e7aacf8066122fd12dae40c53f:
- File
test/fuzz_need.c
— part of check-in
[3598f9d78d]
at
2026-11-14 13:15:53
on branch trunk
— Phase 8a: needs are checked, listed, and shown until they are done
A need is a step a harness must do for itself, such as registering a slot in its own settings. suit never edits those settings; it says what is needed and can tell when it has been done.
The done test has two forms and nothing else: PATH exists, and PATH contains "TEXT". suit needs lists every need as done, not done or cannot tell, and changes nothing. suit need HARNESS NAME prints the prompt's exact bytes so it can be handed to the harness.
After each apply the attention file holds one item for each need not done and none for those that are. Other kinds of item are left alone and keep their order, and nothing is written when nothing changed. If that update fails, apply writes no stamp, so the next run tries again. A bad need stops apply before it places anything. suit off removes the items.
suit-run is untouched and the speed budget still passes.
An eighth fuzz target covers the done-test parser.
1355 unit checks, 479 shell cases, 669 store cases, 745 placement cases and 378 project cases, under clang, under gcc 16, with no user name set, and under a strict umask, in one run of make gate (34 minutes). 100% coverage in all 24 source files. No suite has fewer cases than at the last check-in. (user: dmestas, size: 1460) [annotate] [blame] [check-ins using]
// Fuzz target for the done test: a text that parses gives an absolute path and, // for contains, a TEXT that is not empty and sits inside the input; and the // test written out again in its own form parses to the same test. #include "need.h" #include "platform.h" #include <stdint.h> #include <stdio.h> #include <string.h> int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size); constexpr size_t FUZZ_MAX = 8192; int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { if (size > FUZZ_MAX) return 0; static char in[FUZZ_MAX + 1]; static char again[FUZZ_MAX + DONE_PATH_MAX + 32]; memcpy(in, data, size); in[size] = '\0'; char why[DONE_WHY_MAX]; DoneTest a; if (!done_parse(&a, "/home/u", in, why, sizeof why)) { ensure(why[0] != '\0'); return 0; } ensure(a.path[0] == '/'); if (a.kind == DONE_EXISTS) { snprintf(again, sizeof again, "%s exists", a.path); } else { ensure(a.text_len > 0 && a.text >= in && a.text + a.text_len <= in + size); snprintf(again, sizeof again, "%s contains \"%.*s\"", a.path, (int)a.text_len, a.text); } [[maybe_unused]] DoneTest b; [[maybe_unused]] bool reparsed = done_parse(&b, "", again, why, sizeof why); ensure(reparsed); ensure(a.kind == b.kind && strcmp(a.path, b.path) == 0 && a.text_len == b.text_len); ensure(a.kind == DONE_EXISTS || memcmp(a.text, b.text, a.text_len) == 0); return 0; }