From ab65e703fc6f95c4ba605c815038eb159f08bedf Mon Sep 17 00:00:00 2001 From: Caitlin Ross Date: Mon, 29 Jun 2026 23:14:40 -0500 Subject: [PATCH 1/7] tests: add CMake-driven equivalence test harness Introduce a declarative way to register equivalence/determinism tests so that adding one is a single CMake call rather than a copy-and-edit shell script. - codes_add_equivalence_test() registers a test that runs a model binary two or more times and asserts a marker line ("Net Events Processed" by default) is identical across runs. REPEAT covers reproducibility; VARIANTS covers comparisons such as seq vs optimistic (--sync=1 vs --sync=3). - equivalence-run.sh is the generic runner behind it: each run executes in its own run-N/ subdir (so fixed relative output paths don't collide), greps the marker from each run, and diffs them. - run-test.sh.in now accepts a full command with arguments, not just a single legacy per-scenario script. Migrate example-ping-pong-determinism.sh as the first user of the helper and drop the standalone script. --- tests/CMakeLists.txt | 79 ++++++++++++++++++++- tests/equivalence-run.sh | 95 ++++++++++++++++++++++++++ tests/example-ping-pong-determinism.sh | 39 ----------- tests/run-test.sh.in | 9 ++- 4 files changed, 181 insertions(+), 41 deletions(-) create mode 100755 tests/equivalence-run.sh delete mode 100755 tests/example-ping-pong-determinism.sh diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index ec0acdeb..dc1595e0 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -2,6 +2,73 @@ enable_testing() configure_file(run-test.sh.in run-test.sh) +# codes_add_equivalence_test — register an equivalence/determinism test. +# +# Runs a model binary two or more times and asserts a marker line (default +# "Net Events Processed") is identical across runs. Replaces the copy-and-edit +# per-scenario shell scripts: adding a test is one call here, no new file. +# +# codes_add_equivalence_test( +# NAME +# BINARY # e.g. tutorial-synthetic-ping-pong +# CONFIG # e.g. doc/example/tutorial-ping-pong.conf +# [NP ] # default 3 +# [ARGS ] +# [REPEAT ] # default 2; identical runs (reproducibility) +# [VARIANTS "" "" ...] # one run each, appended +# [MARKER ] # default "Net Events Processed" +# [SETUP