From 84e5c98ae7fa6b0b68e7be690525dda29697ab34 Mon Sep 17 00:00:00 2001 From: Anees Iqbal Date: Sat, 7 Nov 2026 21:24:20 -0800 Subject: [PATCH] :white_check_mark: Test Kernel > Add from reims-ctl's --add-kext line reims-ctl gives reims-vgpu's kexts as --add-kext PATH alone, Graft.kext, ReimsGraphics.kext and RgfxGate.kext in that order, now that Graft replaces Lilu and the kexts need no kernel range. The test parses that command line with the real parser, makes the image's options, reads and checks the three bundles, and asserts Kernel > Add holds exactly their three entries, in that order, enabled, with an empty MinKernel and MaxKernel: nothing of the image's own goes first. --- src/opencore/config.rs | 63 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/src/opencore/config.rs b/src/opencore/config.rs index 8cc0af0..4ec45ad 100644 --- a/src/opencore/config.rs +++ b/src/opencore/config.rs @@ -413,4 +413,67 @@ mod tests { let e = &kernel_add(&template, &set)[0]; assert_eq!(fields(e, &["Comment"]), ["t.Loader"]); } + + /// reims-ctl's command line: reims-vgpu's kexts, each by its path alone, Graft first. + #[test] + fn kernel_add_from_the_command_line() { + use clap::Parser; + let graft = added::tests::info("t.graft", Some("Graft"), &[]); + let gfx = added::tests::info("t.gfx", Some("ReimsGraphics"), &[]); + let gate = added::tests::info("t.gate", Some("RgfxGate"), &["t.graft"]); + let bundles = [ + ("Graft", &graft), + ("ReimsGraphics", &gfx), + ("RgfxGate", &gate), + ] + .map(|(name, plist)| { + added::tests::Bundle::new( + &format!("{name}.kext"), + &[ + ("Contents/Info.plist", plist), + (&format!("Contents/MacOS/{name}"), &[0xcf]), + ], + ) + }); + let mut argv = vec!["reims-util".to_string(), "opencore".to_string()]; + for b in &bundles { + argv.push("--add-kext".into()); + argv.push(b.path.display().to_string()); + } + let Some(crate::cli::Command::Opencore(a)) = + crate::cli::Cli::try_parse_from(argv).unwrap().command + else { + panic!("not the opencore command"); + }; + let o = crate::cli::opencore_options(&a).unwrap(); + let kexts = o + .add_kexts + .iter() + .map(added::read) + .collect::>>() + .unwrap(); + added::check(&kexts).unwrap(); + + let mut template = Dictionary::new(); + template.insert("BundlePath".into(), "Sample.kext".into()); + template.insert("Enabled".into(), false.into()); + let got: Vec> = kernel_add(&template, &kexts) + .iter() + .map(|e| { + assert_eq!(e.as_dictionary().unwrap()["Enabled"], Value::Boolean(true)); + fields( + e, + &["BundlePath", "ExecutablePath", "MinKernel", "MaxKernel"], + ) + }) + .collect(); + assert_eq!( + got, + [ + ["Graft.kext", "Contents/MacOS/Graft", "", ""], + ["ReimsGraphics.kext", "Contents/MacOS/ReimsGraphics", "", ""], + ["RgfxGate.kext", "Contents/MacOS/RgfxGate", "", ""], + ] + ); + } }