@@ -13,27 +13,35 @@ const QEMU_ARGS: &[&str] = &[
13
13
pub fn run_test_kernel ( kernel_binary_path : & str ) {
14
14
let kernel_path = Path :: new ( kernel_binary_path) ;
15
15
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 ( ) ;
21
27
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
+ }
26
31
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 ( ) ;
31
39
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
+ }
35
42
}
36
43
44
+ #[ cfg( feature = "uefi" ) ]
37
45
pub fn run_test_kernel_on_uefi ( out_gpt_path : & Path ) {
38
46
let mut run_cmd = Command :: new ( "qemu-system-x86_64" ) ;
39
47
run_cmd
@@ -57,6 +65,7 @@ pub fn run_test_kernel_on_uefi(out_gpt_path: &Path) {
57
65
}
58
66
}
59
67
68
+ #[ cfg( feature = "bios" ) ]
60
69
pub fn run_test_kernel_on_bios ( out_mbr_path : & Path ) {
61
70
let mut run_cmd = Command :: new ( "qemu-system-x86_64" ) ;
62
71
run_cmd
@@ -79,6 +88,7 @@ pub fn run_test_kernel_on_bios(out_mbr_path: &Path) {
79
88
}
80
89
}
81
90
91
+ #[ cfg( feature = "uefi" ) ]
82
92
pub fn run_test_kernel_on_uefi_pxe ( out_tftp_path : & Path ) {
83
93
let mut run_cmd = Command :: new ( "qemu-system-x86_64" ) ;
84
94
run_cmd. arg ( "-netdev" ) . arg ( format ! (
0 commit comments