@@ -1068,4 +1068,51 @@ Boot0003* test";
10681068 assert_eq ! ( efi_comps, None ) ;
10691069 Ok ( ( ) )
10701070 }
1071+
1072+ #[ test]
1073+ fn test_package_mode_copy_to_boot_discovery ( ) -> Result < ( ) > {
1074+ // Test that we can discover components from /usr/lib/efi
1075+ let tmpdir: & tempfile:: TempDir = & tempfile:: tempdir ( ) ?;
1076+ let tpath = tmpdir. path ( ) ;
1077+ let efi_path = tpath. join ( "usr/lib/efi" ) ;
1078+
1079+ // Create mock EFI components
1080+ std:: fs:: create_dir_all ( efi_path. join ( "shim/15.8-3/EFI/fedora" ) ) ?;
1081+ std:: fs:: create_dir_all ( efi_path. join ( "grub2/2.12-28/EFI/fedora" ) ) ?;
1082+
1083+ // Write some test files
1084+ std:: fs:: write (
1085+ efi_path. join ( "shim/15.8-3/EFI/fedora/shimx64.efi" ) ,
1086+ b"shim content" ,
1087+ ) ?;
1088+ std:: fs:: write (
1089+ efi_path. join ( "grub2/2.12-28/EFI/fedora/grubx64.efi" ) ,
1090+ b"grub content" ,
1091+ ) ?;
1092+
1093+ let utf8_tpath =
1094+ Utf8Path :: from_path ( tpath) . ok_or_else ( || anyhow:: anyhow!( "Path is not valid UTF-8" ) ) ?;
1095+
1096+ // Test component discovery
1097+ let efi_comps = match get_efi_component_from_usr ( utf8_tpath, EFILIB ) ? {
1098+ Some ( comps) if !comps. is_empty ( ) => comps,
1099+ _ => {
1100+ anyhow:: bail!( "Should have found components" ) ;
1101+ }
1102+ } ;
1103+
1104+ // Verify we found the expected components
1105+ assert_eq ! ( efi_comps. len( ) , 2 ) ;
1106+ let names: Vec < _ > = efi_comps. iter ( ) . map ( |c| c. name . as_str ( ) ) . collect ( ) ;
1107+ assert ! ( names. contains( & "shim" ) ) ;
1108+ assert ! ( names. contains( & "grub2" ) ) ;
1109+
1110+ // Verify paths are correct
1111+ for comp in & efi_comps {
1112+ assert ! ( comp. path. starts_with( "usr/lib/efi" ) ) ;
1113+ assert ! ( comp. path. ends_with( "EFI" ) ) ;
1114+ }
1115+
1116+ Ok ( ( ) )
1117+ }
10711118}
0 commit comments