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.4 KiB18 linesraw
1import assert from 'node:assert/strict';
2import {test} from 'node:test';
3import {readFile} from 'node:fs/promises';
4import {transform} from 'esbuild';
5const {code}=await transform(await readFile(new URL('../src/lib/hardware-summary.ts',import.meta.url),'utf8'),{loader:'ts',format:'esm'});
6const {memoryInventory}=await import(`data:text/javascript;base64,${Buffer.from(code).toString('base64')}`);
7test('RAM and every dedicated GPU contribute to the aggregate inventory',()=>{
8 const hardware={memory:{totalGb:64},accelerator:{unified:false},gpus:[{unified:false,backend:'cuda',vramGb:24},{unified:false,backend:'cuda',vramGb:16}]};
9 assert.deepEqual(memoryInventory(hardware),{ram:64,vram:40,total:104,shared:false});
10});
11test('unified GPU memory is counted once, even with multiple reported shared GPU pools',()=>{
12 const hardware={memory:{totalGb:16},accelerator:{unified:true},gpus:[{unified:true,backend:'metal',vramGb:16},{unified:true,backend:'metal',vramGb:16}]};
13 assert.deepEqual(memoryInventory(hardware),{ram:16,vram:0,total:16,shared:true});
14});
15test('shared GPU memory is excluded when dedicated GPUs are also connected',()=>{
16 const hardware={memory:{totalGb:32},accelerator:{unified:true},gpus:[{unified:true,backend:'metal',vramGb:32},{unified:false,backend:'cuda',vramGb:24},{unified:false,backend:'cuda',vramGb:16}]};
17 assert.deepEqual(memoryInventory(hardware),{ram:32,vram:40,total:72,shared:false});
18});