File tree Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -495,6 +495,7 @@ mod tests {
495495 use super :: * ;
496496 #[ cfg( any( target_arch = "x86" , target_arch = "x86_64" ) ) ]
497497 use kvm_bindings:: KVM_MAX_CPUID_ENTRIES ;
498+ use libc:: { fcntl, FD_CLOEXEC , F_GETFD } ;
498499 #[ cfg( any( target_arch = "x86" , target_arch = "x86_64" ) ) ]
499500 use vmm_sys_util:: fam:: FamStruct ;
500501
@@ -503,6 +504,16 @@ mod tests {
503504 Kvm :: new ( ) . unwrap ( ) ;
504505 }
505506
507+ #[ test]
508+ fn test_open_with_cloexec ( ) {
509+ let fd = Kvm :: open_with_cloexec ( false ) . unwrap ( ) ;
510+ let flags = unsafe { fcntl ( fd, F_GETFD , 0 ) } ;
511+ assert_eq ! ( flags & FD_CLOEXEC , 0 ) ;
512+ let fd = Kvm :: open_with_cloexec ( true ) . unwrap ( ) ;
513+ let flags = unsafe { fcntl ( fd, F_GETFD , 0 ) } ;
514+ assert_eq ! ( flags & FD_CLOEXEC , FD_CLOEXEC ) ;
515+ }
516+
506517 #[ test]
507518 fn test_kvm_api_version ( ) {
508519 let kvm = Kvm :: new ( ) . unwrap ( ) ;
You can’t perform that action at this time.
0 commit comments