okami.mom/strata

git clone https://git.nkp.pet/okami.mom/strata

Niko1221apps/host: the owner's UI and the Node App Host0b3299a01

main
1.6 KiB20 linesraw
1import assert from 'node:assert/strict';
2import { test } from 'node:test';
3import { readFile } from 'node:fs/promises';
4import { transform } from 'esbuild';
5async function moduleAt(path) { const {code}=await transform(await readFile(new URL(path,import.meta.url),'utf8'),{loader:'ts',format:'esm'}); return import(`data:text/javascript;base64,${Buffer.from(code).toString('base64')}`); }
6const {dialAngle, dialIndex, unwrapAngle, closestStop}=await moduleAt('../src/lib/tuning-controls.ts');
7const {memoryInventory}=await moduleAt('../src/lib/hardware-summary.ts');
8test('circular dial follows an arc, clamps its gap, and accepts approximate entry',()=>{
9  assert.equal(dialAngle(0,-100),0); assert.equal(dialAngle(100,0),90);
10  assert.equal(dialIndex(-135,4),0); assert.equal(dialIndex(135,4),3);
11  const overGap=unwrapAngle(-170,170); assert.equal(overGap,190); assert.equal(dialIndex(overGap,4),3);
12  assert.equal(dialIndex(unwrapAngle(170,-170),4),0);
13  assert.equal(closestStop(5000,[4096,8192,16384,32768]),4096);
14  assert.equal(closestStop(30000,[4096,8192,16384,32768]),32768);
15});
16test('memory inventory counts shared memory once and includes each dedicated GPU',()=>{
17  assert.deepEqual(memoryInventory({memory:{totalGb:16},accelerator:{unified:true},gpus:[{vramGb:16,unified:true,backend:'metal'}]}),{ram:16,vram:0,total:16,shared:true});
18  assert.deepEqual(memoryInventory({memory:{totalGb:32},accelerator:{unified:false},gpus:[{vramGb:24,unified:false,backend:'cuda'},{vramGb:12,unified:false,backend:'cuda'}]}),{ram:32,vram:36,total:68,shared:false});
19  assert.equal(memoryInventory({memory:{totalGb:32},accelerator:{unified:false},gpus:[]}).total,32);
20});