Files
orca/config/scripts/performance/idle-cpu/idle-cpu-process-sampling.test.mjs

21 lines
881 B
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { spawn } from 'node:child_process'
import { describe, expect, it } from 'vitest'
import { readProcessRows } from './idle-cpu-process-sampling.mjs'
describe.skipIf(process.platform !== 'win32')('Windows process table read', () => {
// Timeout exceeds reader’s 60s bound; cold PowerShell 5.1 has reached 48s on CI, so this is not a latency budget.
it('parses a command line whose characters the OEM code page maps to control bytes', () => {
const marker = 'idle-cpu-oem • → ♪'
const child = spawn(process.execPath, ['-e', 'setInterval(() => {}, 60_000)', marker], {
stdio: 'ignore'
})
try {
const row = readProcessRows().find((candidate) => candidate.pid === child.pid)
expect(row?.command).toContain(marker)
expect(row?.cpuTimeSeconds).toEqual(expect.any(Number))
} finally {
child.kill()
}
}, 75_000)
})