Harden CLI paths and coupling export checks
This commit is contained in:
@@ -72,14 +72,30 @@ def main() -> int:
|
||||
):
|
||||
require_field(inspect.stdout, field)
|
||||
inspect_fields = read_fields(inspect.stdout)
|
||||
if inspect_fields["version"] != "0.2.1":
|
||||
raise AssertionError("inspect version field mismatch")
|
||||
if Path(inspect_fields["input"]) != Path(model):
|
||||
raise AssertionError("inspect input field mismatch")
|
||||
if inspect_fields["mode"] != "inspect":
|
||||
raise AssertionError("inspect mode not reported")
|
||||
if int(inspect_fields["particles"]) != 4:
|
||||
raise AssertionError("CLI particle count mismatch")
|
||||
if int(inspect_fields["warnings"]) != 0:
|
||||
raise AssertionError("CLI warning count mismatch")
|
||||
if abs(float(inspect_fields["time"])) > 1.0e-15:
|
||||
raise AssertionError("inspect time should be zero")
|
||||
if int(inspect_fields["step"]) != 0:
|
||||
raise AssertionError("inspect step should be zero")
|
||||
if int(inspect_fields["water_particles"]) != 4:
|
||||
raise AssertionError("CLI water particle count mismatch")
|
||||
if float(inspect_fields["water_mass"]) <= 0.0:
|
||||
raise AssertionError("CLI water mass mismatch")
|
||||
if float(inspect_fields["max_pressure"]) < 0.0:
|
||||
raise AssertionError("CLI max pressure mismatch")
|
||||
if float(inspect_fields["dtcrit"]) <= 0.0:
|
||||
raise AssertionError("CLI dtcrit mismatch")
|
||||
if inspect_fields["status"] != "ok":
|
||||
raise AssertionError("CLI status field mismatch")
|
||||
|
||||
check = run_command([exe, model, "--check"])
|
||||
if "mode: check" not in check.stdout:
|
||||
@@ -89,6 +105,8 @@ def main() -> int:
|
||||
run_fields = read_fields(run.stdout)
|
||||
if run_fields["mode"] != "run":
|
||||
raise AssertionError("run mode not reported")
|
||||
if float(run_fields["time"]) <= 0.0:
|
||||
raise AssertionError("run mode time did not advance")
|
||||
if int(run_fields["step"]) <= 0:
|
||||
raise AssertionError("run mode did not advance")
|
||||
output_step = int(run_fields["step"])
|
||||
@@ -105,6 +123,22 @@ def main() -> int:
|
||||
bad = run_command([exe, bad_model, "--check"], expect_ok=False)
|
||||
require_field(bad.stderr, "error_code")
|
||||
require_field(bad.stderr, "error_message")
|
||||
missing_arg = run_command([exe], expect_ok=False)
|
||||
if "usage:" not in missing_arg.stdout:
|
||||
raise AssertionError("missing input did not print usage")
|
||||
missing_file = run_command([exe, str(Path(output_dir) / "missing.inp")], expect_ok=False)
|
||||
require_field(missing_file.stderr, "error_code")
|
||||
conflict = run_command([exe, model, "--run", "--check"], expect_ok=False)
|
||||
if "usage:" not in conflict.stdout:
|
||||
raise AssertionError("conflicting modes did not print usage")
|
||||
missing_output = run_command([exe, model, "--run", "--output"], expect_ok=False)
|
||||
if "usage:" not in missing_output.stdout:
|
||||
raise AssertionError("missing output path did not print usage")
|
||||
illegal_output = run_command(
|
||||
[exe, model, "--run", "--output", str(Path(output_dir) / "missing-dir" / "nested")],
|
||||
expect_ok=False,
|
||||
)
|
||||
require_field(illegal_output.stderr, "error_code")
|
||||
return 0
|
||||
|
||||
|
||||
|
||||
@@ -16,6 +16,12 @@ def main() -> int:
|
||||
|
||||
from sphlite_debug import PHASE_SOLID, PHASE_WATER, STATUS_ACTIVE, SPHLite, SPHLiteError
|
||||
|
||||
wrapper_source = (root / "python" / "sphlite_debug.py").read_text(encoding="utf-8")
|
||||
if "ctypes.CDLL" not in wrapper_source:
|
||||
raise AssertionError("Python wrapper is not loading the C ABI library")
|
||||
if "sphft_" in wrapper_source:
|
||||
raise AssertionError("Python wrapper directly references Fortran symbols")
|
||||
|
||||
solver = SPHLite(args.library)
|
||||
if PHASE_SOLID != 4 or STATUS_ACTIVE != 0:
|
||||
raise AssertionError("Python constants are not locked")
|
||||
@@ -37,6 +43,8 @@ def main() -> int:
|
||||
solid_summary = solver.inspect(args.input)
|
||||
if solid_summary["particles"] != 4:
|
||||
raise AssertionError("solid inspect summary mismatch")
|
||||
if "water_mass" not in solid_summary or "dt_cfl" not in solid_summary:
|
||||
raise AssertionError("inspect helper did not include Water diagnostics")
|
||||
solver.set_output_directory(root / "build-codex-unix")
|
||||
solver.write_output(0, 0.0)
|
||||
restart = root / "build-codex-unix" / "python_restart.tmp"
|
||||
@@ -67,6 +75,8 @@ def main() -> int:
|
||||
if water_state["phase"][0] != PHASE_WATER:
|
||||
raise AssertionError("unexpected water particle phase")
|
||||
run_summary = water.run(water_input)
|
||||
if run_summary["particles"] != 4:
|
||||
raise AssertionError("water run particle count mismatch")
|
||||
if run_summary["water_mass"] <= 0.0 or run_summary["dt_cfl"] <= 0.0:
|
||||
raise AssertionError("water run summary mismatch")
|
||||
finally:
|
||||
|
||||
Reference in New Issue
Block a user