@@ -598,41 +598,45 @@ mod tests {
598
598
handle_child_output ( & tmp_dir, r, & output) ;
599
599
}
600
600
601
- const FOCAL_IMAGE_NAME : & str = "focal-server-cloudimg-amd64-raw.img" ;
602
- const JAMMY_IMAGE_NAME : & str = "jammy-server-cloudimg-amd64-raw.img" ;
603
- const CLEAR_IMAGE_NAME : & str = "clear-31311-cloudguest.img" ;
601
+ mod x86_64 {
602
+ use super :: * ;
604
603
605
- #[ test]
606
- fn test_boot_qemu_focal ( ) {
607
- test_boot ( FOCAL_IMAGE_NAME , & UbuntuCloudInit { } , spawn_qemu)
608
- }
604
+ const FOCAL_IMAGE_NAME : & str = "focal-server-cloudimg-amd64-raw.img" ;
605
+ const JAMMY_IMAGE_NAME : & str = "jammy-server-cloudimg-amd64-raw.img" ;
606
+ const CLEAR_IMAGE_NAME : & str = "clear-31311-cloudguest.img" ;
609
607
610
- #[ test]
611
- fn test_boot_qemu_jammy ( ) {
612
- test_boot ( JAMMY_IMAGE_NAME , & UbuntuCloudInit { } , spawn_qemu)
613
- }
608
+ #[ test]
609
+ fn test_boot_qemu_focal ( ) {
610
+ test_boot ( FOCAL_IMAGE_NAME , & UbuntuCloudInit { } , spawn_qemu)
611
+ }
614
612
615
- #[ test]
616
- fn test_boot_qemu_clear ( ) {
617
- test_boot ( CLEAR_IMAGE_NAME , & ClearCloudInit { } , spawn_qemu)
618
- }
613
+ #[ test]
614
+ fn test_boot_qemu_jammy ( ) {
615
+ test_boot ( JAMMY_IMAGE_NAME , & UbuntuCloudInit { } , spawn_qemu)
616
+ }
619
617
620
- #[ test]
621
- #[ cfg( not( feature = "coreboot" ) ) ]
622
- fn test_boot_ch_focal ( ) {
623
- test_boot ( FOCAL_IMAGE_NAME , & UbuntuCloudInit { } , spawn_ch)
624
- }
618
+ #[ test]
619
+ fn test_boot_qemu_clear ( ) {
620
+ test_boot ( CLEAR_IMAGE_NAME , & ClearCloudInit { } , spawn_qemu)
621
+ }
625
622
626
- #[ test]
627
- #[ cfg( not( feature = "coreboot" ) ) ]
628
- fn test_boot_ch_jammy ( ) {
629
- test_boot ( JAMMY_IMAGE_NAME , & UbuntuCloudInit { } , spawn_ch)
630
- }
623
+ #[ test]
624
+ #[ cfg( not( feature = "coreboot" ) ) ]
625
+ fn test_boot_ch_focal ( ) {
626
+ test_boot ( FOCAL_IMAGE_NAME , & UbuntuCloudInit { } , spawn_ch)
627
+ }
631
628
632
- #[ test]
633
- #[ cfg( not( feature = "coreboot" ) ) ]
634
- fn test_boot_ch_clear ( ) {
635
- test_boot ( CLEAR_IMAGE_NAME , & ClearCloudInit { } , spawn_ch)
629
+ #[ test]
630
+ #[ cfg( not( feature = "coreboot" ) ) ]
631
+ fn test_boot_ch_jammy ( ) {
632
+ test_boot ( JAMMY_IMAGE_NAME , & UbuntuCloudInit { } , spawn_ch)
633
+ }
634
+
635
+ #[ test]
636
+ #[ cfg( not( feature = "coreboot" ) ) ]
637
+ fn test_boot_ch_clear ( ) {
638
+ test_boot ( CLEAR_IMAGE_NAME , & ClearCloudInit { } , spawn_ch)
639
+ }
636
640
}
637
641
}
638
642
@@ -709,78 +713,83 @@ mod tests {
709
713
handle_child_output ( & tmp_dir, r, & output) ;
710
714
}
711
715
712
- #[ test]
713
- #[ ignore] // Windows guest test on QEMU is not supported yet.
714
- #[ cfg( not( feature = "coreboot" ) ) ]
715
- fn test_boot_qemu_windows ( ) {
716
- let fw = Firmware {
717
- fw_type : "-kernel" ,
718
- path : "target/x86_64-unknown-none/release/hypervisor-fw" ,
719
- } ;
720
- test_boot_qemu_windows_common ( & fw) ;
721
- }
722
-
723
- #[ test]
724
- #[ ignore] // Windows guest test on QEMU is not supported yet.
725
- #[ cfg( feature = "coreboot" ) ]
726
- fn test_boot_qemu_windows ( ) {
727
- let fw = Firmware {
728
- fw_type : "-bios" ,
729
- path : "resources/coreboot/coreboot/build/coreboot.rom" ,
730
- } ;
731
- test_boot_qemu_windows_common ( & fw) ;
732
- }
733
-
734
- #[ test]
735
- #[ cfg( not( feature = "coreboot" ) ) ]
736
- fn test_boot_ch_windows ( ) {
737
- let mut disk = WindowsDiskConfig :: new ( WINDOWS_IMAGE_NAME . to_string ( ) ) ;
738
- let tmp_dir = TempDir :: new ( ) . expect ( "Expect creating temporary directory to succeed" ) ;
739
- prepare_windows_os_disk ( & mut disk, & tmp_dir) ;
740
-
741
- let clh_path = dirs:: home_dir ( )
742
- . unwrap ( )
743
- . join ( "workloads" )
744
- . join ( "cloud-hypervisor" ) ;
745
- let mut c = Command :: new ( clh_path. to_str ( ) . unwrap ( ) ) ;
746
- c. args ( [
747
- "--cpus" ,
748
- "boot=2,kvm_hyperv=on" ,
749
- "--memory" ,
750
- "size=4G" ,
751
- "--console" ,
752
- "off" ,
753
- "--serial" ,
754
- "tty" ,
755
- "--kernel" ,
756
- "target/x86_64-unknown-none/release/hypervisor-fw" ,
757
- "--disk" ,
758
- & format ! ( "path={}" , disk. osdisk_path) ,
759
- "--net" ,
760
- "tap=" ,
761
- ] ) ;
762
-
763
- let stdout = fs:: File :: create ( tmp_dir. path ( ) . join ( "stdout" ) ) . unwrap ( ) ;
764
- let stderr = fs:: File :: create ( tmp_dir. path ( ) . join ( "stderr" ) ) . unwrap ( ) ;
716
+ mod x86_64 {
717
+ use super :: * ;
718
+
719
+ #[ test]
720
+ #[ ignore] // Windows guest test on QEMU is not supported yet.
721
+ #[ cfg( not( feature = "coreboot" ) ) ]
722
+ fn test_boot_qemu_windows ( ) {
723
+ let fw = Firmware {
724
+ fw_type : "-kernel" ,
725
+ path : "target/x86_64-unknown-none/release/hypervisor-fw" ,
726
+ } ;
727
+ test_boot_qemu_windows_common ( & fw) ;
728
+ }
765
729
766
- eprintln ! ( "Spawning: {:?}" , c) ;
767
- let mut child = c
768
- . stdout ( Stdio :: from ( stdout) )
769
- . stderr ( Stdio :: from ( stderr) )
770
- . spawn ( )
771
- . expect ( "Expect launching Cloud Hypervisor to succeed" ) ;
730
+ #[ test]
731
+ #[ ignore] // Windows guest test on QEMU is not supported yet.
732
+ #[ cfg( feature = "coreboot" ) ]
733
+ fn test_boot_qemu_windows ( ) {
734
+ let fw = Firmware {
735
+ fw_type : "-bios" ,
736
+ path : "resources/coreboot/coreboot/build/coreboot.rom" ,
737
+ } ;
738
+ test_boot_qemu_windows_common ( & fw) ;
739
+ }
772
740
773
- thread:: sleep ( std:: time:: Duration :: from_secs ( 60 ) ) ;
774
- let r = std:: panic:: catch_unwind ( || {
775
- let auth = windows_auth ( ) ;
776
- ssh_command_with_auth ( "192.168.249.2" , "shutdown /s" , & auth)
777
- . expect ( "Expect SSH command to work" ) ;
778
- } ) ;
741
+ #[ test]
742
+ #[ cfg( not( feature = "coreboot" ) ) ]
743
+ fn test_boot_ch_windows ( ) {
744
+ let mut disk = WindowsDiskConfig :: new ( WINDOWS_IMAGE_NAME . to_string ( ) ) ;
745
+ let tmp_dir =
746
+ TempDir :: new ( ) . expect ( "Expect creating temporary directory to succeed" ) ;
747
+ prepare_windows_os_disk ( & mut disk, & tmp_dir) ;
748
+
749
+ let clh_path = dirs:: home_dir ( )
750
+ . unwrap ( )
751
+ . join ( "workloads" )
752
+ . join ( "cloud-hypervisor" ) ;
753
+ let mut c = Command :: new ( clh_path. to_str ( ) . unwrap ( ) ) ;
754
+ c. args ( [
755
+ "--cpus" ,
756
+ "boot=2,kvm_hyperv=on" ,
757
+ "--memory" ,
758
+ "size=4G" ,
759
+ "--console" ,
760
+ "off" ,
761
+ "--serial" ,
762
+ "tty" ,
763
+ "--kernel" ,
764
+ "target/x86_64-unknown-none/release/hypervisor-fw" ,
765
+ "--disk" ,
766
+ & format ! ( "path={}" , disk. osdisk_path) ,
767
+ "--net" ,
768
+ "tap=" ,
769
+ ] ) ;
770
+
771
+ let stdout = fs:: File :: create ( tmp_dir. path ( ) . join ( "stdout" ) ) . unwrap ( ) ;
772
+ let stderr = fs:: File :: create ( tmp_dir. path ( ) . join ( "stderr" ) ) . unwrap ( ) ;
773
+
774
+ eprintln ! ( "Spawning: {:?}" , c) ;
775
+ let mut child = c
776
+ . stdout ( Stdio :: from ( stdout) )
777
+ . stderr ( Stdio :: from ( stderr) )
778
+ . spawn ( )
779
+ . expect ( "Expect launching Cloud Hypervisor to succeed" ) ;
780
+
781
+ thread:: sleep ( std:: time:: Duration :: from_secs ( 60 ) ) ;
782
+ let r = std:: panic:: catch_unwind ( || {
783
+ let auth = windows_auth ( ) ;
784
+ ssh_command_with_auth ( "192.168.249.2" , "shutdown /s" , & auth)
785
+ . expect ( "Expect SSH command to work" ) ;
786
+ } ) ;
779
787
780
- child. kill ( ) . unwrap ( ) ;
781
- let output = child. wait_with_output ( ) . unwrap ( ) ;
788
+ child. kill ( ) . unwrap ( ) ;
789
+ let output = child. wait_with_output ( ) . unwrap ( ) ;
782
790
783
- handle_child_output ( & tmp_dir, r, & output) ;
791
+ handle_child_output ( & tmp_dir, r, & output) ;
792
+ }
784
793
}
785
794
}
786
795
}
0 commit comments