From 7abc070a0dac79e1340a820b35fffd63f33fea4e Mon Sep 17 00:00:00 2001 From: Xenolphthalein <21215869+Xenolphthalein@users.noreply.github.com> Date: Fri, 4 Dec 2026 10:44:59 +0100 Subject: [PATCH 1/2] test: fewer tests that only repeat their recipe's own files or another test: pico4-base's config echoes, pico4-slamd's source greps (its y-up turn stays), stock-value and duplicate checks in pico4-power, -audio, -checks and overpressure-base --- common/overpressure-base/PKGBUILD | 6 +- common/overpressure-base/test_config.py | 11 - phoenix/pico4-audio/PKGBUILD | 4 +- phoenix/pico4-audio/test_audiocal.py | 8 - phoenix/pico4-base/PKGBUILD | 7 +- phoenix/pico4-base/test_config.py | 71 ------ phoenix/pico4-checks/PKGBUILD | 6 +- phoenix/pico4-checks/test_msm_frame_stats.py | 9 - .../pico4-checks/test_session_performance.py | 6 +- phoenix/pico4-power/PKGBUILD | 12 +- phoenix/pico4-power/test_battery_guard.py | 8 - phoenix/pico4-power/test_fan.py | 10 - phoenix/pico4-power/test_power_key.py | 10 - phoenix/pico4-power/test_status_led.py | 7 - phoenix/pico4-slamd/PKGBUILD | 4 +- phoenix/pico4-slamd/test_slamd.py | 229 +----------------- 16 files changed, 22 insertions(+), 386 deletions(-) delete mode 100644 phoenix/pico4-base/test_config.py diff --git a/common/overpressure-base/PKGBUILD b/common/overpressure-base/PKGBUILD index 7525fe5..935874d 100644 --- a/common/overpressure-base/PKGBUILD +++ b/common/overpressure-base/PKGBUILD @@ -8,8 +8,8 @@ # session's user may start (its polkit rule), and its daily check. The preset enables the services and the timer; # the tests run in the build. pkgname=overpressure-base -pkgver=2026.12.2 -pkgrel=2 +pkgver=2026.12.4 +pkgrel=1 pkgdesc="overpressure's installed system: preinit, storage and recovery policy, USB link" arch=(any) url="https://github.com/overpressure/overpressure/blob/main/docs/runtime.md" @@ -71,7 +71,7 @@ sha256sums=('952324c99b08f87f6d318258eb24915ed4f18a4f9fa219e756bbca70d5bd8396' '42e864cce089ddec10704c74a404d4713e9b1371284e88e29c8a396f43e0bf42' '7e2e20deeb0a824f77178be78dd3b52ba3b0eea92723b634279adc2c5e0d38b7' '3daf42f9b44dfcf6d4ae65018d633198503fa9071596c443a188fe37ec379d78' - 'c7dd064ee8c73ae16f18be269c41411820408678cd467e4324cd2414a3b3897e' + 'fe7fb9ba139be31b4bb9aca8ae35373b5ff21ce4bc5c47b2b9d8f880f0f39071' 'f5f3580f84c53379b59a4de7aa206ba88975a439939a4b8eded66bd5dcced147' '7983dff5891f654806fdf7b0ac36683df4b13d8ae291e439c3a90ee5abb5ab4e' 'b45bf0dbde89f82a75cd782acce1773f1e2b7d2b0322d66be50c71782dac0eea' diff --git a/common/overpressure-base/test_config.py b/common/overpressure-base/test_config.py index e9e9422..9b93779 100644 --- a/common/overpressure-base/test_config.py +++ b/common/overpressure-base/test_config.py @@ -96,17 +96,6 @@ def test_the_session_starts_the_three_steps_and_nothing_else(self): self.assertEqual(rule.count("polkit.Result.YES"), 1) self.assertNotIn("Result.AUTH", rule) - def test_the_package_installs_them(self): - pkgbuild = (HERE / "PKGBUILD").read_text(encoding="utf-8") - for name in ( - "overpressure-update@.service", - "overpressure-update-check.service", - "overpressure-update-check.timer", - "50-overpressure-update.rules", - ): - self.assertIn(f" {name}", pkgbuild) - self.assertIn('"$pkgdir/usr/share/polkit-1/rules.d/50-overpressure-update.rules"', pkgbuild) - if __name__ == "__main__": unittest.main() diff --git a/phoenix/pico4-audio/PKGBUILD b/phoenix/pico4-audio/PKGBUILD index f2ce7c0..945a8a3 100644 --- a/phoenix/pico4-audio/PKGBUILD +++ b/phoenix/pico4-audio/PKGBUILD @@ -4,7 +4,7 @@ # the microphone muted while the headset is off the head. The preset enables the audio target; the tests # run in the build. pkgname=pico4-audio -pkgver=2026.12.3 +pkgver=2026.12.4 pkgrel=1 pkgdesc="PICO 4 audio: the ADSP, its audio process, the sound card's routes and calibration, the microphone mute" arch=(any) @@ -44,7 +44,7 @@ sha256sums=('5789e02ea04b1a1100faabd0805891703a8916d00be1ff90f428c16db831308f' '6e73ec6b6f791a857336992b81c95eaafdc8b221f64eb3f8e090c6bd2bb39c3f' 'e6cce0d239fc1389d007aecb5a00d121076deb72963a79149edf05a009c9c38f' '939fd8440eaede54fdbd64642493befc72d6d64cd500834912f2a56aec116b2f' - 'ecba7a9a64a70f6e0cb81f9e537175441ed903dce6ebe46cc55c50953f534b89' + 'af547eeb877d2d837285cb6bbd6c7aa2f0d5f1c27b6c924ddd3e619a68607150' '179f021b124a78032d57233419710aafd98bbc313e36a2e57599c51be0f05766') build() { diff --git a/phoenix/pico4-audio/test_audiocal.py b/phoenix/pico4-audio/test_audiocal.py index 9bc45ac..e08104f 100644 --- a/phoenix/pico4-audio/test_audiocal.py +++ b/phoenix/pico4-audio/test_audiocal.py @@ -198,14 +198,6 @@ def test_export_plays_the_sami_device_unless_plain(self): topologies[bool(flag)] = struct.unpack_from(" configparser.ConfigParser: - """Return a systemd or NetworkManager configuration file of the package, parsed.""" - config = configparser.ConfigParser() - config.read_string((HERE / name).read_text(encoding="utf-8")) - return config - - -def settings(name: str, separator: str | None = None) -> dict[str, str]: - """Return a file's "key value" lines (sysctl's "key = value" with `separator`), comments left out.""" - found = {} - for line in (HERE / name).read_text(encoding="utf-8").splitlines(): - if line and not line.startswith("#"): - key, value = line.split(separator, 1) - found[key.strip()] = value.strip() - return found - - -class ChargerModeTests(unittest.TestCase): - """Charger mode starts no Bluetooth setup: its controller refuses the address there.""" - - def test_the_bluetooth_units_skip_charger_mode(self): - for unit in ("pico4-bt-firmware.service", "pico4-bt-address.service"): - unit_section = (HERE / unit).read_text(encoding="utf-8").split("[Service]")[0] - self.assertIn("ConditionKernelCommandLine=!androidboot.mode=charger", unit_section.splitlines(), unit) - - -class CoredumpLimitTests(unittest.TestCase): - """The limit on the core dumps that vrcompositor leaves at each SteamVR stop.""" - - def test_the_dumps_have_a_disk_limit(self): - self.assertEqual(ini("50-pico4-limit.conf")["Coredump"]["MaxUse"], "1G") - - def test_core_dumps_stay_on(self): - coredump = ini("50-pico4-limit.conf")["Coredump"] - self.assertNotIn("Storage", coredump) - self.assertNotIn("ProcessSizeMax", coredump) - - -class MemoryTests(unittest.TestCase): - def test_pico_os_reclaim_settings(self): - sysctl = settings("50-pico4-memory.conf", "=") - self.assertEqual(sysctl["vm.swappiness"], "100") - self.assertEqual(sysctl["vm.watermark_scale_factor"], "90") - self.assertEqual(sysctl["vm.watermark_boost_factor"], "0") - self.assertEqual(sysctl["vm.overcommit_memory"], "1") - - -class WifiTests(unittest.TestCase): - def test_connections_keep_the_address_pico_assigned(self): - conf = ini("50-pico4-wifi-address.conf") - self.assertEqual(conf["connection"]["wifi.cloned-mac-address"], "preserve") - - def test_network_manager_retries_a_failed_connection(self): - # With iwd's autoconnect, one DHCP timeout leaves the headset offline for good. - self.assertEqual(ini("50-pico4-wifi-autoconnect.conf")["device"]["wifi.iwd.autoconnect"], "false") - - -if __name__ == "__main__": - unittest.main() diff --git a/phoenix/pico4-checks/PKGBUILD b/phoenix/pico4-checks/PKGBUILD index bac1cb8..e386970 100644 --- a/phoenix/pico4-checks/PKGBUILD +++ b/phoenix/pico4-checks/PKGBUILD @@ -3,7 +3,7 @@ # reads), the suspend check, the support bundle and the link's samples after # boot. The preset enables the link samples; the tests run in the build. pkgname=pico4-checks -pkgver=2026.11.25 +pkgver=2026.12.4 pkgrel=1 pkgdesc="PICO 4 checks: the system's and the VR session's acceptance checks, the support bundle" arch=(any) @@ -32,8 +32,8 @@ sha256sums=('83c000aeb2f6834844c79b5dbac32b76f866f0431461bf89b92415eaff29f8b6' '454156206a62fa0b7dea261238feb5e7350013382397891c680feb1ce7bf9ee0' '6e4f6fcd37d067aafd2fb16cbe2544cbfb16c18d762b8f0dba7c34689147762e' '43a502265d0d94d117b4e30bad443348238a904948334e3ad634e822d87ed63a' - 'f07de3d3b4df5f17c154ed24cbce1475b7abd7827222604c185a018920ab4d11' - 'f0eaf22820c981198a319c89b00967b91c8bd2e3a3b286cba7e4a10469db286a' + '6bbc067d6511aa176a310ea0cd4ef938b79b85c092ef819c256c8961e8d5f8b4' + '8a76b8b211ba652de37c28884584baeaffb29597d363e04aa80221f15fefd2ab' '71f8feb17dc54eb08505042fd5f7fd685b8f31c9c6acd44c5b2885dbe2dd5600' 'bad444faaafc81249c69d06807c9c863ab0c63dee2e945b39a2694ce4541c44f') diff --git a/phoenix/pico4-checks/test_msm_frame_stats.py b/phoenix/pico4-checks/test_msm_frame_stats.py index 481cd7f..de461a6 100644 --- a/phoenix/pico4-checks/test_msm_frame_stats.py +++ b/phoenix/pico4-checks/test_msm_frame_stats.py @@ -70,15 +70,6 @@ def test_a_little_margin_fails_the_check_and_the_web_helpers_share_is_reported(s end["job_margin_ms"]["p99"] = 6.3 self.assertEqual(perf.verdict(end, 60.0)["status"], "passed") - def test_the_web_helpers_share_is_reported_and_judges_nothing(self): - flips = [100 + i * REFRESH for i in range(901)] - end = stats.parse(trace(flips, 901, [(700, 5.9)]), {700}) - end["job_margin_ms"] = {"p50": 7.1, "p99": 6.3, "frames": 900, "without_a_job": 0} - for share in (0.0, 12.5): - end["web_helper_gpu_percent"] = share - v = perf.verdict(end, 60.0) - self.assertEqual((v["status"], v["web_helper_gpu_percent"]), ("passed", share)) - def test_the_web_helpers_threads_count_apart_from_the_compositors(self): flips = [100 + i * REFRESH for i in range(91)] lines = trace(flips, 91, [(700, 5.9), (800, 500.0)]) diff --git a/phoenix/pico4-checks/test_session_performance.py b/phoenix/pico4-checks/test_session_performance.py index 6b22513..a680437 100644 --- a/phoenix/pico4-checks/test_session_performance.py +++ b/phoenix/pico4-checks/test_session_performance.py @@ -48,6 +48,8 @@ def test_the_window_passes(self): self.assertAlmostEqual(v["late_percent"], 100 * 2 / 2700, places=2) self.assertEqual(v["gpu_ms"]["mean"], 3.1) self.assertEqual(v["limits"]["commit_hz_min"], 85.5) + # Up to the agreed limit of 90 °C; 90.5 °C fails (the heat case below). + self.assertEqual(perf.verdict(FRAMES, 90.0)["status"], "passed") def test_each_limit_fails_on_its_own(self): cases = [ @@ -97,10 +99,6 @@ def test_command_line(self): ).stdout self.assertEqual(json.loads(out)["status"], "failed") - def test_up_to_the_agreed_limit_of_90_c_passes(self): - self.assertEqual(perf.verdict(FRAMES, 90.0)["status"], "passed") - self.assertEqual(perf.verdict(FRAMES, 90.5)["failures"], ["hottest zone 90.5 °C, above 90.0 °C"]) - if __name__ == "__main__": unittest.main() diff --git a/phoenix/pico4-power/PKGBUILD b/phoenix/pico4-power/PKGBUILD index a0c2d73..c596367 100644 --- a/phoenix/pico4-power/PKGBUILD +++ b/phoenix/pico4-power/PKGBUILD @@ -4,8 +4,8 @@ # the key alone); the status LED as PICO OS sets it (status-led). The preset enables the four services; in a # sleep the fan is off, as on PICO OS (systemd-sleep's hook pico4-fan.sleep); the tests run in the build. pkgname=pico4-power -pkgver=2026.12.3 -pkgrel=2 +pkgver=2026.12.4 +pkgrel=1 pkgdesc="PICO 4 fan control, battery guard, power key and status LED, as on PICO OS" arch=(any) url="https://github.com/overpressure/phoenix/blob/main/docs/cooling.md" @@ -28,10 +28,10 @@ sha256sums=('81899ac36a3ca784da208b1426e6e6f7fe777ebc6ece8c99eda84e97acf892cd' '09cb202f462560346e18f63e8a09bb1c53d19189547ac8b60639913695851908' 'd2c226f50a1c3029888921ff44c135d265952e6cfd488b7d91b3503d3c4939b3' 'e9ca686d1b78eed2e1f7ee7efdbc65e996d59400d1e14a84c3bda892736251c6' - 'f0557038297791bba0fde3efc28d25a565f7ef338dc38cd65ff4dbea0fdada59' - '5f5df141aef42f012da84adb920ac3db4e4a8620bc1dd0059d88fc8579f43251' - 'e403426890c10267a02693e04e06ddbbfc0be30fd3130aa089e2b80c921d1886' - '630cae3a000e3aaea81105a54c9842a3236fe40ac606e0335231b8900b6552d0') + '2933b30c10a5d20347705f7a7b54bcfc1cf5121dd040bc23815d209ca34479d1' + '5edf30f7fde72465d7f812df1213472d09e602bf6471db6d5da39d7280bf8209' + '9870a35718c891ad51ebe9da76c6dfa141874d0874fa4ebc555d9749137ef01e' + '140ff40f372872657c627deace5ca82532361c6b2d4b8c99d09dcacf46ea40a9') build() { python3 -B -m unittest test_fan test_battery_guard test_power_key test_status_led diff --git a/phoenix/pico4-power/test_battery_guard.py b/phoenix/pico4-power/test_battery_guard.py index 8e7d6b8..34bb38b 100644 --- a/phoenix/pico4-power/test_battery_guard.py +++ b/phoenix/pico4-power/test_battery_guard.py @@ -25,14 +25,6 @@ CHARGING, DISCHARGING, NOT_CHARGING, FULL = "Charging", "Discharging", "Not charging", "Full" -class ValuesTests(unittest.TestCase): - def test_the_stock_values(self): - # ExtBatteryServiceImpl: batteryLevel < 1, MIN_BATTERY_LEVEL_SHUTDOWN, postDelayed 60000. - self.assertEqual((tool.EMPTY, tool.SCREEN_OFF_LEVEL, tool.SCREEN_OFF_DELAY), (1, 4, 60.0)) - # checkBatteryStatus's notice and shutdownIfOverTempLocked's limit, in tenths of °C. - self.assertEqual((tool.HOT_NOTICE, tool.HOT_SHUTDOWN), (580, 590)) - - class HotTests(unittest.TestCase): def test_powers_off_above_59_degrees(self): guard = tool.Guard() diff --git a/phoenix/pico4-power/test_fan.py b/phoenix/pico4-power/test_fan.py index 8110c2e..581ebb9 100644 --- a/phoenix/pico4-power/test_fan.py +++ b/phoenix/pico4-power/test_fan.py @@ -243,13 +243,6 @@ def test_an_awake_mcu_is_never_woken(self): class TableTest(unittest.TestCase): - def test_tables_match_the_stock_service(self): - # libpxrfanservice.so, FanControl::FanControl for product "Phoenix". - self.assertEqual(EARLY.thresholds, (90000, 85000, 70000, 60000, 55000, 50000)) - self.assertEqual(EARLY.duties, (75, 60, 45, 30, 30, 30)) - self.assertEqual(LATE.thresholds, (90000, 85000, 80500, 72000, 60000, 55000)) - self.assertEqual(LATE.duties, (50, 45, 40, 35, 30, 0)) - def run_steps(self, table: object, temps: list[float], last: int | None = None) -> list[int | None]: out = [] for t in temps: @@ -862,9 +855,6 @@ def test_wrong_length(self): with self.assertRaises(ValueError): fan.fan_info(reply(1, 2, 3)) - def test_query_stays_on_the_allowlist(self): - self.assertEqual(fan.request(fan.GET_FAN_INFO).hex(), "a030000000" + "90") - class StateTest(unittest.TestCase): def test_fresh_state_only(self): diff --git a/phoenix/pico4-power/test_power_key.py b/phoenix/pico4-power/test_power_key.py index f9a5cbc..33b630b 100644 --- a/phoenix/pico4-power/test_power_key.py +++ b/phoenix/pico4-power/test_power_key.py @@ -1,7 +1,6 @@ # SPDX-License-Identifier: Unlicense """The power key as on PICO OS (docs/install.md#power-key).""" -import configparser import importlib.machinery import importlib.util import tempfile @@ -9,7 +8,6 @@ from pathlib import Path HERE = Path(__file__).resolve().parent -DROPIN = HERE / "50-pico4-power-key.conf" PATH = HERE / "powerkey" _loader = importlib.machinery.SourceFileLoader("powerkey", str(PATH)) _spec = importlib.util.spec_from_loader("powerkey", _loader) @@ -18,14 +16,6 @@ _loader.exec_module(tool) -class LogindTests(unittest.TestCase): - def test_logind_leaves_the_key_to_pico4_powerkey(self): - config = configparser.ConfigParser() - config.read_string(DROPIN.read_text(encoding="utf-8")) - self.assertEqual(config["Login"]["HandlePowerKey"], "ignore") - self.assertEqual(config["Login"]["HandlePowerKeyLongPress"], "ignore") - - class DeviceTests(unittest.TestCase): def test_the_pmic_key(self): with tempfile.TemporaryDirectory() as tmp: diff --git a/phoenix/pico4-power/test_status_led.py b/phoenix/pico4-power/test_status_led.py index f922c28..f4463c6 100644 --- a/phoenix/pico4-power/test_status_led.py +++ b/phoenix/pico4-power/test_status_led.py @@ -50,13 +50,6 @@ def test_temperature_blink_comes_first(self): for temp in (449, 580, 1): self.assertEqual(tool.battery_light(state(CHARGING, plugged=True, temp=temp)), tool.CHARGING, temp) - def test_stock_values(self): - self.assertEqual(tool.CHARGING, tool.Light(red=80, green=80)) - self.assertEqual(tool.BLUE, tool.Light(blue=255)) - self.assertEqual((tool.LOW_BLINK.on_ms, tool.LOW_BLINK.off_ms), (500, 1000)) - self.assertEqual((tool.TEMP_BLINK.on_ms, tool.TEMP_BLINK.off_ms), (500, 2000)) - self.assertEqual(tool.SHUTDOWN_BLINK, tool.Light(blue=255, on_ms=500, off_ms=1000)) - class StockTests(unittest.TestCase): def setUp(self): diff --git a/phoenix/pico4-slamd/PKGBUILD b/phoenix/pico4-slamd/PKGBUILD index e0b912c..c4d31d7 100644 --- a/phoenix/pico4-slamd/PKGBUILD +++ b/phoenix/pico4-slamd/PKGBUILD @@ -5,7 +5,7 @@ # (pico4-base's preinit, from the data partition's copy and the dsp partition); this package holds the # root's own programs and its mount points. The image-processing tests run natively first. pkgname=pico4-slamd -pkgver=2026.11.22 +pkgver=2026.12.4 pkgrel=1 pkgdesc="PICO 4 head tracker host for PICO OS's libSlam in its bionic root" arch=(aarch64) @@ -34,7 +34,7 @@ sha256sums=('24d211e81a71dfd7c3e59a15f4adcb46c6c64c63f7e58576378e3cf8c0c309d5' '608befe2639f75341ac4814027b8a68464dc66112bd284bbadd9040ba9b22014' 'f7fe40aa72ef0d7af23d3de894906e11630e5d36c2d3eb26018c465b6a303144' '81435015c4f43e39480e7e82b88d3208ce5d8c7eea1127917972796bd92cb79b' - '3158cf7a88e8f8d50b63f9b49d28df2ca43cdd69daacbec632e3af964ea11730') + '295ad772a5be3b0d0daa4d709df53de504546d97f1449a19ba7c8e0f42365ea2') build() { python3 -B -m unittest test_slamd diff --git a/phoenix/pico4-slamd/test_slamd.py b/phoenix/pico4-slamd/test_slamd.py index e9282bf..443be96 100644 --- a/phoenix/pico4-slamd/test_slamd.py +++ b/phoenix/pico4-slamd/test_slamd.py @@ -1,8 +1,7 @@ # SPDX-License-Identifier: Unlicense -"""pico4-slamd, PICO OS's head tracker's host in its bionic root: its build, cameras, rooms, depth mesh and floor.""" +"""pico4-slamd, PICO OS's head tracker's host in its bionic root: the depth mesh's turn to y-up.""" import math -import re import unittest from pathlib import Path @@ -14,173 +13,6 @@ def read(path: Path) -> str: return path.read_text(encoding="utf-8") -class FastRpcBridgeTests(unittest.TestCase): - def test_the_fastrpc_bridge_is_built_and_tested(self): - # The stock libraries' vendor FastRPC and ION calls, carried over to the upstream driver. - build = read(ROOT / "build.sh") - # Its translations are tested natively before the bionic library is built. - self.assertLess(build.index('"$work/test_fastrpc_bridge"'), build.index('libpico4-fastrpc-bridge.so" \\')) - bridge = read(ROOT / "fastrpc-bridge.c") - for symbol in ("\nopen(", "\n__open_2(", "\nopenat(", "\n__openat_2(", "\nioctl(", "\nclose("): - self.assertIn(symbol, bridge) - # The bridge reaches the kernel by system calls, never through the functions it replaces. - self.assertNotIn("dlsym", bridge) - - def test_build_script_stays_lf(self): - self.assertNotIn(b"\r", (ROOT / "build.sh").read_bytes()) - - -class LogTests(unittest.TestCase): - def test_the_stock_libraries_stdio_goes_nowhere_and_slamd_s_own_lines_to_the_journal(self): - slamd = read(ROOT / "pico4-slamd.c") - # As PICO OS's init: stdio on /dev/null before libSlam loads, so its own copy of each line goes nowhere. - self.assertLess(slamd.index("\tquiet_stock_stdio();"), slamd.index('dlopen("libSlam.so"')) - # stderr is /dev/null then: this program's lines go to the journal's copy of it, or nowhere. - for name in ("pico4-slamd.c", "vst.c"): - self.assertIsNone(re.search(r"\w+\(\s*stderr\b", read(ROOT / name)), name) - # Android's log: libSlam's own informational lines (its per-frame timing) stay out by default. - stubs = read(ROOT / "stubs.c") - self.assertIn('strcmp(tag, "SLAM") == 0 ? 5 : 4', stubs) - self.assertIn('getenv("PICO4_SLAMD_LOG_FD")', stubs) - - -class SlamdThreadTests(unittest.TestCase): - def test_images_on_their_own_thread(self): - # As PICO OS: frames (checkIsSync) apart from the IMU (threadReader), so a set never holds - # up the samples and their poses. - slamd = read(ROOT / "pico4-slamd.c") - frame = slamd.index("frame_thread(void *arg)") - self.assertIn("c->image(c->h, 0, &frames);", slamd[frame : slamd.index("\n}\n", frame)]) - self.assertIn("pthread_create(&thread, 0, frame_thread, &frames)", slamd) - main = slamd.index("main(int argc") - self.assertNotIn("image(h,", slamd[main:]) - self.assertIn("__atomic_store_n(&frames.imu_fed_ts, e.ts_ns, __ATOMIC_RELEASE);", slamd) - - -class TemperatureTests(unittest.TestCase): - """The IMU's die temperature with every sample, as PICO OS's sensor DSP inserts it.""" - - def test_slamd_passes_only_what_libslam_accepts(self): - slamd = read(ROOT / "pico4-slamd.c") - self.assertIn("#define TEMPERATURE_MIN -30.0", slamd) - self.assertIn("#define TEMPERATURE_MAX 100.0", slamd) - self.assertIn("sample[6] = known ? e.temperature : DEFAULT_TEMPERATURE;", slamd) - - -class CameraOtpTests(unittest.TestCase): - """The modules' ids as PICO OS's station service gets them on a fresh install.""" - - def test_saved_on_the_data_partition_where_pico_os_keeps_them(self): - slamd = read(ROOT / "pico4-slamd.c") - self.assertIn('#define OTP_PATH "/data/stationservice/camera_otp.json"', slamd) - # Saved only when PICO OS would keep them (all 8 or 9), and the saved ones offered first. - self.assertIn("isp_otp_valid(ids) ? open(OTP_PATH", slamd) - # Once saved, a driver started again while this pico4-slamd runs reads no OTP. - self.assertIn("memcpy(feed->otp_saved, ids, sizeof(ids));", slamd) - self.assertLess( - slamd.index("memcpy(feed->otp_saved, saved, sizeof(saved));"), - slamd.index("load_tables(camera_vendor(feed, generation))"), - ) - self.assertIn("isp_lsc_file(vendor)", slamd) - - -class AutoExposureTests(unittest.TestCase): - """PICO OS's auto exposure in pico4-slamd, the station commands in the driver.""" - - def test_slamd_calls_it_as_pico_os(self): - slamd = read(ROOT / "pico4-slamd.c") - self.assertIn('dlopen("libExposureImageProcess.so", RTLD_NOW)', slamd) - self.assertIn('dlsym(lib, "ExposurePredict")', slamd) - # Images after black level and lens shading, before gamma; 16-bit at the 50 Hz rate. - self.assertIn("to_ae ? g_linear[k] : 0", slamd) - self.assertIn("#define AE_FPS 50", slamd) - self.assertIn("#define AE_BIT_WIDTH 16", slamd) - # Nothing sent when it is what the set was taken with, or what was sent last. - self.assertIn("if (!own && !same)", slamd) - self.assertIn("__atomic_fetch_add(&feed->ae_written, 1, __ATOMIC_RELEASE);", slamd) - self.assertIn("__atomic_store_n(&feed->ae_generation, 0, __ATOMIC_RELEASE);", slamd) - android = read(ROOT / "android.c") - for name in ("allocate", "lock", "unlock", "release", "sendHandleToUnixSocket", "recvHandleFromUnixSocket"): - self.assertIn(f"AHardwareBuffer_{name}(", android) - - -class RoomTests(unittest.TestCase): - """PICO OS's map persistence and a SteamVR universe per room.""" - - def test_slamd_saves_every_map_with_its_rooms_shape(self): - slamd = read(ROOT / "pico4-slamd.c") - self.assertIn("room_decode((const double(*)[3])g_seen, 4, &id, sqrt) == 0", slamd) - self.assertIn("room_fit((const double(*)[3])g_seen, (const double(*)[3])shape, 4,", slamd) - self.assertIn("write_boundary(SESSION_BOUNDARY, (const double(*)[3])shape, 4);", slamd) - # The universe comes from the room's id, not from the tracker's map name. - self.assertIn("room_identity(id, feed->room_uuid, sizeof(feed->room_uuid));", slamd) - self.assertIn("room_table_add(id, map);", slamd) - # A copy left from an earlier session must not count as this one's relocalisation. - self.assertLess(slamd.index("unlink(RELOCALISED_BOUNDARY);"), slamd.index('void *h = t->create("");')) - # The clean stop that saves the map, as PICO OS's service stops the tracker. - stop = slamd.index("t->prestop(h);") - self.assertLess(stop, slamd.index('t->stop(h, "non_sleep");')) - self.assertLess(slamd.index('t->stop(h, "non_sleep");'), slamd.index("t->destroy(h);")) - - def test_slamd_restarts_a_lost_tracker_as_pico_os(self): - # PICO OS's tracking service restarts a tracker whose confidence fell from 1 to 0 - # and stayed 0 for more than restart_tracking_sec (10). - slamd = read(ROOT / "pico4-slamd.c") - self.assertIn("#define RESTART_DEFAULT_S 10", slamd) - self.assertIn("if (p->confidence == 0 && last_confidence == 1) {", slamd) - self.assertIn("lost_since = now_ns(CLOCK_BOOTTIME);", slamd) - restart = slamd.index("restarting the tracker") - self.assertLess(slamd.index("pthread_join(thread, 0);", restart), slamd.index("tracker_stop(&t, h);", restart)) - self.assertLess( - slamd.index("tracker_stop(&t, h);", restart), slamd.index("h = tracker_start(&t, feed);", restart) - ) - - def test_slamd_takes_a_late_relocalisation(self): - # The room settles when the tracker writes its copy of the saved room's boundary, also after - # a new room was decided. libSlam's callback for this does not come here. - slamd = read(ROOT / "pico4-slamd.c") - self.assertNotIn('dlsym(lib, "RelocResultCallbackRegister")', slamd) - start = slamd.index("tracker_start(const struct tracker *t") - self.assertLess(slamd.index("unlink(RELOCALISED_BOUNDARY);", start), slamd.index("t->create(", start)) - loop = slamd.index("relocalised in a saved map") - self.assertLess( - slamd.index("if (!relocalised && read_boundary(RELOCALISED_BOUNDARY, g_seen) == 4) {", loop - 400), loop - ) - self.assertLess( - loop, slamd.index("if (!room_settled && input_since != 0 && now - input_since > relocalise_ns) {") - ) - settle = slamd.index("settle_room(struct pico4_slam_feed *feed") - self.assertLess( - slamd.index("__atomic_store_n(&feed->room_state, 0, __ATOMIC_RELEASE);", settle), - slamd.index("__atomic_store_n(&feed->room_state, state, __ATOMIC_RELEASE);", settle), - ) - - def test_the_time_to_relocalise_runs_from_the_trackers_first_frames(self): - # Cameras that start 10 s late after a failed sync must not decide a new room unseen. - slamd = read(ROOT / "pico4-slamd.c") - self.assertIn("#define RELOCALISE_DEFAULT_S 10", slamd) - self.assertIn( - "if (input_since == 0 && __atomic_load_n(&frames.sets_fed, __ATOMIC_RELAXED) != sets_at_start) {", slamd - ) - # A restarted tracker starts over: its copy is removed and its first frames count again. - restart = slamd.index("restarting the tracker") - for reset in ("relocalised = false;", "sets_at_start = __atomic_load_n(&frames.sets_fed", "input_since = 0;"): - self.assertLess(restart, slamd.index(reset, restart)) - - -class FloorTests(unittest.TestCase): - """The floor libSlam detects, to SteamVR's room setup as the Frame's driver_cv sends its own.""" - - def test_slamd_passes_the_ground_with_each_pose(self): - slamd = read(ROOT / "pico4-slamd.c") - self.assertIn("p->floor_status = (uint32_t)plane_status;", slamd) - self.assertIn("p->floor_height = plane_height;", slamd) - self.assertLess( - slamd.index("p->floor_height = plane_height;"), - slamd.index("__atomic_store_n(&feed->poses_written, w + 1, __ATOMIC_RELEASE);"), - ) - - class DepthMeshTests(unittest.TestCase): """PICO OS's see-through depth mesh (libphotoid) in pico4-slamd, fed as its see-through service.""" @@ -221,65 +53,6 @@ def rot(w: float, x: float, y: float, z: float) -> list[list[float]]: for j in range(3): self.assertAlmostEqual(turned[i][j], c_r_ct[i][j]) - def test_cvp_session_answered_without_the_hardware(self): - # vst_releaseA opens a CVP session and takes its depth from FLNet on the Compute DSP. - stubs = read(ROOT / "stubs.c") - for name in ( - "cvpCreateSession", - "cvpStartSession", - "cvpStopSession", - "cvpDeleteSession", - "cvpInitDfs", - "cvpDeInitDfs", - "cvpDfs_Sync", - "cvpMemAlloc", - "cvpMemFree", - ): - self.assertIn(f"{name}(", stubs, name) - # Its image sizes stay libcvp2's own calculation. - self.assertNotIn("cvpQueryImageInfo(", stubs) - # A run of the depth from stereo fails loudly: nothing here computes it. - sync = stubs[stubs.index("cvpDfs_Sync(") :] - self.assertIn("return -1;", sync[: sync.index("cvpMemAlloc(")]) - self.assertNotIn("cvp_restart_related", read(ROOT / "vst.c")) - - def test_slamd_feeds_it_as_pico_os(self): - slamd = read(ROOT / "pico4-slamd.c") - vst = read(ROOT / "vst.c") - # libSlam's ground detection: the floor in every result, which libphotoid takes as its ground. - self.assertIn('t->set(h, "plane", "1");', slamd) - # The forward pair (cam3 left, cam2 right) with the tracker's result at the pair's time. - self.assertIn( - "vst_feed(g_images[3], g_images[2], PICO4_SLAM_FEED_W, PICO4_SLAM_FEED_H, ts, exposure_ns, head);", slamd - ) - # The map points only while the tracker tracks (type 1, confidence 1). - self.assertIn("head[0x40] == 1 && head[0x41] == 1", slamd) - self.assertIn('dlsym(lib, "AlgorithmPointCallbackRegister")', slamd) - # Only while the driver asks for meshes. - self.assertIn("__atomic_load_n(&feed->mesh_wanted_ns, __ATOMIC_ACQUIRE) <", slamd) - # The buffers before the start: the pipeline writes its first mesh without a check. - self.assertLess(vst.index("mesh_buffer(g_vst.vertices"), vst.index("int ok = start();")) - self.assertIn('"$src/crt.c" "$src/pico4-slamd.c" "$src/vst.c"', read(ROOT / "build.sh")) - - -class BuildTests(unittest.TestCase): - def test_the_tracker_links_against_bionic_stand_ins_not_pico_os_s_libraries(self): - build = read(ROOT / "build.sh") - self.assertIn('libs=(-L"$stubs")', build) - self.assertNotIn("system/lib64", build) - stubs = read(ROOT / "bionic-stubs.c") - for lib in ("LIBC", "LIBM", "LIBDL"): - self.assertIn(f"defined(STUB_{lib})", stubs) - - -class StationRateTests(unittest.TestCase): - """The cameras' rate: 50 Hz as stock, or PICO OS's 60 Hz for a faster room view.""" - - def test_auto_exposure_takes_the_measured_rate(self): - slamd = (ROOT / "pico4-slamd.c").read_text(encoding="utf-8") - self.assertIn("ts - c->last_set_ts < 36700000 ? 60 : AE_FPS", slamd) - self.assertIn("&unused, __atomic_load_n(&c->fps, __ATOMIC_RELAXED),", slamd) - if __name__ == "__main__": unittest.main() From 22ee22965808171d980358448d464463d5aec5ce Mon Sep 17 00:00:00 2001 From: Xenolphthalein <21215869+Xenolphthalein@users.noreply.github.com> Date: Fri, 4 Dec 2026 11:23:20 +0100 Subject: [PATCH 2/2] docs: AGENTS.md's testing policy: a test only for a regression that matters and nothing else covers, so the suite stays small --- AGENTS.md | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/AGENTS.md b/AGENTS.md index 81e4bf4..246d4ad 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -52,6 +52,34 @@ image ([a build](docs/develop/building.md#a-build)); from a checkout of overpres - **Releases only by the workflow** (*Actions*, *Packages*, *Run workflow* on `main`); a tag pushed by hand releases nothing, and released tags never move ([a release](docs/develop/releasing.md#a-release)). +## Testing policy + +Tests are a maintenance liability unless they provide meaningful regression protection. + +- Write the minimum number of tests necessary to verify meaningful behavior. +- Test behavior and contracts, not implementation details. +- Do not test static text, labels, constants, styling, or hardcoded configuration unless explicitly required by a + specification. +- Do not write tests asserting the absence of intentionally removed features, files, functions, or fields unless + their absence is an active security or compatibility requirement. +- Remove obsolete tests when their corresponding functionality is intentionally removed. +- Do not test private helpers, trivial getters, or framework functionality without a concrete reason. +- Do not duplicate coverage already provided by existing tests. +- Do not reproduce production logic inside test assertions. +- Do not add tests solely to increase coverage metrics. +- Prefer extending or consolidating existing tests over creating new ones. +- Never remove or weaken tests merely to make a failing build pass. + +Before adding a test, answer: + +1. What concrete regression would this test detect? +2. Would this regression matter to a user or system consumer? +3. Is this behavior already covered? +4. Would the test survive a behavior-preserving refactor? + +If a test cannot be justified, do not write it. Adding zero tests is an acceptable outcome. Before completing a task, +review all new and modified tests and remove unnecessary, redundant, brittle, or obsolete assertions. + ## Changes A branch and a pull request against `main`, titled as a conventional commit; merged by rebase or squash once `ci`