import { setupTest, startEngine, openCmdFifo, wait, ensureGenTone, execSync, readStatusNonBlock, teardownTest } from './test_utils'; import * as globals from "./test_globals"; export async function testStatusFifoLevelLine(): Promise { console.log("\nTest: STATUS FIFO LEVEL LINE AFTER TONE"); const engine = await startEngine(); openCmdFifo(); await wait(500); // Play tone directly (not through TUI) ensureGenTone(); execSync(`${globals.GEN_TONE_BIN} 1.0 "looper:ch0in"`, { timeout: 5000 }); // Wait for engine to write status await wait(2000); // Read status FIFO directly const data = readStatusNonBlock(); const hasLevel = data.includes("LEVEL="); console.log(" Status FIFO data:", data.slice(0, 500)); if (hasLevel) { console.log(" PASS: LEVEL line found in status FIFO"); } else { console.log(" FAIL: No LEVEL line in status FIFO. Check engine RMS computation."); engine.kill(); teardownTest(); throw new Error("Level line missing from status FIFO"); } engine.kill(); teardownTest(); }