vmm: implement test method in mod tests
The functions get_kernel_cmdline and remove_addr are only used in tests,
but they were defined in the Vmm implementation. Add a test implementation
for Vmm in mod tests for these functions because otherwise they are
included in the coverage report.
@@ -1501,23 +1501,6 @@ impl Vmm {
Ok(())
}
-
- #[cfg(test)]
- fn get_kernel_cmdline(&self) -> &str {
- if let Some(ref k) = self.kernel_config {
- k.cmdline.as_str()
- } else {
- ""
- }
- }
-
- #[cfg(test)]
- fn remove_addr(&mut self, id: &String) {
- self.mmio_device_manager
- .as_mut()
- .unwrap()
- .remove_address(id);
- }
}
/// Starts a new vmm thread that can service API requests.
@@ -1570,6 +1553,23 @@ mod tests {
use devices::virtio::ActivateResult;
use net_util::MacAddr;
+ impl Vmm {
+ fn get_kernel_cmdline(&self) -> &str {
+ if let Some(ref k) = self.kernel_config {
+ k.cmdline.as_str()
+ } else {
+ ""
+ }
+ }
+
+ fn remove_addr(&mut self, id: &String) {
+ self.mmio_device_manager
+ .as_mut()
+ .unwrap()
+ .remove_address(id);
+ }
+ }
+
struct DummyEpollHandler {
pub evt: Option<DeviceEventT>,
pub flags: Option<u32>,
