Artifact ad57f10e7f021f25df2f426efdb15b8078fb5e70bc45c6fa1ab5aca391f4db3c:
- File
test/fuzz_remote.c
— part of check-in
[0c65a50c7f]
at
2026-11-14 00:48:47
on branch trunk
— Phase 7c-1: a wardrobe can be cloned onto a second machine, and one call tends them all
suit clone NAME URL makes a wardrobe on this machine from a remote. It clones into a temporary file, renames it into place, opens the store at the tip of trunk and records the remote last. A failure at any step removes what it made: no partial repository file, no store folder, no remotes line. A name already in use is refused with exit 20 and nothing is overwritten. A login saved beforehand is used, so a private wardrobe can be cloned.
suit tend with no name tends every wardrobe in name order. One wardrobe's failure does not stop the others; the exit code is the highest any of them returned, with one line for each that did not end clean.
After three failed syncs in a row the attention file names the wardrobe and the host. A sync that reaches the remote clears the count and the line.
A limit: libfossil's clone builds its own context, so fault injection cannot reach the system calls made inside the clone. The tests cover every step suit takes around it, and a bad remote covers a failure inside it.
One existing case changed: tend-usage expected suit tend with no name to be an error, which is now the behaviour above. It tests suit tend with two names instead.
1204 unit checks, 227 shell cases, 669 store cases, 612 placement cases and 378 project cases, under clang, under gcc 16, with no user name set, and under a strict umask. 100% coverage in all 22 source files. No suite has fewer cases than at the last check-in. (user: dmestas, size: 2162) [annotate] [blame] [check-ins using]
// Fuzz target for the remotes and credentials parsers: whatever parses must // write back out and parse again to the same entries, and a failed parse // leaves nothing behind. #include "platform.h" #include "remote.h" #include <stdint.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> static Remotes r1; static Remotes r2; static Creds c1; static Creds c2; static char rpath[4096 + 32]; static char cpath[4096 + 32]; static char spath[4096 + 32]; int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size); int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { if (rpath[0] == '\0') { const char *tmp = getenv("TMPDIR"); char dir[4096]; snprintf(dir, sizeof dir, "%s/suit-fuzz-remote.XXXXXX", tmp != nullptr ? tmp : "/tmp"); if (mkdtemp(dir) == nullptr) abort(); snprintf(rpath, sizeof rpath, "%s/remotes", dir); snprintf(cpath, sizeof cpath, "%s/credentials", dir); snprintf(spath, sizeof spath, "%s/wd.syncfail", dir); } RemoteError e; if (!remotes_parse(&r1, (const char *)data, size, &e)) { ensure(e.msg[0] != '\0' && r1.n == 0); } else { [[maybe_unused]] int written = remotes_write(&r1, rpath); ensure(written == 0); [[maybe_unused]] bool again = remotes_load(&r2, rpath, &e); ensure(again && r2.n == r1.n); } if (!creds_parse(&c1, (const char *)data, size, &e)) { ensure(e.msg[0] != '\0' && c1.n == 0); } else { [[maybe_unused]] int written = creds_write(&c1, cpath); ensure(written == 0); [[maybe_unused]] bool again = creds_load(&c2, cpath, &e); ensure(again && c2.n == c1.n); } unsigned n1; unsigned n2; if (!syncfail_parse((const char *)data, size, &n1)) { ensure(n1 == 0); } else { [[maybe_unused]] int written = syncfail_write(spath, n1); ensure(written == 0); [[maybe_unused]] bool again = syncfail_load(spath, &n2, &e); ensure(again && n2 == n1 && n1 >= 1 && n1 <= SYNC_FAILS_MAX); } secret_wipe(&c1, sizeof c1); secret_wipe(&c2, sizeof c2); return 0; }