diff --git a/src/dragonball/dbs_utils/src/rate_limiter.rs b/src/dragonball/dbs_utils/src/rate_limiter.rs index 02d2264f6..c4bda8099 100644 --- a/src/dragonball/dbs_utils/src/rate_limiter.rs +++ b/src/dragonball/dbs_utils/src/rate_limiter.rs @@ -556,7 +556,8 @@ mod tests { self.processed_refill_time } - // After a restore, we cannot be certain that the last_update field has the same value. + /// Helper function to help comparing `TokenBucket` after update. + /// After a restore, we cannot be certain that the last_update field has the same value. pub fn partial_eq(&self, other: &TokenBucket) -> bool { (other.capacity() == self.capacity()) && (other.one_time_burst() == self.one_time_burst()) diff --git a/src/dragonball/src/device_manager/mod.rs b/src/dragonball/src/device_manager/mod.rs index c8ebeb3b2..7d89dcb44 100644 --- a/src/dragonball/src/device_manager/mod.rs +++ b/src/dragonball/src/device_manager/mod.rs @@ -1296,6 +1296,7 @@ mod tests { } impl DeviceManager { + /// Helper function to create a dummy DeviceManager for testing purpose pub fn new_test_mgr() -> Self { let kvm = Kvm::new().unwrap(); let vm = kvm.create_vm().unwrap(); diff --git a/src/dragonball/src/vm/mod.rs b/src/dragonball/src/vm/mod.rs index 2ac1cc39d..37e9f408f 100644 --- a/src/dragonball/src/vm/mod.rs +++ b/src/dragonball/src/vm/mod.rs @@ -874,6 +874,8 @@ impl Vm { } } +/// Unit test module for methods of struct Vm, and helper functions to shorten +/// test code. #[cfg(test)] pub mod tests { #[cfg(target_arch = "aarch64")] @@ -889,6 +891,7 @@ pub mod tests { use crate::test_utils::tests::create_vm_for_test; impl Vm { + /// Helper function to forch change `mstate` of Vms pub fn set_instance_state(&mut self, mstate: InstanceState) { self.shared_info .write() @@ -897,6 +900,7 @@ pub mod tests { } } + /// Helper function to create dummy Vm instance for testing purpose pub fn create_vm_instance() -> Vm { let instance_info = Arc::new(RwLock::new(InstanceInfo::default())); let epoll_manager = EpollManager::default();