import assert from 'node:assert/strict'; import {shutdownHostFixture} from './k2150-el0-storage-host-fixture.mjs'; import {checkShutdownProfile,checkProfile} from './k2150-el0-storage-check.mjs'; let rejected=0; function mutateEverySnapshot(input,index){ for(const s of input.stages){ const calls=Number(s.el0.readBigUInt64LE(16*8)); if(index<32||index<32+calls*16)s.el0.writeBigUInt64LE(s.el0.readBigUInt64LE(index*8)^1n,index*8); } input.el0Final=Buffer.from(input.stages.at(-1).el0); } for(const caseId of [0,1,2]){ const input=shutdownHostFixture(caseId);assert.equal(checkShutdownProfile(input).el0StorageVerified,true); assert.throws(()=>checkProfile(input));rejected++; // Coordinated changes in every copy avoid merely testing snapshot equality. for(let i=0;i<240;i++){ const bad=shutdownHostFixture(caseId);mutateEverySnapshot(bad,i); assert.throws(()=>checkShutdownProfile(bad),`case ${caseId} semantic word ${i}`);rejected++; } for(const pid of [1,9]){const bad=shutdownHostFixture(caseId);bad.programs[pid].writeUInt32LE(0xd503201f);assert.throws(()=>checkShutdownProfile(bad));rejected++;} const absent=shutdownHostFixture(caseId);absent.stages=absent.stages.filter(s=>s.stage!==200);assert.throws(()=>checkShutdownProfile(absent));rejected++; } console.log(JSON.stringify({status:'EL0_STORAGE_CHECKER_HOST_CONTROLS_PASSED',hostFixtures:3,semanticForgeriesRejected:rejected, guestExecuted:false,physicalStorageVerified:false,requiresRealMatrix:true}));