Rust · 1334 bytes Raw Blame History
1 //! Intentional-regression guardrails for Sprint 27.
2
3 mod common;
4
5 use std::path::PathBuf;
6
7 use common::harness::{
8 diff_macho, have_xcrun, have_xcrun_tool, link_both, load_corpus, output_section,
9 };
10
11 #[test]
12 fn mutated_text_byte_is_not_tolerated() {
13 if !have_xcrun() || !have_xcrun_tool("ld") {
14 eprintln!("skipping: xcrun as/ld unavailable");
15 return;
16 }
17
18 let root = PathBuf::from(env!("CARGO_MANIFEST_DIR"))
19 .join("tests")
20 .join("parity_corpus");
21 let case = load_corpus(&root)
22 .expect("load parity corpus")
23 .into_iter()
24 .find(|case| case.name == "hello_classic")
25 .expect("hello_classic parity case");
26
27 let outputs = link_both(&case).expect("link hello_classic with both linkers");
28 let (_, mut our_text) =
29 output_section(&outputs.ours, "__TEXT", "__text").expect("afs-ld __TEXT,__text");
30 let (_, their_text) =
31 output_section(&outputs.theirs, "__TEXT", "__text").expect("Apple __TEXT,__text");
32
33 our_text[0] ^= 0x1;
34 let report = diff_macho(&our_text, &their_text);
35 assert!(
36 !report.is_clean(),
37 "mutated text byte should be reported as critical: {report:#?}"
38 );
39 assert!(
40 !report.critical.is_empty(),
41 "expected at least one critical diff after mutation: {report:#?}"
42 );
43 }
44