BF2.US bf2-rsdeveloper wiki Parity Discord bf2.us
On this page

Sweeps, the regression wall and soak runs

BF22142Heroes

A hand-written scenario checks one thing somebody thought of. Three kinds of check go beyond that. A sweep is generated from the game's own data and covers a whole class of things at once. The wall keeps every fault that was ever found from coming back. A soak looks for what only shows after many rounds. All three are scenarios underneath and obey the same rules: 127.0.0.1, the port's own servers, every process stopped within five minutes.

The file, the assertions and the invariants: scenarios.

Where a check comes from a scenario somebody wrote it one behaviour, exactly a sweep generated from the game's own data: a whole class the wall one brick for each fault once found: it stays fixed a soak a series over many rounds: growth after warm-up all four are scenario runs: real programs, 127.0.0.1, every process stopped, the same invariants tools/scenarios/gen/*.py, suites.toml, soak.py, invariants.py
Four ways a check comes to exist, and what each is good at.

Sweeps: generated from the data#

A sweep's generator reads the game's templates and levels from your install and writes the scenarios, the injected input and the expectations. Nobody types "the M16 has 30 rounds": the generator reads the magazine size from the template, and where the template is silent it takes the original constructor's default from a table that was read out of the binary. Generated files are committed; to change one you change the generator.

Every kit, item and action#

tools/scenarios/gen/actions.py. For each kit of a level's two teams and each item in it, the cases a player can perform: select it, fire, fire until empty, reload, the alternate fire, zoom, throw, plant and detonate. Each case carries what must happen (so many shots in so many ticks, the magazine count after the reload, a detonation) and the citation of the original function that makes it so; a case that cannot apply says why not. A client script called a tour plays the plan with injected keys.

The same matrix runs against the original server too, side by side, as the player-action differential: 519 cases of a kit, an item and an action (test rigs).

Every vehicle, seat and weapon#

tools/scenarios/gen/vehicles.py reads a level's spawners (which template for which team, where) and the vehicle templates: the seats are the player control objects in tree order, a weapon belongs to its nearest seat above it, its key is the template's fire input. One scenario per vehicle: a player of the owning team is placed beside it, walks to the nearest entry point, takes each seat and fires each weapon.

Every level, mode and size#

tools/scenarios/gen/maps.py lists every combination the level descriptors name: 108 for Battlefield 2 with its boosters and Special Forces, 85 of conquest and 23 of co-op. For each it reads the layer's objects and writes a scenario that loads it and checks what a level must have: control points, spawn points for both teams, spawners whose templates exist. Variants run the same list as a differential against the original server, as co-op rounds with bots, and as co-op rounds played to their end on both.

A sweep finds the fault nobody thought to look for, of the kind: an item of a kit that cannot be selected, a level size whose spawn group is empty.

HUD, menus and pictures#

The same idea elsewhere: a sweep over every HUD screen and menu page, and a picture sweep that replays a client's frames on a reference Direct3D 9 device and compares the pictures pixel by pixel (shadows and lighting).

The regression wall#

Every fault found in play that a scenario can express gets a scenario that fails if the fault returns. The scenario's description carries the row of the fault's record, and an open fault's scenario stands on the list of known failures with that row. Some of the wall's bricks, to show the kind:

The faultThe scenario checks
bots stop fighting after a whileeight co-op bots on a fast-forwarded server: kills in every bucket of game time, on both teams
an enemy's vehicle could be enteredtimed use presses at an occupied vehicle: no entry by the other team
flagpoles vanish up closespots from 100 m to 2 m from a pole: the pole is listed and drawn at each
the C4 detonator does not show in first persona per-frame trace: charge planted, right click, the detonator drawn within 15 frames, left click, the vehicle damaged
the capture bar does not movethe HUD's two capture variables drain and fill strictly between 0 and 1
a tank's barrel does not follow the mousethe drawn barrel's pitch within 2 degrees of the camera's over a sweep of 27
the rotor blur of somebody else's helicopter stands stilla second client 22 m away sees the disc turn
a kit cannot be picked upa bot's kit drop and the human's pickup events

The wall runs in two halves on a schedule and whole in the full suite. It is the project's memory: a fix without a brick tends to be undone by the next refactor.

Fast-forward#

A bot round of 30 game minutes cannot run in a 5-minute process at real time. The port's server has a switch (its own, not the original's) that skips the frame's sleep and gives every frame the fixed 1/30 s step: ticks run back to back with the same per-tick results. An idle server runs about 10 times real time, eight fighting bots about 7 times, sixteen about 4. Clients on such a server see time fly, so fast-forward is for bot-only runs.

Soak#

Slow faults are leaks, growing stutter and rotations that fail on the seventh level. A soak scenario measures a series over one process and judges its growth after warm-up, per level or round or minute:

ScenarioWhat runsJudged
co-op rotation16 bots, fast-forward, three levels rotating with 60 s rounds: six or seven level loadsthe server's heap after warm-up (at most +2 MB), objects, ghosts, templates
conquest churn200 headless joins and leaves, about seven connected at a time; then the same on the original serverthe heap, ghost records and connections; both servers' memory side by side
demo roundsco-op with automatic recording, alternating levelsprivate memory and handles at each round's end against the same level's earlier rounds
client co-opan off-screen client through a round, a map change, a disconnect and rejoin, another map changethe client's memory and live heap
client reloadfour loads of the same level in one client processmemory growth per load

Every scenario, soak or not, samples every process it started every five seconds: memory, handles, threads. Because that works on the original server too, its memory over the same rotation is the yardstick: the port may not grow where the original does not.

Which to write#

You haveWrite
a new rule, a new item, a new vehicle partnothing by hand: regenerate the sweep and look at what turned red
a fault a player reporteda brick for the wall, red before your fix
a function you porteda test from its address, an oracle case if it is pure: a scenario proves wiring, not arithmetic
a suspicion that something growsa soak series and a limit

How it is tested#

A sweep is a reading, and this page says so of each: a row's verdict is what a person found in the original's text beside the port's. A row becomes a proof when its test stands; the count of those is on parity, and per feature on the feature checklists. The soak and the wall are runs, judged by their own invariants (no panic, no hang).

In the code#

WhatWhere
the generatorstools/scenarios/gen/ (actions.py, vehicles.py, maps.py, coop_rounds.py)
the constructor defaults they fall back onre/data/template_properties.tsv
the tour script of the clientcrates/bf2-client/app/src/script/tour.rs
soak series and limitstools/scenarios/soak.py, tools/scenarios/test_soak.py
suites and known failurestools/scenarios/suites.toml

Notes: notes/tracks/scenarios.md ("Data-driven sweeps", "Regression wall", "Soak", "Fast-forward"), notes/tracks/validation-strategy.md.

Source: docs/dev/testing/sweeps-and-soak.md · built from bf2-rs e3b4f05 · part of the Battlefield 2 / 2142 / Heroes reimplementation. Not affiliated with EA or DICE.