Repository Public
1// SP Lecture Studio — Tests2// File: Tests/Tools/CrashSim/main.swift3// Description: Helper process for the crash test: records synthetic audio with the real engine until it is killed with SIGKILL.4//5// Author: Simon-Pierre Boucher6// Contact: contact@spboucher.ai7import Foundation8import LectureCore9import LectureStorage10import LectureCapture11import LectureTesting1213// usage: lecture-crashsim <directory> <segmentSeconds> <secondsBeforeReady>14let args = CommandLine.arguments15guard args.count == 4, let segment = Double(args[2]), let before = Double(args[3]) else { fputs("usage\n", stderr); exit(2) }16let dir = URL(fileURLWithPath: args[1])17let pdf = Fixtures.makePDF(at: dir.appendingPathComponent("sim.pdf"), pages: 3)18let pkg = try ProjectPackage.create(in: dir, manifest: ProjectManifest(title: "CrashSim"), pdf: pdf, pdfPageCount: 3)19let source = SyntheticAudioSource()20var cfg = RecordingConfiguration(); cfg.segmentSeconds = segment21let engine = RecordingEngine(package: pkg, manifest: try pkg.loadManifest(), log: try EventLogWriter(url: pkg.eventsURL, syncInterval: 0.2), audio: source, configuration: cfg)22engine.useHostClock { source.hostTime }23try engine.start(currentPage: 0)24source.push(seconds: before)25engine.record(.marker(Marker(kind: .chapter, label: "before-kill")))26print("READY \(pkg.url.path)"); fflush(stdout)27// Keep recording in real time until the parent kills this process. No clean-up code ever runs.28while true { source.push(seconds: 0.1); usleep(100_000) }29