Sync source edition with VCC Plus 3.7.0 build 63

This commit is contained in:
Brian Holman committed 2026-11-14 01:43:46 -07:00
1 parent c652a5276d
commit b2ecec4d87
86 files changed
+10519 -472

No files matched your search

+284 -29
View File
@@ -2,51 +2,306 @@
import XCTest
final class CMOCSourceMapTests: XCTestCase {
/// Explicit opt-in diagnostic for any retained custom project's immutable
/// build result. No project Makefile is executed and no emulator is loaded.
func testExplicitlySuppliedBankedBuildEvidence() throws {
private enum RetainedEvidenceFailure: Error { case missingCompilationRoot, ambiguousCompilationRoot }
/// Test harness recovery only. Ordinary CMOC markers survive optimized builds
/// even when optional VCCDBG1 type records are absent. Never infer from a Mac
/// username, output directory name or current project location.
private func retainedCompilationDirectory(files: [String: Data], entrySource: String) throws -> URL {
let pattern = try NSRegularExpression(pattern: #"\* (?:Line (.+):([0-9]+)(?::.*)?|FUNCTION .+: defined at (.+):([0-9]+))$"#)
var roots = Set<String>()
func consider(_ path: String) {
guard path.hasPrefix("/"), path.hasSuffix("/" + entrySource) else { return }
roots.insert(URL(fileURLWithPath: String(path.dropLast(entrySource.count))).standardizedFileURL.path)
}
for (name, data) in files where ["s", "lst"].contains((name as NSString).pathExtension.lowercased()) {
guard let text = String(data: data, encoding: .utf8) else { continue }
for row in text.components(separatedBy: .newlines) {
if let marker = row.range(of: "* VCCDBG1 "),
let record = try? JSONSerialization.jsonObject(with: Data(row[marker.upperBound...].utf8)) as? [String: Any],
let location = record["location"] as? String, let colon = location.lastIndex(of: ":") {
consider(String(location[..<colon]))
}
let ns = row as NSString
if let match = pattern.firstMatch(in: row, range: NSRange(location: 0, length: ns.length)) {
let index = match.range(at: 1).location == NSNotFound ? 3 : 1
consider(ns.substring(with: match.range(at: index)))
}
}
}
guard !roots.isEmpty else { throw RetainedEvidenceFailure.missingCompilationRoot }
guard roots.count == 1, let root = roots.first else { throw RetainedEvidenceFailure.ambiguousCompilationRoot }
return URL(fileURLWithPath: root, isDirectory: true)
}
private func explicitlySuppliedBankedArtifact() throws -> CMOCBuildArtifact {
guard let path = ProcessInfo.processInfo.environment["VCC_TEST_BANKED_ARTIFACT"] else {
throw XCTSkip("Supply a retained banked artifact directory for project qualification.")
}
let directory = URL(fileURLWithPath: path).resolvingSymlinksInPath()
if let expected = ProcessInfo.processInfo.environment["VCC_TEST_BANKED_ARTIFACT_ID"] {
XCTAssertEqual(directory.lastPathComponent, expected, "Qualification must read the explicitly selected artifact")
}
let project = try CMOCProject.open(at: directory)
let files = try CMOCProject.files(in: directory)
let sources = files.filter { CMOCProject.isSource($0.key) && String(data: $0.value, encoding: .utf8) != nil && !$0.value.contains(0) }
let settings = project.configuration
let entry = try XCTUnwrap(sources[settings.entrySource])
let binaryPath = try XCTUnwrap(settings.binary)
let binary = try XCTUnwrap(files[binaryPath])
// Compiler source markers retain the original isolated working folder.
// Recover it from a full, retained metadata record rather than assuming
// it is the current output folder or a historical machine path.
var compilationDirectory: URL?
for (name, data) in sources where name.hasSuffix(".s") {
guard let text = String(data: data, encoding: .utf8) else { continue }
for row in text.components(separatedBy: .newlines) {
guard let marker = row.range(of: "* VCCDBG1 "),
let record = try? JSONSerialization.jsonObject(with: Data(row[marker.upperBound...].utf8)) as? [String: Any],
let location = record["location"] as? String, let colon = location.lastIndex(of: ":") else { continue }
let sourcePath = String(location[..<colon])
if sourcePath.hasPrefix("/"), sourcePath.hasSuffix("/" + settings.entrySource) {
compilationDirectory = URL(fileURLWithPath: String(sourcePath.dropLast(settings.entrySource.count)))
break
}
}
if compilationDirectory != nil { break }
}
let artifact = CMOCBuildArtifact(id: UUID(), directory: directory, source: String(decoding: entry, as: UTF8.self),
let binaryPath = try XCTUnwrap(settings.binary), binary = try XCTUnwrap(files[binaryPath])
let manifestPath = try XCTUnwrap(settings.debugManifest), manifest = try XCTUnwrap(files[manifestPath])
print("Retained qualification identity: artifact=\(directory.lastPathComponent), manifest_sha256=\(CMOCSourceMap.sha256(manifest)), binary_sha256=\(CMOCSourceMap.sha256(binary)).")
return CMOCBuildArtifact(id: UUID(), directory: directory, source: String(decoding: entry, as: UTF8.self),
sourceData: entry, sourceSHA256: CMOCProject.sha256(entry), binaryData: binary, buildLog: "",
sources: sources, compilationDirectory: try XCTUnwrap(compilationDirectory), entrySourcePath: settings.entrySource,
binaryRelativePath: binaryPath, diskRelativePath: settings.diskImage, outputPaths: files.keys.sorted(),
debugManifestRelativePath: settings.debugManifest)
sources: sources, compilationDirectory: try retainedCompilationDirectory(files: files, entrySource: settings.entrySource),
entrySourcePath: settings.entrySource, binaryRelativePath: binaryPath, diskRelativePath: settings.diskImage,
outputPaths: files.keys.sorted(), debugManifestRelativePath: settings.debugManifest)
}
/// Explicit opt-in typed Debug qualification remains strict: a verified
/// executable does not substitute for real compiler type/function metadata.
func testExplicitlySuppliedBankedBuildEvidence() throws {
let artifact = try explicitlySuppliedBankedArtifact()
let map = try CMOCProjectSourceMap.parse(artifact: artifact)
XCTAssertNotNil(map.bankedLayout)
XCTAssertFalse(map.instructions.isEmpty)
XCTAssertNotNil(map.bankedLayout); XCTAssertFalse(map.instructions.isEmpty)
let metadata = try CMOCVariableDebug.parse(artifact: artifact, verifiedMap: map)
XCTAssertFalse(metadata.functions.isEmpty)
print("Verified retained banked artifact: \(map.bankedLayout?.modules.count ?? 0) modules, \(map.instructions.count) instructions, \(metadata.functions.count) functions, \(metadata.variables.count) variables.")
}
/// Release builds may deliberately omit type records. This separate opt-in
/// still requires complete executable/source mapping and reports typed limits.
func testExplicitlySuppliedBankedExecutableEvidence() throws {
let artifact = try explicitlySuppliedBankedArtifact()
let map = try CMOCProjectSourceMap.parse(artifact: artifact)
XCTAssertNotNil(map.bankedLayout); XCTAssertFalse(map.instructions.isEmpty)
XCTAssertFalse(map.executableSymbols.isEmpty)
let metadata: CMOCVariableDebug?, reason: String?
do { metadata = try CMOCVariableDebug.parse(artifact: artifact, verifiedMap: map); reason = nil }
catch { metadata = nil; reason = error.localizedDescription }
let fields = CMOCPublicDebugEvidence.fields(map: map, metadata: metadata, variableError: reason, sharedPaths: Set(artifact.sources.keys))
XCTAssertEqual(fields["source_map"] as? String, "verified")
if metadata == nil {
XCTAssertEqual(fields["status"] as? String, "source_only")
XCTAssertEqual(fields["variables"] as? String, "unavailable")
XCTAssertFalse(try XCTUnwrap(fields["reason"] as? String).isEmpty)
} else { XCTAssertEqual(fields["status"] as? String, "verified") }
print("Verified retained executable: \(map.bankedLayout?.modules.count ?? 0) modules, \(map.instructions.count) instructions, \(map.executableSymbols.count) executable symbols; typed metadata: \(reason ?? "verified").")
}
func testRetainedCompilationRootUsesOrdinaryMarkersWithoutInventingTypeMetadata() throws {
let root = "/private/tmp/authored build/project"
let function = Data("* FUNCTION main(): defined at \(root)/src/main.c:7\n".utf8)
XCTAssertEqual(try retainedCompilationDirectory(files: ["obj/main.s": function], entrySource: "src/main.c").path, root)
let listing = Data("(obj/main.s):00018 * Line \(root)/src/main.c:8: inline assembly\n".utf8)
XCTAssertEqual(try retainedCompilationDirectory(files: ["obj/main.lst": listing], entrySource: "src/main.c").path, root)
let metadata = Data("* VCCDBG1 {\"location\":\"\(root)/src/main.c:9\"}\n".utf8)
XCTAssertEqual(try retainedCompilationDirectory(files: ["obj/main.s": metadata], entrySource: "src/main.c").path, root)
XCTAssertThrowsError(try retainedCompilationDirectory(files: ["obj/other.s": function], entrySource: "other.c"))
let conflicting = function + Data("* Line /private/tmp/different/src/main.c:4\n".utf8)
XCTAssertThrowsError(try retainedCompilationDirectory(files: ["obj/main.s": conflicting], entrySource: "src/main.c"))
}
func testExplicitPhysicalOverlaysRequireExclusiveOwnersAndResidentCodeProof() throws {
let directory = FileManager.default.temporaryDirectory.appendingPathComponent("CMOCOverlay-" + UUID().uuidString).resolvingSymlinksInPath()
try FileManager.default.createDirectory(at: directory, withIntermediateDirectories: true)
defer { try? FileManager.default.removeItem(at: directory) }
let source = Data("void a(void) {}\nvoid b(void) {}\n".utf8)
let packed = binary([(0x0e00, [0x12])], entry: 0x0e00)
let names = ["a1", "a2", "b1", "b2"]
let opcodes: [UInt8] = [0x12, 0x39, 0x13, 0x3a]
let objectBytes = object(zip(names, opcodes).map { Section(name: $0.0, bytes: [$0.1]) })
let listing = Data(names.enumerated().flatMap { index, name in
[row("SECTION \(name)"), row("* Line main.c:\(index < 2 ? 1 : 2)"), row("NOP", offset: 0, bytes: [opcodes[index]]), row("ENDSECTION")]
}.joined(separator: "\n").utf8)
let placements = names.enumerated().map { index, name in "Section: \(name) (main.o) load at \(index % 2 == 0 ? "4000" : "5000"), length 0001" }
let map = Data((placements + ["Section: dataA (runtime.o) load at 6000, length 0001", "Section: dataB (runtime.o) load at 6000, length 0001", "Section: bssA (runtime.o) load at 6100, length 0001", "Section: bssB (runtime.o) load at 6100, length 0001", "Section: resident (runtime.o) load at 7000, length 0001"]).joined(separator: "\n").utf8)
var files = ["game.bin": packed, "game.map": map, "main.o": objectBytes, "main.lst": listing,
"a1.raw": Data([opcodes[0]]), "a2.raw": Data([opcodes[1]]), "b1.raw": Data([opcodes[2]]), "b2.raw": Data([opcodes[3]]),
"dataA.raw": Data([0x42]), "dataB.raw": Data([0x99]), "resident.raw": Data([0x39])]
var modules: [[String: Any]] = names.enumerated().map { index, name in
["id": name, "sections": [name], "codeSections": [name],
"image": ["path": name + ".raw", "logicalAddress": index % 2 == 0 ? 0x4000 : 0x5000],
"pages": [["logicalPage": 2, "physicalPage": 30]],
"overlay": ["group": "stages", "owner": index < 2 ? "A" : "B"]]
}
for owner in ["A", "B"] {
modules.append(["id": "data" + owner, "sections": ["data" + owner], "codeSections": [],
"image": ["path": "data" + owner + ".raw", "logicalAddress": 0x6000],
"pages": [["logicalPage": 3, "physicalPage": 31]], "overlay": ["group": "stages", "owner": owner]])
modules.append(["id": "bss" + owner, "sections": ["bss" + owner], "codeSections": [],
"pages": [["logicalPage": 3, "physicalPage": 31]], "overlay": ["group": "stages", "owner": owner]])
}
modules.append(["id": "resident", "sections": ["resident"], "codeSections": ["resident"],
"image": ["path": "resident.raw", "logicalAddress": 0x7000], "pages": [["logicalPage": 3, "physicalPage": 31]]])
func manifest(_ edit: (inout [String: Any]) -> Void = { _ in }) throws -> Data {
var value: [String: Any] = ["version": 2, "entryPoint": 0x0e00,
"binary": ["path": "game.bin", "sha256": CMOCSourceMap.sha256(packed)],
"linkMap": ["path": "game.map", "sha256": CMOCSourceMap.sha256(map)],
"sources": ["main.c": CMOCSourceMap.sha256(source)],
"artifacts": files.filter { $0.key != "game.bin" && $0.key != "game.map" }.mapValues(CMOCSourceMap.sha256),
"overlayGroups": [["id": "stages", "owners": ["A", "B"]]], "modules": modules]
edit(&value); return try JSONSerialization.data(withJSONObject: value)
}
func layout(_ edit: (inout [String: Any]) -> Void = { _ in }) throws -> CMOCBankedDebugLayout {
for (name, bytes) in files { try bytes.write(to: directory.appendingPathComponent(name)) }
return try CMOCBankedDebugLayout.parse(data: manifest(edit), directory: directory, sources: ["main.c": source], binary: packed,
binaryPath: "game.bin", allowedOutputs: Array(files.keys))
}
let verified = try layout()
XCTAssertTrue(verified.permitsPhysicalOverlap(between: "a1", and: "b1"))
XCTAssertFalse(verified.permitsPhysicalOverlap(between: "a1", and: "a2"))
let mapping = try CMOCProjectSourceMap.parse(sources: ["main.c": source], compilationDirectory: directory,
units: [.init(sourcePath: "main.c", sourceName: "main.c", objectName: "main.o", listing: listing, object: objectBytes)],
linkMap: map, binary: packed, bankedLayout: verified)
XCTAssertEqual(mapping.instructions.count, 4, "Distinct exclusive owners may occupy the same physical instruction identity")
XCTAssertEqual(mapping.projected(physicalPages: [2: 30, 3: 31]).activeModuleIDs, ["resident"], "Pages alone never identify an overlay owner")
var memory = Data(repeating: 0, count: 65536), available = Data(repeating: 1, count: 65536)
memory[0x4000] = opcodes[0]; memory[0x5000] = opcodes[1]; memory[0x7000] = 0x39
func selected() -> CMOCProjectSourceMap { mapping.projected(physicalPages: [2: 30, 3: 31], memory: memory, available: available) }
XCTAssertEqual(selected().activeModuleIDs, ["a1", "a2", "dataA", "bssA", "resident"])
XCTAssertEqual(selected().instructions.map(\.moduleID), ["a1", "a2"])
let typed = CMOCVariableDebug(functions: [
.init(name: "stage", sourcePath: "main.c", entry: 0x4000, body: 0x4000, end: 0x4001, frame: false, moduleID: "a1"),
.init(name: "stage", sourcePath: "main.c", entry: 0x4000, body: 0x4000, end: 0x4001, frame: false, moduleID: "b1")], variables: [
.init(name: "stateA", sourcePath: "main.c", line: 1, type: .integer, address: 0x6100, offset: nil, scope: nil, isStatic: false, moduleID: "bssA"),
.init(name: "stateB", sourcePath: "main.c", line: 2, type: .integer, address: 0x6100, offset: nil, scope: nil, isStatic: false, moduleID: "bssB"),
.init(name: "wrongScope", sourcePath: "main.c", line: 1, type: .integer, address: 0x6000, offset: nil, scope: 0x4000..<0x4001, isStatic: true, moduleID: "dataA", scopeModuleID: "b1")], sourceMap: mapping)
func typedSelection() -> CMOCVariableDebug { typed.projected(physicalPages: [2: 30, 3: 31], memory: memory, available: available) }
XCTAssertTrue(typed.projected(physicalPages: [2: 30, 3: 31]).variables.isEmpty)
XCTAssertEqual(typedSelection().variables.map(\.name), ["stateA"], "BSS inherits only its uniquely proven owner; lexical owner must also match")
XCTAssertEqual(typedSelection().entryFunction(named: "stage")?.moduleID, "a1")
memory[0x5000] = opcodes[3]
XCTAssertEqual(selected().activeModuleIDs, ["resident"], "A half-loaded owner must not establish residency")
XCTAssertTrue(typedSelection().functions.isEmpty); XCTAssertTrue(typedSelection().variables.isEmpty)
memory[0x4000] = opcodes[2]
XCTAssertEqual(selected().activeModuleIDs, ["b1", "b2", "dataB", "bssB", "resident"])
XCTAssertEqual(typedSelection().variables.map(\.name), ["stateB"])
XCTAssertEqual(typedSelection().entryFunction(named: "stage")?.moduleID, "b1")
available[0x5000] = 0
XCTAssertEqual(selected().activeModuleIDs, ["resident"], "Unavailable executable bytes never establish residency")
XCTAssertThrowsError(try layout { $0["version"] = 1 })
XCTAssertThrowsError(try layout { $0.removeValue(forKey: "overlayGroups") })
XCTAssertThrowsError(try layout { value in
var changed = modules; changed[2]["overlay"] = ["group": "stages", "owner": "A"]; value["modules"] = changed
}, "Same-owner physical overlap remains invalid")
XCTAssertThrowsError(try layout { value in
var changed = modules; changed[2].removeValue(forKey: "overlay"); value["modules"] = changed
}, "Ordinary resident code cannot share overlay storage")
XCTAssertThrowsError(try layout { value in
value["overlayGroups"] = [["id": "stages", "owners": ["A", "B", "unused"]]]
})
XCTAssertThrowsError(try layout { value in
var changed = modules; changed[5]["overlay"] = ["group": "stages", "owner": "C"]
value["modules"] = changed; value["overlayGroups"] = [["id": "stages", "owners": ["A", "B", "C"]]]
}, "A data/BSS-only owner has no immutable executable residency proof")
XCTAssertThrowsError(try layout { value in
value["overlayGroups"] = [["id": "stages", "owners": ["A", "A"]]]
})
XCTAssertThrowsError(try layout { value in
var changed = modules; changed[2]["overlay"] = ["group": "other", "owner": "C"]
value["modules"] = changed
value["overlayGroups"] = [["id": "stages", "owners": ["A", "B"]], ["id": "other", "owners": ["C", "D"]]]
}, "Different overlay groups may coexist and cannot share physical storage") {
XCTAssertTrue($0.localizedDescription.contains("module images overlap physical RAM"))
}
XCTAssertThrowsError(try layout { value in
var changed = modules; changed[0]["overlay"] = ["group": "stages", "owner": "unknown"]; value["modules"] = changed
})
XCTAssertThrowsError(try layout { value in
value["overlayGroups"] = [["id": "stages", "owners": ["A", "B"]], ["id": "stages", "owners": ["C", "D"]]]
})
XCTAssertThrowsError(try layout { value in
value["overlayGroups"] = [["id": String(repeating: "x", count: 129), "owners": ["A", "B"]]]
})
XCTAssertThrowsError(try layout { value in
value["overlayGroups"] = (0..<65).map { ["id": "g\($0)", "owners": ["A", "B"]] }
})
XCTAssertThrowsError(try layout { value in
value["overlayGroups"] = [["id": "stages", "owners": (0..<257).map { "o\($0)" }]]
})
XCTAssertThrowsError(try layout { value in
// Even null metadata cannot silently downgrade to version 1.
value["version"] = 1; value["overlayGroups"] = NSNull()
})
let catalog = CMOCPublicDebugEvidence.fields(map: mapping, metadata: nil, variableError: nil, sharedPaths: ["main.c"])
XCTAssertEqual(catalog["supported_manifest_versions"] as? [Int], [1, 2])
XCTAssertEqual(catalog["module_catalog_scope"] as? String, "verified_static_declarations_not_residency")
XCTAssertEqual((catalog["overlay_groups"] as? [[String: Any]])?.first?["owners"] as? [String], ["A", "B"])
XCTAssertNil(catalog["active_overlay_owners"], "Build declarations never assert runtime residency")
files["b1.raw"] = files["a1.raw"]; files["b2.raw"] = files["a2.raw"]
let ambiguousLayout = try layout()
let ambiguous = CMOCProjectSourceMap(entryPoint: mapping.entryPoint, binarySHA256: mapping.binarySHA256, sourceHashes: mapping.sourceHashes,
instructions: mapping.instructions, objectHashes: mapping.objectHashes, listingHashes: mapping.listingHashes,
linkMapSHA256: mapping.linkMapSHA256, bankedLayout: ambiguousLayout)
memory[0x4000] = opcodes[0]; memory[0x5000] = opcodes[1]; available[0x5000] = 1
XCTAssertEqual(ambiguous.projected(physicalPages: [2: 30, 3: 31], memory: memory, available: available).activeModuleIDs, ["resident"],
"Identical code signatures must not guess an owner or expose its BSS")
}
func testGeneratedAssemblyEvidenceUsesTypedBudgetsAndExactIdentity() throws {
let directory = FileManager.default.temporaryDirectory.appendingPathComponent("CMOCEvidence-" + UUID().uuidString).resolvingSymlinksInPath()
try FileManager.default.createDirectory(at: directory, withIntermediateDirectories: true)
defer { try? FileManager.default.removeItem(at: directory) }
let source = Data("void main(void) {}\n".utf8)
let packed = binary([(0x0e00, [0x12])], entry: 0x0e00)
let map = Data("Section: code (main.o) load at 4000, length 0001\n".utf8)
let raw = Data([0x39])
for (name, data) in ["game.bin": packed, "game.map": map, "code.raw": raw] {
try data.write(to: directory.appendingPathComponent(name))
}
var artifacts = ["code.raw": CMOCSourceMap.sha256(raw)]
func parse(outputs: [String]? = nil) throws -> CMOCBankedDebugLayout {
let value: [String: Any] = ["version": 1, "entryPoint": 0x0e00,
"binary": ["path": "game.bin", "sha256": CMOCSourceMap.sha256(packed)],
"linkMap": ["path": "game.map", "sha256": CMOCSourceMap.sha256(map)],
"sources": ["main.c": CMOCSourceMap.sha256(source)], "artifacts": artifacts,
"modules": [["id": "code", "sections": ["code"], "codeSections": ["code"],
"image": ["path": "code.raw", "logicalAddress": 0x4000],
"pages": [["logicalPage": 2, "physicalPage": 30]]]]]
return try CMOCBankedDebugLayout.parse(data: JSONSerialization.data(withJSONObject: value),
directory: directory, sources: ["main.c": source], binary: packed, binaryPath: "game.bin",
allowedOutputs: outputs ?? (["game.bin", "game.map"] + Array(artifacts.keys)))
}
// A compiler can emit large type records/data while retaining small code.
let assembly = Data(repeating: 0x3b, count: 9 * 1024 * 1024 + 17)
let path = "generated.s", file = directory.appendingPathComponent(path)
try assembly.write(to: file); artifacts[path] = CMOCSourceMap.sha256(assembly)
let verified = try parse()
XCTAssertEqual(verified.artifactHashes[path], CMOCSourceMap.sha256(assembly))
XCTAssertEqual(verified.modules.first?.physicalAddress(0x4000), 30 * 8192)
XCTAssertNoThrow(try CMOCSourceMap.validateEvidenceSize(assembly.count, path: path))
XCTAssertThrowsError(try parse(outputs: ["game.bin", "game.map", "code.raw"]))
try Data(repeating: 0x21, count: assembly.count).write(to: file)
XCTAssertThrowsError(try parse()) { XCTAssertTrue($0.localizedDescription.contains("generated.s SHA-256")) }
try FileManager.default.removeItem(at: file)
try FileManager.default.createSymbolicLink(at: file, withDestinationURL: directory.appendingPathComponent("code.raw"))
XCTAssertThrowsError(try parse()) { XCTAssertTrue($0.localizedDescription.contains("generated.s must not traverse symbolic links")) }
try FileManager.default.removeItem(at: file)
artifacts.removeValue(forKey: path)
for (name, size, limit) in [("oversized.s", 32 * 1024 * 1024 + 1, 32 * 1024 * 1024),
("oversized.lst", 8 * 1024 * 1024 + 1, 8 * 1024 * 1024)] {
let bytes = Data(repeating: 0x3b, count: size)
try bytes.write(to: directory.appendingPathComponent(name)); artifacts[name] = CMOCSourceMap.sha256(bytes)
XCTAssertThrowsError(try parse()) {
let message = $0.localizedDescription
XCTAssertTrue(message.contains(name)); XCTAssertTrue(message.contains("\(size) bytes"))
XCTAssertTrue(message.contains("\(limit) bytes"))
}
XCTAssertThrowsError(try CMOCSourceMap.validateEvidenceSize(size, path: name))
artifacts.removeValue(forKey: name)
try FileManager.default.removeItem(at: directory.appendingPathComponent(name))
}
let chunk = Data(repeating: 0x3b, count: 27 * 1024 * 1024)
let hash = CMOCSourceMap.sha256(chunk)
for index in 0..<5 {
let name = "part\(index).s"
try chunk.write(to: directory.appendingPathComponent(name)); artifacts[name] = hash
}
XCTAssertThrowsError(try parse()) {
XCTAssertTrue($0.localizedDescription.contains("aggregate limit is 134217728 bytes"))
}
}
// Small LWOBJ16 records are constructed here to exercise relocation failures
// independently of a compiler installation or personal ROM files.
private struct Section {