Files
wehub-resource-sync 85453da49f
regression / regression-shards (style-16-prod style-9-prod style-17-prod iframe-render-compat variables-prod mp4-h265-sdr, shard-4) (push) Has been cancelled
regression / regression-shards (style-4-prod style-11-prod style-2-prod animejs-adapter typegpu-adapter parallel-capture-regression, shard-5) (push) Has been cancelled
regression / regression-shards (style-7-prod style-8-prod style-10-prod css-spinner-render-compat webm-transparency mp4-h264-sdr webm-vp9, shard-3) (push) Has been cancelled
regression / regression-shards (sub-composition-video style-18-prod raf-ball-render-compat font-variant-numeric sub-comp-t0 sub-comp-id-selector, shard-7) (push) Has been cancelled
Windows render verification / Detect changes (push) Has been cancelled
Windows render verification / Preflight (lint + format) (push) Has been cancelled
Windows render verification / Render on windows-latest (push) Has been cancelled
Windows render verification / Tests on windows-latest (push) Has been cancelled
CI / Detect changes (push) Has been cancelled
CI / Build (push) Has been cancelled
CI / Lint (push) Has been cancelled
CI / Fallow audit (push) Has been cancelled
CI / Format (push) Has been cancelled
CI / Typecheck (push) Has been cancelled
CI / Test (push) Has been cancelled
CI / Producer: integration tests (push) Has been cancelled
CI / Producer: unit tests (push) Has been cancelled
CI / File size check (push) Has been cancelled
CI / Test: skills (push) Has been cancelled
CI / Skills: manifest in sync (push) Has been cancelled
CI / CLI: npx shim (macos-latest) (push) Has been cancelled
CI / CLI: npx shim (ubuntu-latest) (push) Has been cancelled
CI / CLI: npx shim (windows-latest) (push) Has been cancelled
CI / SDK: unit + contract + smoke (push) Has been cancelled
CI / Test: runtime contract (push) Has been cancelled
CI / Studio: load smoke (push) Has been cancelled
CI / Smoke: global install (push) Has been cancelled
CI / CLI smoke (required) (push) Has been cancelled
CI / Semantic PR title (push) Has been cancelled
Player perf / Detect changes (push) Has been cancelled
Player perf / Preflight (lint + format) (push) Has been cancelled
Player perf / player-perf (push) Has been cancelled
Player perf / Perf: drift (push) Has been cancelled
Player perf / Perf: fps (push) Has been cancelled
Player perf / Perf: parity (push) Has been cancelled
Player perf / Perf: scrub (push) Has been cancelled
Player perf / Perf: load (push) Has been cancelled
preview-regression / Detect changes (push) Has been cancelled
preview-regression / Preflight (lint + format) (push) Has been cancelled
preview-regression / Preview parity (push) Has been cancelled
preview-regression / preview-regression (push) Has been cancelled
regression / regression (push) Has been cancelled
regression / Detect changes (push) Has been cancelled
regression / Preflight (lint + format) (push) Has been cancelled
regression / regression-shards (hdr-regression style-5-prod style-3-prod mov-prores, shard-1) (push) Has been cancelled
regression / regression-shards (overlay-montage-prod style-12-prod chat missing-host-comp-id png-sequence portrait-edge-bleed, shard-6) (push) Has been cancelled
regression / regression-shards (style-13-prod style-6-prod vignelli-stacking gsap-letters-render-compat audio-mux-parity, shard-8) (push) Has been cancelled
regression / regression-shards (style-15-prod hdr-hlg-regression style-1-prod many-cuts vfr-screen-recording render-symlinked-assets, shard-2) (push) Has been cancelled
CodeQL / Analyze (actions) (push) Has been cancelled
CodeQL / Analyze (javascript-typescript) (push) Has been cancelled
CodeQL / Analyze (python) (push) Has been cancelled
Docs / Validate docs (push) Has been cancelled
Sync skills to ClawHub / Publish changed skills (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:58:35 +08:00

76 lines
2.7 KiB
JavaScript

import { strict as assert } from "node:assert";
import { test } from "node:test";
import { probeSpecs } from "./specs.mjs";
// Fake os module + exec so the probe is deterministic across CI machines.
const fakeOs = (over = {}) => ({
platform: () => over.platform ?? "linux",
arch: () => over.arch ?? "x64",
cpus: () => Array.from({ length: over.cores ?? 8 }),
totalmem: () => (over.ramMB ?? 16384) * 1024 * 1024,
});
test("probeSpecs reports structured caps", () => {
const s = probeSpecs({ osMod: fakeOs({ cores: 12, ramMB: 32768 }), exec: () => null });
assert.equal(s.cpuCores, 12);
assert.equal(s.ramMB, 32768);
assert.equal(s.platform, "linux");
assert.equal(s.gpu.present, false);
// probe unavailable (exec returns null) -> availableRamMB falls back to total
assert.equal(s.availableRamMB, 32768);
});
test("availableRamMB is read from /proc/meminfo on Linux", () => {
const exec = (cmd) =>
cmd.includes("meminfo") ? "MemTotal: 33554432 kB\nMemAvailable: 8388608 kB\n" : null;
const s = probeSpecs({ osMod: fakeOs({ platform: "linux", ramMB: 32768 }), exec });
assert.equal(s.availableRamMB, 8192, "8388608 kB -> 8192 MB");
});
test("availableRamMB is summed from reclaimable vm_stat pages on macOS", () => {
const vmStat =
"Mach Virtual Memory Statistics: (page size of 16384 bytes)\n" +
"Pages free: 100000.\n" +
"Pages inactive: 200000.\n" +
"Pages speculative: 50000.\n" +
"Pages purgeable: 10000.\n";
const exec = (cmd) => (cmd.includes("vm_stat") ? vmStat : null);
const s = probeSpecs({
osMod: fakeOs({ platform: "darwin", arch: "arm64", ramMB: 24576 }),
exec,
});
// (100000+200000+50000+10000) pages * 16384 B / 1MiB = 5625 MB
assert.equal(s.availableRamMB, 5625);
});
test("Apple Silicon is detected as a unified-memory GPU", () => {
const s = probeSpecs({
osMod: fakeOs({ platform: "darwin", arch: "arm64", ramMB: 24576 }),
exec: () => null,
});
assert.equal(s.appleSilicon, true);
assert.equal(s.gpu.present, true);
assert.equal(s.gpu.kind, "apple");
// unified memory: VRAM tracks system RAM
assert.equal(s.gpu.vramMB, 24576);
});
test("NVIDIA GPU is detected via nvidia-smi VRAM query", () => {
const exec = (cmd) => (cmd.includes("nvidia-smi") ? "24564" : null);
const s = probeSpecs({ osMod: fakeOs({ platform: "linux" }), exec });
assert.equal(s.gpu.present, true);
assert.equal(s.gpu.kind, "nvidia");
assert.equal(s.gpu.vramMB, 24564);
});
test("no GPU when nvidia-smi is absent / fails", () => {
const s = probeSpecs({
osMod: fakeOs({ platform: "linux" }),
exec: () => {
throw new Error("command not found");
},
});
assert.equal(s.gpu.present, false);
assert.equal(s.gpu.vramMB, 0);
});