ReviewOS

also looking at this

stacks/drone

test: exercise full host filesystem recovery

#58
Merged chris wants to merge codex/runtime-full-volume-recovery into main
13 files +644 -5
tests/fixtures/updates/host-project.tsmodified+8-2
Changes to tests/fixtures/updates/host-project.ts
@@ -1,12 +1,18 @@
11import { cp, mkdir, readFile, writeFile } from 'node:fs/promises'
22import { join } from 'node:path'
33
4/** Actual disposable source repo with explicit stop-reply or configure-output faults. */
5export async function createHostSourceProject(root: string, options: { fault?: 'stop-session' | 'configure-output' } = {}) {
4/** Actual disposable source repo with explicit faults and optional host-only file padding. */
5export async function createHostSourceProject(root: string, options: { fault?: 'stop-session' | 'configure-output', imagePadding?: true } = {}) {
66 const project = join(root, 'project')
77 await mkdir(project, { mode: 0o700 })
88 await mkdir(join(project, 'firmware'), { mode: 0o700 })
99 await cp(join(import.meta.dir, '../../../firmware/runtime'), join(project, 'firmware/runtime'), { recursive: true })
10 if (options.imagePadding) {
11 const path = join(project, 'firmware/runtime/src/host.cpp'), source = await readFile(path, 'utf8')
12 const entry = 'int main(int argc, char** argv) {'
13 if (source.split(entry).length !== 2) throw new Error('Owned host entry no longer matches the large-image fixture')
14 await writeFile(path, source.replace(entry, 'struct TestImagePadding { unsigned char first; unsigned char bytes[2 * 1024 * 1024]; unsigned char last; };\nvolatile TestImagePadding test_image_padding{1, {}, 1};\n' + entry + '\n if (test_image_padding.first != 1 || test_image_padding.last != 1) return 2;'))
15 }
1016 if (options.fault === 'stop-session') {
1117 const path = join(project, 'firmware/runtime/src/host.cpp'), source = await readFile(path, 'utf8')
1218 const original = 'drone::encode(runtime.status(now), bytes);'