@@ -661,7 +661,9 @@ where
661661
662662#[ cfg( test) ]
663663mod tests {
664- use super :: { Error , IotlbIterator , IovaRange , MappedRange } ;
664+ #[ cfg( feature = "backend-mmap" ) ]
665+ use super :: IotlbIterator ;
666+ use super :: { Error , IovaRange , MappedRange } ;
665667 #[ cfg( all( feature = "backend-bitmap" , feature = "backend-mmap" ) ) ]
666668 use crate :: bitmap:: AtomicBitmap ;
667669 #[ cfg( feature = "backend-mmap" ) ]
@@ -670,17 +672,20 @@ mod tests {
670672 use crate :: GuestMemoryRegion ;
671673 #[ cfg( feature = "backend-mmap" ) ]
672674 use crate :: {
673- Bytes , GuestMemoryError , GuestMemoryMmap , GuestMemoryResult , IoMemory , IommuMemory ,
675+ Bytes , GuestMemoryError , GuestMemoryMmap , GuestMemoryResult , IoMemory , Iommu , IommuMemory ,
674676 } ;
675- use crate :: { GuestAddress , Iommu , Iotlb , Permissions } ;
677+ use crate :: { GuestAddress , Iotlb , Permissions } ;
676678 use std:: fmt:: Debug ;
677679 #[ cfg( all( feature = "backend-bitmap" , feature = "backend-mmap" ) ) ]
678680 use std:: num:: NonZeroUsize ;
679681 use std:: ops:: Deref ;
682+ #[ cfg( feature = "backend-mmap" ) ]
680683 use std:: sync:: atomic:: { AtomicBool , AtomicU64 , AtomicUsize , Ordering } ;
684+ #[ cfg( feature = "backend-mmap" ) ]
681685 use std:: sync:: { RwLock , RwLockReadGuard } ;
682686
683687 #[ derive( Debug ) ]
688+ #[ cfg( feature = "backend-mmap" ) ]
684689 struct SimpleIommu {
685690 iotlb : RwLock < Iotlb > ,
686691 /// Records the last fail event's base IOVA
@@ -693,8 +698,8 @@ mod tests {
693698 next_map_to : AtomicU64 ,
694699 }
695700
701+ #[ cfg( feature = "backend-mmap" ) ]
696702 impl SimpleIommu {
697- #[ cfg( feature = "backend-mmap" ) ]
698703 fn new ( ) -> Self {
699704 SimpleIommu {
700705 iotlb : Iotlb :: new ( ) . into ( ) ,
@@ -705,22 +710,21 @@ mod tests {
705710 }
706711 }
707712
708- #[ cfg( feature = "backend-mmap" ) ]
709713 fn expect_mapping_request ( & self , to_phys : GuestAddress ) {
710714 // Clear failed range info so it can be tested after the request
711715 self . fail_base . store ( 0 , Ordering :: Relaxed ) ;
712716 self . fail_len . store ( 0 , Ordering :: Relaxed ) ;
713717 self . next_map_to . store ( to_phys. 0 , Ordering :: Relaxed ) ;
714718 }
715719
716- #[ cfg( feature = "backend-mmap" ) ]
717720 fn verify_mapping_request ( & self , virt : GuestAddress , len : usize , was_miss : bool ) {
718721 assert_eq ! ( self . fail_base. load( Ordering :: Relaxed ) , virt. 0 ) ;
719722 assert_eq ! ( self . fail_len. load( Ordering :: Relaxed ) , len) ;
720723 assert_eq ! ( self . fail_was_miss. load( Ordering :: Relaxed ) , was_miss) ;
721724 }
722725 }
723726
727+ #[ cfg( feature = "backend-mmap" ) ]
724728 impl Iommu for SimpleIommu {
725729 type IotlbGuard < ' a > = RwLockReadGuard < ' a , Iotlb > ;
726730
0 commit comments