Commit graph

2 commits

Author SHA1 Message Date
Stephen Dennis
a38e7ab39a test(dbt): FCVT conformance against qemu-derived golden values
580 cases: every float->int convert (W/WU/L/LU) against every static
rounding mode (RNE/RTZ/RDN/RUP/RMM) over 29 inputs -- zeroes of both
signs, values that round in each direction, exact ties in both parities,
quiet and signalling NaNs, both infinities, and the representable values
either side of each type's range boundary.

Deliberately not differential.  The fuzzer next door compares the
interpreter against the DBT, which by construction cannot see anything the
two get wrong in the same way, and both bugs fixed in this branch were of
exactly that kind: both routes truncated instead of rounding, and both
returned 0 for NaN in the unsigned converts.  The fuzzer reported those
runs clean.

So the expected values come from qemu-riscv64 executing the same
instructions, not from anything in this tree.  There is a comment on the
table saying so, because the tempting way to "fix" a failure here is to
paste in what dbt_interp currently returns, and that would throw away the
only independent opinion the test has.

Negative control: against the unfixed interpreter this fails 105 of the
580 -- the rounding cases in every mode but RTZ, the NaN unsigned cases,
and the round-then-range-check boundary at 2147483647.5.

The test runs each case as a real guest program (ADDI/FLD/FCVT/ECALL)
rather than calling the conversion helper, so decode, the rm field and the
range checks are all on the path.  Note the DATA address must fit a signed
12-bit immediate: 0x800 encodes as -2048, every load returns zero, and the
whole table then reads as "the interpreter converts everything to 0" --
which is how the first draft of this test failed.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-07-25 23:18:03 -06:00
Stephen Dennis
2b980576f9 Merge master into refactor/consolidate-dbt-tests; fold in tests/dbt_interp
#1299 landed tests/dbt_interp while this branch was consolidating the
other three islands, so the root Makefile conflicted on all three hunks
(.PHONY, clean, and the test: prerequisite list).

Resolved toward this branch's consolidated `test-dbt`, and folded the
fourth island in rather than leaving a directory this refactor exists to
remove:

  - test_dbt_interp.cpp -> tests/dbt/test_interp.cpp (git mv, history
    follows), matching the test_chain/test_cache naming
  - tests/dbt_interp/{Makefile,.gitignore} removed
  - `interp` target added beside chain/cache/exec, in `all:`, in `test:`,
    and in .gitignore

It needs its own binary for the same reason the other three do: the
driver #includes dbt_interp.cpp to reach file-static mem_check, so it
cannot share a link with `exec`, which compiles that TU normally.

All four run from the one target: chain 48, cache 14, interp 13,
hand-assembled 172, plus both ELF legs.  Full make test green,
smoke 1427/0.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-25 21:35:57 -06:00