First unit test suites: pure-logic modules with high regression risk #1245

Open
opened 2026-10-28 20:33:40 +00:00 by sky_line · 0 comments
Owner

Part of #1243.

Scope. Prerequisite: a viewer-free home for testable logic. Many of these modules live in newview behind llviewerprecompiledheaders.h and viewer globals, so they cannot be linked into a small test executable. Create indra/slcore (static library, depends only on llcommon, llmath, llxml, llinventory, llcachestore) and move or split the pure parts into it, leaving thin forwarders in newview. This is the same refactor the fuzzing README proposes for the SLBridge line parser and the weather tag parser. Suites, in priority order (each is its own sub-task and its own test executable):

  1. Weather maths: the rate ladder, occlusion helpers, SLWeather mixing / quantisation; SLWeatherRegion::parseTag / formatTag / tagRoundTrips / editDescription (move to slweathertag.cpp; round-trip property tests plus the failure corpus from fuzzing).
  2. Run-off flow (snow / rain run-off, wet-surface accumulation): table-driven cases for monotonicity, conservation and clamping; include the "never NaN, never negative" invariants.
  3. Cache / segment store (llcachestore, slcachestore, slassetcachestore, migrations): already has integration tests (llcachestore, llfilesystemstore, slgputexmigrate, slj2cmigrate, slassetmigrate); port those and add: crash-in-the-middle recovery, byte-budget eviction (feedback rule "every cache frees or has a budget"), corrupted record skipped not fatal.
  4. Inventory safety helpers (no server-side loss, no blind retries): the decision helpers that gate delete / purge / move, and LLInventoryItem::importLegacyStream round trips (use the fuzz_inventory corpus as extra fixtures).
  5. Key-binding migration: the key_bindings v2 to v3 upgrade (llkeybind, the settings migration code): golden input files for v2, v3, partially corrupt, and user-edited, asserting no binding is lost or duplicated.
  6. SLBridge parser: SLBridgeLine::parse (prefix, type, | fields, hello handshake fields, over-long and malformed lines) once extracted from processOwnerSay; token-bucket route budget as a pure function.
  7. LLSD round trips: XML / notation / binary parse then format then parse for a corpus of values (edge numbers, empty / nested containers, binary, dates); the existing llcommon llsdserialize_test is the starting point.
  8. Settings presets (#1226): once the feature exists: save / load / apply / migrate, unknown keys preserved, version bump.

Acceptance criteria.

  • indra/slcore exists, builds under GCC and clang-cl, has no dependency on newview, GL or Vulkan.
  • Each suite above has at least 15 meaningful cases (not smoke tests), each case names the bug or invariant it guards; every past regression we can name gets a test.
  • Whole default suite stays under the 5 s budget; any case over 200 ms is labelled slow and moved out of the default run.
  • Each suite is demonstrated to fail on a deliberately reintroduced bug (mutation check done once per suite, noted in the PR).

Effort. Large: 1 to 2 weeks for slcore extraction plus suites 1 to 4, about 1 week more for 5 to 8; suites 7 and 8 are small. Do 1, 5 and 7 first (highest risk per line, lowest extraction cost).

Part of #1243. **Scope.** Prerequisite: a viewer-free home for testable logic. Many of these modules live in `newview` behind `llviewerprecompiledheaders.h` and viewer globals, so they cannot be linked into a small test executable. Create `indra/slcore` (static library, depends only on llcommon, llmath, llxml, llinventory, llcachestore) and move or split the pure parts into it, leaving thin forwarders in newview. This is the same refactor the fuzzing README proposes for the SLBridge line parser and the weather tag parser. Suites, in priority order (each is its own sub-task and its own test executable): 1. **Weather maths**: the rate ladder, occlusion helpers, `SLWeather` mixing / quantisation; `SLWeatherRegion::parseTag` / `formatTag` / `tagRoundTrips` / `editDescription` (move to `slweathertag.cpp`; round-trip property tests plus the failure corpus from fuzzing). 2. **Run-off flow** (snow / rain run-off, wet-surface accumulation): table-driven cases for monotonicity, conservation and clamping; include the "never NaN, never negative" invariants. 3. **Cache / segment store** (`llcachestore`, `slcachestore`, `slassetcachestore`, migrations): already has integration tests (`llcachestore`, `llfilesystemstore`, `slgputexmigrate`, `slj2cmigrate`, `slassetmigrate`); port those and add: crash-in-the-middle recovery, byte-budget eviction (feedback rule "every cache frees or has a budget"), corrupted record skipped not fatal. 4. **Inventory safety helpers** (no server-side loss, no blind retries): the decision helpers that gate delete / purge / move, and `LLInventoryItem::importLegacyStream` round trips (use the `fuzz_inventory` corpus as extra fixtures). 5. **Key-binding migration**: the key_bindings v2 to v3 upgrade (`llkeybind`, the settings migration code): golden input files for v2, v3, partially corrupt, and user-edited, asserting no binding is lost or duplicated. 6. **SLBridge parser**: `SLBridgeLine::parse` (prefix, type, `|` fields, hello handshake fields, over-long and malformed lines) once extracted from `processOwnerSay`; token-bucket route budget as a pure function. 7. **LLSD round trips**: XML / notation / binary parse then format then parse for a corpus of values (edge numbers, empty / nested containers, binary, dates); the existing llcommon `llsdserialize_test` is the starting point. 8. **Settings presets (#1226)**: once the feature exists: save / load / apply / migrate, unknown keys preserved, version bump. **Acceptance criteria.** - `indra/slcore` exists, builds under GCC and clang-cl, has no dependency on `newview`, GL or Vulkan. - Each suite above has at least 15 meaningful cases (not smoke tests), each case names the bug or invariant it guards; every past regression we can name gets a test. - Whole default suite stays under the 5 s budget; any case over 200 ms is labelled `slow` and moved out of the default run. - Each suite is demonstrated to fail on a deliberately reintroduced bug (mutation check done once per suite, noted in the PR). **Effort.** Large: 1 to 2 weeks for `slcore` extraction plus suites 1 to 4, about 1 week more for 5 to 8; suites 7 and 8 are small. Do 1, 5 and 7 first (highest risk per line, lowest extraction cost).
sky_line added this to the Slipstream project 2026-10-28 20:33:40 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
sky_line/Slipstream#1245
No description provided.