/** * Static getconf entries for POSIX-ish shared memory / IPC hints. */ import { readFile } from 'node:fs/promises' import path from 'node:path' import { fileURLToPath } from 'node:url' import test from 'brittle' const __dirname = path.dirname(fileURLToPath(import.meta.url)) const AsyncFunction = Object.getPrototypeOf(async function () {}).constructor async function loadBin(name) { const runtime = await readFile( path.join(__dirname, '../lib/runtime.js'), 'utf8' ) const body = await readFile( path.join(__dirname, `../src/${name}.js`), 'utf8' ) return new AsyncFunction( 'ctx', 'argv', `${runtime}\n${body}\nif (typeof run === 'function') return await run(ctx, argv)\n` ) } test('getconf _POSIX_SHARED_MEMORY_OBJECTS is 1', async (t) => { const run = await loadBin('getconf') const lines = [] const ctx = { console: { log: (m) => lines.push(String(m)) }, exitCode: 0 } await run(ctx, ['getconf', '_POSIX_SHARED_MEMORY_OBJECTS']) t.is(ctx.exitCode, 0) t.is(lines[0], '1') }) test('getconf BARE_OS_GUEST_SENSITIVE_BARE_DENY catalog entry', async (t) => { const run = await loadBin('getconf') const lines = [] const ctx = { vfs: { env: {} }, console: { log(s) { lines.push(String(s)) }, error() {} }, exitCode: 0, b4a: await import('b4a') } await run(ctx, ['getconf', 'BARE_OS_GUEST_SENSITIVE_BARE_DENY']) t.is(lines.join('\n').trim(), '1') }) test('getconf _SC_PAGESIZE static table', async (t) => { const run = await loadBin('getconf') const lines = [] const ctx = { console: { log: (m) => lines.push(String(m)) }, exitCode: 0 } await run(ctx, ['getconf', '_SC_PAGESIZE']) t.is(ctx.exitCode, 0) t.is(lines[0], '4096') })