@@ -523,12 +523,64 @@ impl InterruptHandle for LinuxInterruptHandle {
523523
524524#[ cfg( all( test, any( target_os = "windows" , kvm) ) ) ]
525525pub ( crate ) mod tests {
526- use crate :: Result ;
526+ use std:: sync:: { Arc , Mutex } ;
527+
528+ use hyperlight_testing:: dummy_guest_as_string;
529+
530+ use crate :: sandbox:: uninitialized:: GuestBinary ;
531+ #[ cfg( any( crashdump, gdb) ) ]
532+ use crate :: sandbox:: uninitialized:: SandboxRuntimeConfig ;
533+ use crate :: sandbox:: uninitialized_evolve:: set_up_hypervisor_partition;
534+ use crate :: sandbox:: { SandboxConfiguration , UninitializedSandbox } ;
535+ use crate :: { Result , is_hypervisor_present, new_error} ;
527536
528537 #[ test]
529538 fn test_initialise ( ) -> Result < ( ) > {
530- // This test was temporarily removed as part of trait abstraction removal
531- // TODO: Re-implement this test if needed for specific hypervisor functionality
539+ if !is_hypervisor_present ( ) {
540+ return Ok ( ( ) ) ;
541+ }
542+
543+ use crate :: mem:: ptr:: RawPtr ;
544+ use crate :: sandbox:: host_funcs:: FunctionRegistry ;
545+
546+ let filename = dummy_guest_as_string ( ) . map_err ( |e| new_error ! ( "{}" , e) ) ?;
547+
548+ let config: SandboxConfiguration = Default :: default ( ) ;
549+ #[ cfg( any( crashdump, gdb) ) ]
550+ let rt_cfg: SandboxRuntimeConfig = Default :: default ( ) ;
551+ let sandbox =
552+ UninitializedSandbox :: new ( GuestBinary :: FilePath ( filename. clone ( ) ) , Some ( config) ) ?;
553+ let ( mem_mgr, mut gshm) = sandbox. mgr . build ( ) ;
554+ let mut vm = set_up_hypervisor_partition (
555+ & mut gshm,
556+ & config,
557+ #[ cfg( any( crashdump, gdb) ) ]
558+ & rt_cfg,
559+ sandbox. load_info ,
560+ ) ?;
561+
562+ // Set up required parameters for initialise
563+ let peb_addr = RawPtr :: from ( 0x1000u64 ) ; // Dummy PEB address
564+ let seed = 12345u64 ; // Random seed
565+ let page_size = 4096u32 ; // Standard page size
566+ let host_funcs = Arc :: new ( Mutex :: new ( FunctionRegistry :: default ( ) ) ) ;
567+ let guest_max_log_level = Some ( log:: LevelFilter :: Error ) ;
568+
569+ #[ cfg( gdb) ]
570+ let dbg_mem_access_fn = Arc :: new ( Mutex :: new ( mem_mgr. clone ( ) ) ) ;
571+
572+ // Test the initialise method
573+ vm. initialise (
574+ peb_addr,
575+ seed,
576+ page_size,
577+ mem_mgr,
578+ host_funcs,
579+ guest_max_log_level,
580+ #[ cfg( gdb) ]
581+ dbg_mem_access_fn,
582+ ) ?;
583+
532584 Ok ( ( ) )
533585 }
534586}
0 commit comments