Simplify crossed dispatch and add SMT-derived cases
Drop the redundant begin.offset split in crossedCompleteOvershoot and the rE > 0 guard in closedFormForwardSaturated; both are implied by the call-site invariants. Add an SMT-derived empty-interval case as the smt_cases CTest and as a committed fuzz_readable seed. run-fuzz.sh now loads the read-only seed corpus alongside the writable one. Rename exhaustive to sweep and document that it is exhaustive only over its bounded family of instances.
This commit is contained in:
1 parent
7a41d1f647
commit
a0b68d148b
9 files changed
+72
-50
No files matched your search
+19
-13
@@ -16,10 +16,12 @@ The Lean build is untouched.
|
||||
| `oracle/gen.lean` | Deterministic generator of golden vectors by evaluating the real Lean `closedForm`. |
|
||||
| `tests/golden.cpp` | Checks the literal translation against the Lean golden vectors. |
|
||||
| `tests/diff_corpus.cpp` | Compares literal and fast on the sorted subset of the golden corpus. |
|
||||
| `tests/smt_cases.txt` | Curated readable cases found by SMT-assisted mutation analysis; run by the `smt_cases` CTest. |
|
||||
| `tests/readable_gen.h` | Readable-by-construction instance generator (owns the selector keys and reported keys, with borrowed views into them). |
|
||||
| `tests/extreme.cpp` | Regression test for offsets at the ends of the 32-bit input range. |
|
||||
| `tests/exhaustive.cpp` | Deterministic exhaustive sweep of small readable instances (also the coverage driver). |
|
||||
| `tests/sweep.cpp` | Deterministic sweep over a finite class of small readable instances (also the coverage driver). |
|
||||
| `tests/fuzz_readable.cpp` | libFuzzer differential test: literal vs. fast on readable instances. |
|
||||
| `tests/corpus/readable/` | Committed read-only seeds for `fuzz_readable`. |
|
||||
| `tests/fuzz_raw.cpp` | libFuzzer safety test on arbitrary instances under ASan/UBSan. |
|
||||
| `tests/bench.cpp` | nanobench literal-vs-fast benchmark. |
|
||||
| `run-fuzz.sh` | Rebuilds and runs both fuzzers for a fixed time. |
|
||||
@@ -50,7 +52,7 @@ integer and reject values outside the 32-bit range before narrowing to
|
||||
and `golden_test` compares it with Lean over the whole generated corpus, most of
|
||||
which is not readable. `fast.cpp` is the readable-only implementation:
|
||||
`diff_corpus` filters the corpus to readable cases, and the fuzzers and the
|
||||
exhaustive sweep generate readable instances. The Lean anchor therefore covers
|
||||
finite sweep generate readable instances. The Lean anchor therefore covers
|
||||
`literal` on all inputs, while `fast` is anchored to `literal` on the readable
|
||||
subset.
|
||||
|
||||
@@ -69,7 +71,8 @@ ctest --test-dir build --output-on-failure
|
||||
```
|
||||
|
||||
`golden` and `diff_corpus` read `oracle/golden.txt`; regenerate it first if it
|
||||
is missing (see below).
|
||||
is missing (see below). `smt_cases` reads the committed
|
||||
`tests/smt_cases.txt` and needs no generated input.
|
||||
|
||||
## Golden vectors from Lean
|
||||
|
||||
@@ -98,20 +101,21 @@ cases that satisfy the readable sorting invariant:
|
||||
# extreme: 7574 cases, 0 mismatches
|
||||
```
|
||||
|
||||
`exhaustive_test` enumerates a specific finite class rather than sampling it:
|
||||
every sorted database of at most four stored keys drawn from a fixed universe of
|
||||
`sweep_test` is exhaustive over a specific bounded class rather than sampling
|
||||
it: every sorted database of at most four stored keys drawn from a fixed universe of
|
||||
boundary keys, every selector key (including `⊥` and `⊤`) with offsets in
|
||||
`[-3, 5]`, both traversal directions, and every readable result shape (the
|
||||
complete traversal, each nonempty truncated prefix, or the empty result when the
|
||||
traversal is empty):
|
||||
|
||||
```sh
|
||||
./cpp/build/exhaustive_test
|
||||
# exhaustive: 13565772 cases, 0 mismatches
|
||||
./cpp/build/sweep_test
|
||||
# sweep: 13565772 cases, 0 mismatches
|
||||
```
|
||||
|
||||
It runs in about a second and is also the coverage driver. The class is not all
|
||||
readable inputs; the guarantee is that every instance in this family agrees. In
|
||||
It runs in about a second and is also the coverage driver. It is exhaustive
|
||||
only within those bounds; the class is not all readable inputs, and the
|
||||
guarantee is that every instance in this family agrees. In
|
||||
particular, branch coverage cannot exercise a predicate operand that the
|
||||
implementation no longer contains: the coverage result below describes the code
|
||||
as written, it is not a proof of equivalence with `literal.cpp`.
|
||||
@@ -123,8 +127,8 @@ as written, it is not a proof of equivalence with `literal.cpp`.
|
||||
```
|
||||
|
||||
The script configures a Clang source-based-coverage build, runs
|
||||
`exhaustive_test`, and fails unless `src/fast.cpp` has 100% line and branch
|
||||
coverage. `exhaustive_test` alone covers every region, function, line, and
|
||||
`sweep_test`, and fails unless `src/fast.cpp` has 100% line and branch
|
||||
coverage. `sweep_test` alone covers every region, function, line, and
|
||||
branch side of the summarised implementation:
|
||||
|
||||
```text
|
||||
@@ -149,11 +153,13 @@ translation can still be audited line by line.
|
||||
```sh
|
||||
cd cpp
|
||||
mkdir -p /tmp/cr-corpus/readable /tmp/cr-corpus/raw
|
||||
./build/fuzz_readable -max_total_time=300 /tmp/cr-corpus/readable
|
||||
./build/fuzz_readable -max_total_time=300 /tmp/cr-corpus/readable tests/corpus/readable
|
||||
./build/fuzz_raw -max_total_time=300 /tmp/cr-corpus/raw
|
||||
```
|
||||
|
||||
or simply `./cpp/run-fuzz.sh` (optionally `./cpp/run-fuzz.sh build 600`).
|
||||
`tests/corpus/readable` holds committed seeds; the first directory above is the
|
||||
writable corpus where libFuzzer stores newly discovered units.
|
||||
The CMake fuzz targets compile the implementation sources directly so that the
|
||||
decoder code, not just the harness, is covered by ASan/UBSan.
|
||||
|
||||
@@ -173,7 +179,7 @@ One representative validation run on this machine:
|
||||
| literal vs. Lean golden vectors | 40,000 | 0 mismatches (exact endpoints) |
|
||||
| fast vs. literal on sorted corpus | 18,971 | 0 mismatches |
|
||||
| extreme-offset regression (`extreme_test`) | 7,574 | 0 mismatches |
|
||||
| exhaustive readable sweep (`exhaustive_test`) | 13,565,772 | 0 mismatches |
|
||||
| finite readable sweep (`sweep_test`) | 13,565,772 | 0 mismatches |
|
||||
| readable differential fuzzing (60 s) | 1,182,424 | 0 mismatches |
|
||||
| raw safety fuzzing (60 s) | 1,905,270 | no ASan/UBSan findings |
|
||||
|
||||
|
||||
Reference in new issue
Block a user