aboutsummaryrefslogtreecommitdiff
path: root/tests/check_workspace_api.py
diff options
context:
space:
mode:
authorOnur Gündüz <ogunduz@gmail.com>2026-06-20 20:36:55 +0200
committerOnur Gündüz <ogunduz@gmail.com>2026-06-21 06:00:26 +0200
commit6652fcbc653d84e75cb5c08c5f5edf52263ed50f (patch)
tree1ccffa48e1dc86c59c61dcd4672ffedcf1e0c873 /tests/check_workspace_api.py
parentdbdf714bb57578431924e5d069089bdfd9f4c604 (diff)
downloadffwd-6652fcbc653d84e75cb5c08c5f5edf52263ed50f.tar.gz
ffwd-6652fcbc653d84e75cb5c08c5f5edf52263ed50f.zip
tests: upgrade unit tests and add integration/parity tests
Diffstat (limited to 'tests/check_workspace_api.py')
-rw-r--r--tests/check_workspace_api.py46
1 files changed, 46 insertions, 0 deletions
diff --git a/tests/check_workspace_api.py b/tests/check_workspace_api.py
new file mode 100644
index 0000000..40bac11
--- /dev/null
+++ b/tests/check_workspace_api.py
@@ -0,0 +1,46 @@
+#!/usr/bin/env python3
+"""Run the workspace / model API smoke test against real weights.
+
+The C side is tests/test_workspace.c, the same source `make test` builds with
+the synthetic fixture. Given a MODEL_DIR it loads real weights from that
+directory instead and exercises the workspace and batch APIs. Needs only
+python3 and a model directory (with vocab.json), no reference stack.
+
+The model must be mean-pooled: the test checks that a whole-sequence span pools
+to the embedding, which holds for mean pooling (pplx-embed, BERT/BGE) but not
+for last-token pooling (Qwen3). Use a pplx-embed model.
+
+ tests/check_workspace_api.py --model-dir DIR # DIR = a pplx-embed model
+"""
+
+import argparse
+import os
+import subprocess
+import sys
+from pathlib import Path
+
+ROOT = Path(__file__).resolve().parents[1]
+DRIVER = ROOT / "tests/test_workspace"
+
+
+def ensure_driver(cc: str) -> None:
+ """Build tests/test_workspace via the Makefile so a C change is picked up."""
+ proc = subprocess.run(["make", "-C", "tests", f"CC={cc}", "test_workspace"],
+ cwd=ROOT, text=True, stdout=subprocess.PIPE,
+ stderr=subprocess.STDOUT, check=False)
+ if proc.returncode != 0:
+ sys.stderr.write(proc.stdout)
+ raise SystemExit(proc.returncode)
+
+
+def main() -> int:
+ ap = argparse.ArgumentParser()
+ ap.add_argument("--model-dir", required=True)
+ ap.add_argument("--cc", default=os.environ.get("CC", "cc"))
+ args = ap.parse_args()
+ ensure_driver(args.cc)
+ return subprocess.run([str(DRIVER), args.model_dir], cwd=ROOT).returncode
+
+
+if __name__ == "__main__":
+ raise SystemExit(main())