tests: cover x2w_root_constants bounds, storage, and truncation #3861
No reviewers
Labels
No labels
accessibility
awaiting author
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
priority: P0
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/R0Y00--Xbox2Windows!3861
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3859"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@Ammmae0x on GitHub · 2026-12-02 14:31 UTC · original
Ammmae0x:tests/root-constant-store-unit→main· +1103 −0 · 5 files · 2 commits · merged 2026-12-02 15:32 UTCRefs #1149
Portable C++17 unit and header-mutation tests for
x2w_root_constants::Store(src/startup_stubs/root_constant_store.h), matchingtests/cmake/logical_view_table_unit.cmake. The source is unchanged; only 5 new files are added (+1103/-0), and the existingtests/startup_root_constant_store.cppcoverage is untouched. The new check uses the disjointroot_constant_store_unitprefix so test names do not collide.What landed
tests/root_constant_store_unit_check.cpp— 10 cases, header-only againstsrc, no device, no loader, no title data. Every shared constant isstatic constexpr.tests/cmake/root_constant_store_unit.cmake— one CTest test per case plusroot_constant_store_unit_all, and 6WILL_FAIL TRUEcontrols (BEFORE PRIVATEmutated header copies, 1:1 with the meta check).tests/root_constant_store_unit_meta_check.py— audits the contract, compiles and runs the real C++ check and every mutation natively withg++ -std=c++17 -Wall -Wextra -Wpedantic -Werror(orclwith/W4).tests/checks/python-linux/root_constant_store_unit.txt— lists exactly the meta check.docs/experiments/root-constant-store-unit.md— cases, controls, and verification.Cases
constants:parameter_count == 16andwords_per_parameter == 8;stored,truncatedanddroppedare distinct; a default store holds no words and no bound bits.clear: clearing a fresh store is a no-op; after filling parameters 0, 7 and 15,clear()zeroes every word and forgets every bound bit; a secondclear()is still a no-op, and the store accepts a write afterwards.set_stored: a write that fits is stored whole, reads back at its offsets, and marks exactly the words it wrote; a full row at offset 0 and a write ending exactly at the last word are stored, not truncated; parameter 15 is the last one kept; an overwritingset_onechanges one word without disturbing its neighbours.set_one: a single word at the last offset is stored and bound; writing 0 is still a write (word()reads 0 either way, butis_bound()is true); a single word in parameter 15 and an overwrite read back.bad_param: parameters 16, 17 and the largest unsigned value (the unsigned-1) are dropped for bothsetandset_one, leaving sentinel words in parameters 0 and 15 unchanged;word(-1, 0),word(16, 0)andword(INT_MAX, 0)read 0.bad_offset: offsets 8, 9 and the largest unsigned value (the unsigned-1) are dropped for bothsetandset_one, leaving a sentinel full row unchanged;word(0, 8),word(0, 9)andword(0, -1)read 0; offset 7 is the last valid offset.zero_count: a zero-count write is dropped with valid data, a null source, or at offset 3, and writes nothing; a zero-count range is never bound even after the whole row is written; a range running past the end of the row is never bound.truncation: a write running past the end of the parameter is cut off (offset 6 count 4, offset 0 count 9, offset 7 count 2): the words that fit are kept and bound, nothing spills into the next parameter; a write ending exactly at the last word is stored, not truncated.null_data: a null source is dropped at any count, parameter and offset, writes nothing, and leaves the store intact for a later write.word_oob: every out-of-range read gives 0 on a fresh store and after in-range words are set (-1,16,17,INT_MAXas the parameter;-1,8,9,INT_MAXas the offset;INT_MINfor both); a never-written word also reads 0, and onlyis_bound()tells it from a word written as 0.Mutation controls (6/6 killed)
count_guard_mut: thecount == 0guard inset()is dropped, so an empty write is stored instead of dropped;zero_countthen returnsstoredforset(0, 0, data, 0).trunc_cut_mut: the truncation cut is off by one (count > words - offsetbecomes>=);set_storedthen returnstruncatedfor a full row that exactly fits.bound_mask_mut: the bound mask is not shifted to the write offset;set_storedthen reportsis_bound(3, 2, 4)false afterset(3, 4, data, 2).is_bound_zero_mut: thecount == 0guard inis_bound()is dropped, so an empty range reports bound (its mask is zero);zero_countthen reportsis_bound(0, 0, 0)true.clear_bound_mut:clear()no longer forgets the bound bits;clearthen reportsis_bound(0, 0, 8)true afterclear().result_swap_mut: thestored/truncatedresults are swapped;set_storedthen returnstruncatedfor a write that fits.There is no control for the
data == nullptrguard: dropping it dereferences a null pointer, which CTest reports as a crash rather than an expected failure, so it has no cleanWILL_FAILcontrol;null_datastill exercises that guard directly. There is likewise no control for the parameter / offset guards inset(): weakening one lets a write index past the kept words, which is undefined behaviour rather than a wrong result;bad_paramandbad_offsetstill exercise those guards directly.Verification (Linux, this host,
g++ -std=c++17, baseorigin/main5770f14e)Full configure needs DXC, unavailable on Linux, so the fragment was configured standalone via symlinked
src/testsunderout/root-constant-store-unit-scratch(17 tests: 10 cases + all + 6 controls).Full Linux CI list from
.github/workflows/windows.yml(tools/run_checks_parallel.py --from-dir tests/checks/python-linux ...):all 329 checks passed.git diff --checkclean;git merge-treeexits 0. No mingw on this host, so no Windows compile check; WIN-VERIFY is the arbiter.Windows Verification (
6ec52266911ea1a0f23d340b15759a43fc2fe23f)AI-assisted.
@R0Y00 on GitHub · 2026-12-02 14:56 UTC · original · approved these changes
Reviewed the five-file test-only diff and verified a clean trial merge. On
6ec52266,python3 -B tests/root_constant_store_unit_meta_check.pypassed all 10 original cases on GCC and caught all six mutations. I also built the unmodified CMake fragment in a standalone harness with MSVC 19.51 and ranctest --test-dir build --output-on-failure. All 17 tests passed, including the expected mutation failures. The cases exercise parameter and word bounds, truncation, clear and zero-count behavior. Hosted Windows CI still fails in the sharednative_direct_meshfixture tracked by #3853.