1
1
use bootloader:: BootConfig ;
2
+ use bootloader:: DiskImageBuilder ;
2
3
use std:: { io:: Read , path:: Path , process:: Command } ;
3
4
4
5
const QEMU_ARGS : & [ & str ] = & [
@@ -31,26 +32,20 @@ pub fn run_test_kernel_internal(
31
32
config_file_path : Option < & BootConfig > ,
32
33
) {
33
34
let kernel_path = Path :: new ( kernel_binary_path) ;
35
+ let mut image_builder = DiskImageBuilder :: new ( kernel_path) ;
36
+ if let Some ( rdp) = ramdisk_path {
37
+ image_builder. set_ramdisk ( rdp) ;
38
+ }
39
+ if let Some ( cfp) = config_file_path {
40
+ image_builder. set_boot_config ( cfp) ;
41
+ }
34
42
35
43
#[ cfg( feature = "uefi" ) ]
36
44
{
37
- // create a GPT disk image for UEFI booting
38
45
let gpt_path = kernel_path. with_extension ( "gpt" ) ;
39
- let mut uefi_builder = bootloader:: UefiBoot :: new ( kernel_path) ;
40
- // Set ramdisk for test, if supplied.
41
- if let Some ( rdp) = ramdisk_path {
42
- uefi_builder. set_ramdisk ( rdp) ;
43
- }
44
- if let Some ( cfp) = config_file_path {
45
- uefi_builder. set_boot_config ( cfp) ;
46
- }
47
- uefi_builder. create_disk_image ( & gpt_path) . unwrap ( ) ;
48
-
49
- // create a TFTP folder with the kernel executable and UEFI bootloader for
50
- // UEFI PXE booting
51
46
let tftp_path = kernel_path. with_extension ( "tftp" ) ;
52
- uefi_builder . create_pxe_tftp_folder ( & tftp_path ) . unwrap ( ) ;
53
-
47
+ image_builder . create_uefi_image ( & gpt_path ) . unwrap ( ) ;
48
+ image_builder . create_uefi_tftp_folder ( & tftp_path ) . unwrap ( ) ;
54
49
run_test_kernel_on_uefi ( & gpt_path) ;
55
50
run_test_kernel_on_uefi_pxe ( & tftp_path) ;
56
51
}
@@ -59,32 +54,10 @@ pub fn run_test_kernel_internal(
59
54
{
60
55
// create an MBR disk image for legacy BIOS booting
61
56
let mbr_path = kernel_path. with_extension ( "mbr" ) ;
62
- let mut bios_builder = bootloader:: BiosBoot :: new ( kernel_path) ;
63
- // Set ramdisk for test, if supplied.
64
- if let Some ( rdp) = ramdisk_path {
65
- bios_builder. set_ramdisk ( rdp) ;
66
- }
67
- if let Some ( cfp) = config_file_path {
68
- bios_builder. set_boot_config ( cfp) ;
69
- }
70
- bios_builder. create_disk_image ( & mbr_path) . unwrap ( ) ;
57
+ image_builder. create_bios_image ( mbr_path. as_path ( ) ) . unwrap ( ) ;
71
58
72
59
run_test_kernel_on_bios ( & mbr_path) ;
73
60
}
74
-
75
- #[ cfg( feature = "uefi" ) ]
76
- {
77
- let gpt_path = kernel_path_buf. with_extension ( "gpt" ) ;
78
- let tftp_path = kernel_path_buf. with_extension ( "tftp" ) ;
79
- image_builder. create_uefi_image ( & gpt_path) . unwrap ( ) ;
80
- image_builder. create_uefi_tftp_folder ( & tftp_path) . unwrap ( ) ;
81
- run_test_kernel_on_uefi ( & gpt_path) ;
82
- run_test_kernel_on_uefi_pxe ( & tftp_path) ;
83
- }
84
- }
85
-
86
- pub fn run_test_kernel ( kernel_binary_path : & str ) {
87
- run_test_kernel_with_ramdisk ( kernel_binary_path, None ) ;
88
61
}
89
62
90
63
#[ cfg( feature = "uefi" ) ]
0 commit comments