tests: a walled run reads a 128 GB box's memory, and no test loses or takes an exported class

install.sh reads the box's class and its GiB from QWEN38_MEMINFO (/proc/meminfo by default), and
the walled copies read the machine running the tests: on a 64 GB one, 10 of the context mode's 19
tests failed. fenced_env now gives every walled run the reference box's MemTotal unless the test
gives its own, as the fresh machine's 31 and 57.6 GiB cases now do. The in-process tests read
os.environ: with QWEN38_MEMORY_CLASS=64 exported, the proof campaign's own tool, test_boxmem lost
a test and test_conformity_recommended two (both fail so on the old code), and test_boxmem's
cleanup popped the variable for the tests after it, which hid the second. They now set the
class they test and put the environment back as it was (found in review, 2026-10-23).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Hasan BasbunarandClaude Opus 5.5 committed 2026-10-23 21:58:27 +02:00
1 parent 5927159f64
commit b784057251
5 files changed
+44 -9

No files matched your search

+7 -4
View File
@@ -9,6 +9,7 @@ import shutil
import sys
import tempfile
import unittest
from unittest import mock
from pathlib import Path
HERE = Path(__file__).resolve()
@@ -47,8 +48,9 @@ class TheBox(unittest.TestCase):
shutil.rmtree(cls.tmp, ignore_errors=True)
def box(self, cls):
os.environ["QWEN38_MEMORY_CLASS"] = cls
self.addCleanup(os.environ.pop, "QWEN38_MEMORY_CLASS", None)
patch = mock.patch.dict(os.environ, {"QWEN38_MEMORY_CLASS": cls})
patch.start()
self.addCleanup(patch.stop)
self.cp._BOX.clear()
self.addCleanup(self.cp._BOX.clear)
return self.cp.box_info()
@@ -67,8 +69,9 @@ class TheBox(unittest.TestCase):
self.assertEqual(self.cp.collect_machine()["box"]["cls"], "64")
def test_a_box_that_cannot_be_read_is_unknown_not_a_failed_panel(self):
os.environ["QWEN38_MEMORY_CLASS"] = "96" # boxmem.py refuses it
self.addCleanup(os.environ.pop, "QWEN38_MEMORY_CLASS", None)
patch = mock.patch.dict(os.environ, {"QWEN38_MEMORY_CLASS": "96"}) # boxmem.py refuses it
patch.start()
self.addCleanup(patch.stop)
self.cp._BOX.clear()
self.addCleanup(self.cp._BOX.clear)
self.assertEqual(self.cp.box_info(), {"cls": None, "name": None, "fits": None})
+13 -1
View File
@@ -125,13 +125,25 @@ def fence(enabled=()):
return str(d), record
def meminfo_128():
"""A /proc/meminfo of the reference box, a 128 GB DGX Spark (121.6 GiB of MemTotal)."""
path = _tmp("meminfo-") / "meminfo"
path.write_text("MemTotal: 127533104 kB\nMemAvailable: 121000000 kB\n")
return path
def fenced_env(home=None, enabled=(), first=None, **extra):
"""(env, record): a minimal environment whose PATH starts with the fence (after
`first`, a directory of the test's own stubs, when given) and a throwaway HOME."""
`first`, a directory of the test's own stubs, when given) and a throwaway HOME.
install.sh reads the box's class and its GiB from QWEN38_MEMINFO (/proc/meminfo by
default): a walled run reads a 128 GB box's unless the test gives its own, so it does not
depend on the machine the tests run on (on a 64 GB one, 10 of the context mode's tests
failed, found in review, 2026-10-23)."""
entry, record = fence(enabled)
path = ":".join(p for p in (first, entry, "/usr/local/bin:/usr/bin:/bin") if p)
env = {"PATH": path, "HOME": str(home or _tmp("home-"))}
env.update({k: str(v) for k, v in extra.items()})
env.setdefault("QWEN38_MEMINFO", str(meminfo_128()))
return env, record
+7 -1
View File
@@ -14,6 +14,7 @@ import subprocess
import sys
import tempfile
import unittest
from unittest import mock
REPO = pathlib.Path(__file__).resolve().parents[1]
spec = importlib.util.spec_from_file_location("boxmem", REPO / "boxmem.py")
@@ -32,6 +33,12 @@ class Base(unittest.TestCase):
self.d = pathlib.Path(tempfile.mkdtemp(prefix="boxmem-"))
self.addCleanup(lambda: subprocess.run(["rm", "-rf", str(self.d)]))
self.env = {k: v for k, v in os.environ.items() if not k.startswith("QWEN38_")}
# the in-process checks read os.environ: none of an exported QWEN38_* reaches them, and
# all of it is back after each test (a pop lost it for the tests after, found in review,
# 2026-10-23)
patch = mock.patch.dict(os.environ, clear=True, values=self.env)
patch.start()
self.addCleanup(patch.stop)
def meminfo(self, kb):
p = self.d / f"meminfo-{kb}" # one file per size: a test that reads two keeps both
@@ -62,7 +69,6 @@ class MemClass(Base):
def test_forced_for_the_proofs_and_only_to_a_class(self):
os.environ["QWEN38_MEMORY_CLASS"] = "64"
self.addCleanup(os.environ.pop, "QWEN38_MEMORY_CLASS", None)
self.assertEqual(boxmem.mem_class(self.meminfo(REFERENCE_KB)), "64")
os.environ["QWEN38_MEMORY_CLASS"] = "96"
with self.assertRaises(ValueError):
+14
View File
@@ -24,6 +24,20 @@ import installer_wall as wall # noqa: E402
REPO = pathlib.Path(__file__).resolve().parents[1]
sys.path.insert(0, str(REPO))
import conformity # noqa: E402
from unittest import mock # noqa: E402
# conformity.py recommends by the box's class (the native window on a 64 GB one): these hold a
# 128 GB box's state, so the class is that one whatever the machine running them is, and an
# exported QWEN38_MEMORY_CLASS is back as it was after them (found in review, 2026-10-23).
_ENV = mock.patch.dict(os.environ, {"QWEN38_MEMORY_CLASS": "128"})
def setUpModule():
_ENV.start()
def tearDownModule():
_ENV.stop()
INSTALL = (REPO / "install.sh").read_text()
CHANGELOG = (REPO / "CHANGELOG.md").read_text()
+3 -3
View File
@@ -742,7 +742,7 @@ class TheWholeScripts(unittest.TestCase):
small = copy.parent / "meminfo-32"
small.write_text("MemTotal: 32505856 kB\n") # 31.0 GiB, below the 64 GB class
copy.write_text(copy.read_text().replace("/proc/meminfo", str(small)))
r, out, record = self.run_install(box, str(copy))
r, out, record = self.run_install(box, str(copy), QWEN38_MEMINFO=str(small))
self.assertIn("This box has 31.0 GiB of memory (MemTotal), and the lanes here need a 64 GB or a 128 GB DGX Spark.", out)
self.assertEqual(box.sudo_calls(), [])
@@ -754,7 +754,7 @@ class TheWholeScripts(unittest.TestCase):
mem = copy.parent / "meminfo-64"
mem.write_text("MemTotal: 60397977 kB\n") # 57.6 GiB: 64 GiB held aside on the reference box
copy.write_text(copy.read_text().replace("/proc/meminfo", str(mem)))
r, out, record = self.run_install(box, str(copy))
r, out, record = self.run_install(box, str(copy), QWEN38_MEMINFO=str(mem))
self.assertIn(wall.WALL, out, out[-800:])
self.assertIn("This box is a 64 GB DGX Spark: the lanes that fit it are the 27B and Nemotron 3.5 Bolt here", out)
self.assertIn("Left out, as they need a 128 GB one: image (Qwen-Image 2.1), video (MiniMax-H3), flash 176B, Kolibri-1, "
@@ -775,7 +775,7 @@ class TheWholeScripts(unittest.TestCase):
mem = copy.parent / "meminfo-64"
mem.write_text("MemTotal: 60397977 kB\n")
copy.write_text(copy.read_text().replace("/proc/meminfo", str(mem)))
r, out, record = self.run_install(box, str(copy), *args, **env)
r, out, record = self.run_install(box, str(copy), *args, **{**env, "QWEN38_MEMINFO": str(mem)})
self.assertEqual(r.returncode, 1, out[-800:])
self.assertIn(said, out)
self.assertNotIn(wall.WALL, out)