@@ -13,27 +13,35 @@ const QEMU_ARGS: &[&str] = &[
1313pub fn run_test_kernel ( kernel_binary_path : & str ) {
1414 let kernel_path = Path :: new ( kernel_binary_path) ;
1515
16- // create an MBR disk image for legacy BIOS booting
17- let mbr_path = kernel_path. with_extension ( "mbr" ) ;
18- bootloader:: BiosBoot :: new ( kernel_path)
19- . create_disk_image ( & mbr_path)
20- . unwrap ( ) ;
16+ #[ cfg( feature = "uefi" ) ]
17+ {
18+ // create a GPT disk image for UEFI booting
19+ let gpt_path = kernel_path. with_extension ( "gpt" ) ;
20+ let uefi_builder = bootloader:: UefiBoot :: new ( kernel_path) ;
21+ uefi_builder. create_disk_image ( & gpt_path) . unwrap ( ) ;
22+
23+ // create a TFTP folder with the kernel executable and UEFI bootloader for
24+ // UEFI PXE booting
25+ let tftp_path = kernel_path. with_extension ( ".tftp" ) ;
26+ uefi_builder. create_pxe_tftp_folder ( & tftp_path) . unwrap ( ) ;
2127
22- // create a GPT disk image for UEFI booting
23- let gpt_path = kernel_path. with_extension ( "gpt" ) ;
24- let uefi_builder = bootloader:: UefiBoot :: new ( kernel_path) ;
25- uefi_builder. create_disk_image ( & gpt_path) . unwrap ( ) ;
28+ run_test_kernel_on_uefi ( & gpt_path) ;
29+ run_test_kernel_on_uefi_pxe ( & tftp_path) ;
30+ }
2631
27- // create a TFTP folder with the kernel executable and UEFI bootloader for
28- // UEFI PXE booting
29- let tftp_path = kernel_path. with_extension ( ".tftp" ) ;
30- uefi_builder. create_pxe_tftp_folder ( & tftp_path) . unwrap ( ) ;
32+ #[ cfg( feature = "bios" ) ]
33+ {
34+ // create an MBR disk image for legacy BIOS booting
35+ let mbr_path = kernel_path. with_extension ( "mbr" ) ;
36+ bootloader:: BiosBoot :: new ( kernel_path)
37+ . create_disk_image ( & mbr_path)
38+ . unwrap ( ) ;
3139
32- run_test_kernel_on_uefi ( & gpt_path) ;
33- run_test_kernel_on_bios ( & mbr_path) ;
34- run_test_kernel_on_uefi_pxe ( & tftp_path) ;
40+ run_test_kernel_on_bios ( & mbr_path) ;
41+ }
3542}
3643
44+ #[ cfg( feature = "uefi" ) ]
3745pub fn run_test_kernel_on_uefi ( out_gpt_path : & Path ) {
3846 let mut run_cmd = Command :: new ( "qemu-system-x86_64" ) ;
3947 run_cmd
@@ -57,6 +65,7 @@ pub fn run_test_kernel_on_uefi(out_gpt_path: &Path) {
5765 }
5866}
5967
68+ #[ cfg( feature = "bios" ) ]
6069pub fn run_test_kernel_on_bios ( out_mbr_path : & Path ) {
6170 let mut run_cmd = Command :: new ( "qemu-system-x86_64" ) ;
6271 run_cmd
@@ -79,6 +88,7 @@ pub fn run_test_kernel_on_bios(out_mbr_path: &Path) {
7988 }
8089}
8190
91+ #[ cfg( feature = "uefi" ) ]
8292pub fn run_test_kernel_on_uefi_pxe ( out_tftp_path : & Path ) {
8393 let mut run_cmd = Command :: new ( "qemu-system-x86_64" ) ;
8494 run_cmd. arg ( "-netdev" ) . arg ( format ! (
0 commit comments