Files
colibri/c/tests/test_makefile_platform.py
T
ZacharyZcR f853ea8a0b refactor: split glm.c into colibri.c + 4 header modules
Rename glm.c → colibri.c and extract four self-contained modules
into header-only files (same pattern as st.h/tier.h/grammar.h):

  quant.h      (672 lines) — SIMD matmul kernels, quantization
  sample.h     (143 lines) — RNG, top-p sampling, stop-set
  kv_persist.h (121 lines) — .coli_kv disk persistence
  telemetry.h  (189 lines) — dashboard protocol, stats, usage

Main engine file shrinks from 6588 to 5396 lines (−18%).

Build system: primary target is now colibri$(EXE); `make glm`
remains as a phony alias for backward compat. CI, setup.sh,
coli CLI, and all 10 test files that include the engine are
updated. make check passes (C + Python, 73 tests, zero warnings).
2026-07-19 21:12:04 +08:00

77 lines
2.3 KiB
Python

import os
import shutil
import subprocess
import unittest
from pathlib import Path
C_DIR = Path(__file__).resolve().parents[1]
MAKE = shutil.which("make")
@unittest.skipUnless(MAKE, "make is required")
class MakefilePlatformTests(unittest.TestCase):
def _dry_run(self, target, triplet, **variables):
args = [
MAKE,
"--no-print-directory",
"-B",
"-n",
target,
f"TRIPLET={triplet}",
]
args.extend(f"{name}={value}" for name, value in variables.items())
return subprocess.run(
args,
cwd=C_DIR,
text=True,
capture_output=True,
check=True,
)
def test_windows_nt_without_uname_selects_mingw_build(self):
env = os.environ.copy()
env["OS"] = "Windows_NT"
env["PATH"] = ""
result = subprocess.run(
[MAKE, "--no-print-directory", "-B", "-n", "colibri"],
cwd=C_DIR,
env=env,
text=True,
capture_output=True,
check=True,
)
self.assertIn("-o colibri.exe", result.stdout)
self.assertIn("-fopenmp", result.stdout)
self.assertIn("-static", result.stdout)
def test_portable_build_uses_target_architecture(self):
cases = (
("x86_64-unknown-linux-gnu", "-march=x86-64-v3"),
("aarch64-unknown-linux-gnu", "-march=armv8-a"),
("powerpc64le-unknown-linux-gnu", "-mcpu=power8"),
("ppc64le-unknown-linux-gnu", "-mcpu=power8"),
)
for triplet, expected_flag in cases:
with self.subTest(triplet=triplet):
result = self._dry_run("portable", triplet)
self.assertIn(expected_flag, result.stdout)
def test_darwin_portable_build_does_not_force_x86_architecture(self):
missing_libomp = "/colibri-test/missing-libomp"
result = self._dry_run(
"portable", "arm64-apple-darwin", OMPDIR=missing_libomp
)
self.assertIn("clang -O3", result.stdout)
self.assertNotIn("-mcpu=x86-64-v3", result.stdout)
self.assertNotIn(missing_libomp, result.stdout)
self.assertNotIn("-fopenmp", result.stdout)
if __name__ == "__main__":
unittest.main()