101 lines
12 KiB
Python
101 lines
12 KiB
Python
|
|
"""Public synthetic machinery cases; no roster data or source-derived wording."""
|
||
|
|
from collections import Counter
|
||
|
|
|
||
|
|
from suite_contract import encoded
|
||
|
|
|
||
|
|
# Each row specifies different control/measurement machinery, not subsystem labels.
|
||
|
|
MECHANISMS = (
|
||
|
|
("Reset pulse timing", "Stop and restart a hardware watchdog pulse generator", "Measure reset-pin edges with a logic analyzer", "pulse generator and digital capture driver"),
|
||
|
|
("Network loss recovery", "Drop selected datagrams through a network impairment bridge", "Correlate packet captures with retransmission state", "network impairment bridge and packet-capture adapter"),
|
||
|
|
("SPI waveform decoding", "Replay chip-select and clock waveform sequences", "Decode sampled SPI edge ordering and returned words", "SPI waveform synthesizer and edge decoder"),
|
||
|
|
("I2C contention handling", "Hold the I2C data line during competing controller transfers", "Observe bus arbitration loss and recovery pulses", "I2C open-drain bus fault injector"),
|
||
|
|
("CAN arbitration", "Schedule competing CAN frames with controlled identifiers", "Measure arbitration winners and error-frame counters", "CAN bus traffic generator and bus monitor"),
|
||
|
|
("UART framing errors", "Transmit serial bytes with altered stop-bit durations", "Correlate serial framing flags with received characters", "UART timing generator and serial capture adapter"),
|
||
|
|
("USB reconnect enumeration", "Disconnect and reconnect a USB endpoint through a relay", "Capture enumeration transactions and endpoint availability", "USB relay controller and protocol analyzer"),
|
||
|
|
("DMA guard protection", "Issue PCIe DMA transfers spanning mapped guard regions", "Inspect IOMMU faults and memory guard signatures", "PCIe DMA exerciser and IOMMU fault collector"),
|
||
|
|
("GPIO debounce timing", "Apply contact-bounce transitions to an input pin", "Measure accepted event timing against the bounce waveform", "GPIO bounce sequencer and event timestamp recorder"),
|
||
|
|
("ADC transfer accuracy", "Sweep calibrated voltage into an analog converter", "Fit conversion residuals against sampled reference voltages", "precision voltage source and ADC sampling adapter"),
|
||
|
|
("DAC spectral purity", "Command analog waveform output at several frequencies", "Calculate harmonic distortion from oscilloscope samples", "oscilloscope waveform reader and FFT analysis helper"),
|
||
|
|
("Supply transient recovery", "Apply short controlled supply-voltage dips", "Measure rail recovery and brownout indications", "programmable supply transient controller and voltage probes"),
|
||
|
|
("Thermal expansion", "Cycle the enclosure in a thermal chamber", "Measure enclosure dimensions with a calibrated displacement gauge", "thermal chamber controller and displacement gauge reader"),
|
||
|
|
("Acoustic spectrum", "Run the actuator under controlled load in an anechoic fixture", "Compare microphone spectral peaks with the acoustic envelope", "microphone acquisition chain and acoustic spectrum analyzer"),
|
||
|
|
("Vibration resonance", "Sweep a shaker through the mechanical excitation range", "Estimate resonant peaks from accelerometer transfer functions", "shaker controller and accelerometer acquisition system"),
|
||
|
|
("RF emissions", "Operate the transmitter inside a shielded emissions fixture", "Measure out-of-band power with a swept spectrum analyzer", "RF chamber fixture and spectrum analyzer adapter"),
|
||
|
|
("Display luminance", "Render grayscale patches on the display", "Compare luminance uniformity using a calibrated photometer", "photometer positioning stage and luminance reader"),
|
||
|
|
("Camera geometric calibration", "Capture a calibrated optical checkerboard at controlled poses", "Calculate reprojection errors from detected calibration corners", "camera capture adapter and geometric calibration solver"),
|
||
|
|
("Touch trajectory response", "Move a robotic stylus along a specified screen trajectory", "Compare reported touch coordinates with robot encoder positions", "robotic stylus controller and coordinate synchronizer"),
|
||
|
|
("Battery discharge", "Discharge a battery through programmed current profiles", "Integrate current and compare cutoff voltage timing", "electronic load controller and coulomb-counting acquisition"),
|
||
|
|
("GNSS acquisition", "Generate synthetic satellite signals with controlled clock offsets", "Measure acquisition latency and reported navigation residuals", "GNSS RF simulator and receiver telemetry adapter"),
|
||
|
|
("PTP synchronization", "Inject timestamp asymmetry into precision time exchanges", "Compare hardware clock offsets against a reference clock", "PTP timestamp injector and clock comparison fixture"),
|
||
|
|
("Filesystem crash consistency", "Cut block-device writes at selected journal boundaries", "Remount the image and verify filesystem invariants", "block-device crash emulator and filesystem image checker"),
|
||
|
|
("ECC fault handling", "Inject single-bit and double-bit memory corruption", "Read ECC syndrome registers and corrected memory values", "memory error injector and ECC register access adapter"),
|
||
|
|
("Allocation exhaustion", "Force allocator failures at selected allocation calls", "Inspect returned errors and retained allocation ownership", "allocator interposition hooks and ownership tracker"),
|
||
|
|
("Thread race detection", "Replay conflicting memory accesses with controlled scheduling", "Compare race-detector reports with happens-before expectations", "thread scheduling harness and race-detector report adapter"),
|
||
|
|
("Deadlock graph detection", "Force opposing lock-acquisition orders in worker threads", "Inspect blocked-thread stacks and wait-for graph cycles", "lock-order scheduler and thread-stack graph collector"),
|
||
|
|
("Queue saturation", "Drive bounded producers and consumers at controlled rates", "Check queue depth, rejection ordering, and recovery after drain", "concurrent queue drivers and sequence-number observation fixture"),
|
||
|
|
("Flash endurance evidence", "Execute repeated flash erase/program cycles", "Compare bad-block telemetry and corrected-read counters", "flash cycling controller and device health telemetry decoder"),
|
||
|
|
("Certificate path validation", "Construct certificate chains with varied constraints", "Assert validation decisions and reported path violations", "certificate graph builder and trust-store fixture"),
|
||
|
|
("Firmware rollback recovery", "Interrupt a firmware image installation between boot-bank writes", "Inspect boot-bank selection and retained image signatures", "boot-bank flash interrupter and bootloader console collector"),
|
||
|
|
("Secure boot measurement", "Start measured boot with altered signed boot components", "Read TPM event logs and verify PCR extension chains", "TPM access adapter and measured-boot event-log verifier"),
|
||
|
|
("Authorization decisions", "Submit role-scoped operations to the policy decision function", "Compare permit/deny results with the permissions matrix", "identity fixture builder and in-memory policy store"),
|
||
|
|
("Audit log chain integrity", "Rotate tamper-evident audit segments after controlled events", "Recompute segment hash links and verify event continuity", "audit segment reader and hash-chain verifier"),
|
||
|
|
("AST rule analysis", "Run syntax-tree checks against small source-code fixtures", "Compare AST findings and source spans with expected rule matches", "compiler AST adapter and rule-location comparator"),
|
||
|
|
("Binary symbol inspection", "Build object files with controlled symbol visibility", "Inspect ELF symbol tables and relocation references", "ELF section parser and symbol/relocation checker"),
|
||
|
|
("Branch coverage tracing", "Execute instrumented branch paths with selected inputs", "Compare trace counters with the branch transition matrix", "coverage instrumentation driver and binary trace decoder"),
|
||
|
|
("Reproducible builds", "Rebuild the same source in isolated clean build containers", "Compare artifact digests after permitted timestamp normalization", "container build runner and reproducibility diff helper"),
|
||
|
|
("Configuration parsing", "Load text configuration fixtures through the parser", "Assert parsed values or diagnostic source positions", "configuration text builder and parser-call fixture"),
|
||
|
|
("Binary frame decoding", "Feed escaped binary frames through the frame decoder", "Compare decoded fields, checksum flags, and rejection codes", "byte-array frame builder and decoder-call fixture"),
|
||
|
|
("Transaction rollback", "Inject connection failures at database transaction boundaries", "Query committed rows and verify transaction isolation invariants", "database fault proxy and transaction-state query fixture"),
|
||
|
|
("Backup restoration", "Restore a snapshot into a fresh isolated service instance", "Compare restored object manifests and recovery checkpoints", "snapshot restoration runner and manifest comparison adapter"),
|
||
|
|
("HTTP backpressure", "Throttle readers of a long HTTP response stream", "Measure socket send-buffer pressure and cancellation cleanup", "HTTP slow-reader driver and socket instrumentation collector"),
|
||
|
|
("WebSocket reconnection", "Break established WebSocket sessions during sequenced messages", "Compare resumed sequence markers and duplicate-delivery flags", "WebSocket reconnect driver and message sequence tracker"),
|
||
|
|
("GPU kernel accuracy", "Launch numerical GPU kernels on generated input tensors", "Compare device results with high-precision host reference arrays", "GPU launch adapter and numeric tolerance comparator"),
|
||
|
|
)
|
||
|
|
|
||
|
|
|
||
|
|
def fixture():
|
||
|
|
"""Return 363 interleaved objectives and an independent machinery partition.
|
||
|
|
|
||
|
|
Exact total source bytes match retained metadata. Per-field real lengths were
|
||
|
|
not retained, so the synthetic distribution is explicit, not claimed identical.
|
||
|
|
"""
|
||
|
|
cases, expected = [], {}
|
||
|
|
for i in range(363):
|
||
|
|
name, action, observation, machinery = MECHANISMS[i % len(MECHANISMS)]
|
||
|
|
case = {"alias": f"CASE-CAP-{i:04d}", "case_type": ("nominal", "boundary", "fault injection")[(i // 45) % 3],
|
||
|
|
"description": action + ". Repeat the same test operation with alternate inputs and initial states.",
|
||
|
|
"preconditions": "Initialize the " + machinery + ". Restore the fixture to its known baseline before the test.",
|
||
|
|
"success_criteria": observation + ". Compare observed results with supplied expected values. Retain evidence for each individual objective.",
|
||
|
|
"verification_method": "test", "verifies": "[reference]"}
|
||
|
|
cases.append(case)
|
||
|
|
expected[case["alias"]] = name
|
||
|
|
# Duplicate content at distant positions retains two membership objectives.
|
||
|
|
cases[-2] = {**cases[1], "alias": cases[-2]["alias"]}
|
||
|
|
expected[cases[-2]["alias"]] = expected[cases[1]["alias"]]
|
||
|
|
source = {"campaign": "SYNTHETIC", "suite": "CAPACITY-363", "cases": cases}
|
||
|
|
target = 410322
|
||
|
|
additions = {
|
||
|
|
"description": " The case varies supplied settings without introducing an additional control or measurement interface.",
|
||
|
|
"preconditions": " Confirm the driver is ready and the observation buffer is empty. Record the fixture configuration for the run.",
|
||
|
|
"success_criteria": " Use the existing observations to assert the selected expected outcome. Preserve diagnostic evidence and distinguish an unavailable observation from a failed assertion.",
|
||
|
|
}
|
||
|
|
while len(encoded(source)) < target:
|
||
|
|
for i, case in enumerate(cases):
|
||
|
|
field = ("description", "preconditions", "success_criteria")[(i // 7) % 3]
|
||
|
|
remaining = target - len(encoded(source))
|
||
|
|
if remaining <= 0:
|
||
|
|
break
|
||
|
|
# Fixed sentence variations provide a range of realistic field lengths.
|
||
|
|
case[field] += additions[field][:remaining]
|
||
|
|
# Preserve one identical pair after variable-length expansion without changing size.
|
||
|
|
before = len(encoded(source))
|
||
|
|
for field in ("description", "preconditions", "success_criteria"):
|
||
|
|
cases[-2][field], cases[1][field] = cases[1][field], cases[1][field]
|
||
|
|
delta = target - len(encoded(source))
|
||
|
|
cases[-1]["description"] += " " * max(0, delta)
|
||
|
|
if delta < 0:
|
||
|
|
cases[-1]["description"] = cases[-1]["description"][:delta]
|
||
|
|
assert len(encoded(source)) == target and before == target
|
||
|
|
assert min(Counter(expected.values()).values()) > 5
|
||
|
|
return source, expected
|