Artifact f996fd32eadc08b687a56bf2fed89a343cc65c0871eca3454b8c029cc8e09e58:
- File
test/qualification/replay.c
— part of check-in
[11f47eadde]
at
2026-11-18 11:58:22
on branch trunk
— Record S0/S1 qualification groundwork before product code
Contract maps and pinned Pi reference, local C qualification fixtures, MC/DC and Fil-C remote lifecycle tooling, and the context transaction substrate probe. No product harness code yet. (user: dmestas, size: 1985) [annotate] [blame] [check-ins using]
#include <stdio.h> #include <stdlib.h> #include <string.h> #include "qual.h" static int g_checked; static int replay_one(const char *path, const uint8_t *buf, size_t len) { q_op ops[Q_MAX_OPS]; size_t n = q_parse_ops(buf, len, ops, Q_MAX_OPS); q_ctx *c; q_trace t; const q_record *r; const q_effect *e; size_t nr, ne; char detail[160]; q_verdict v; if (n == SIZE_MAX) { /* Unparseable input is an expected refusal, not a crash. */ return 1; } if (n == 0) { return 1; } c = q_new(1); if (c == NULL) { fprintf(stderr, "replay: %s: allocation failed\n", path); return 0; } q_run_ops(c, ops, n, &t); r = q_records(c, &nr); e = q_effects(c, &ne); detail[0] = '\0'; v = q_oracle_check(ops, n, &t, r, nr, e, ne, detail, sizeof detail); q_free(c); if (v != Q_OK) { fprintf(stderr, "replay: %s: %s (%s)\n", path, q_verdict_name(v), detail); return 0; } g_checked++; return 1; } static int read_file(const char *path, uint8_t *buf, size_t cap, size_t *len) { FILE *f = fopen(path, "rb"); size_t got; if (f == NULL) { return 0; } got = fread(buf, 1, cap, f); if (ferror(f)) { fclose(f); return 0; } fclose(f); *len = got; return got <= cap; } int main(int argc, char **argv) { uint8_t buf[4096]; int files = 0; if (argc < 2) { fprintf(stderr, "usage: %s CORPUS_FILE...\n", argv[0]); return 2; } for (int i = 1; i < argc; i++) { size_t len = 0; if (!read_file(argv[i], buf, sizeof buf, &len)) { fprintf(stderr, "replay: %s: read failure or oversize\n", argv[i]); return 1; } if (!replay_one(argv[i], buf, len)) { return 1; } files++; } printf("replay: %d files, %d sequences checked\n", files, g_checked); return 0; }