Fix warnings in tests

Remove following warnings
- unused import
- unused Result

Signed-off-by: Tim Zhang <tim@hyper.sh>
This commit is contained in:
Tim Zhang
2020-11-11 20:12:30 +08:00
parent f34225411e
commit fbd7164c29
10 changed files with 62 additions and 63 deletions
+20 -14
View File
@@ -7,7 +7,7 @@
//! Integration tests about the devices subsystem
use cgroups::devices::{DevicePermissions, DeviceType, DevicesController};
use cgroups::{Cgroup, DeviceResource, Hierarchy};
use cgroups::{Cgroup, DeviceResource};
#[test]
fn test_devices_parsing() {
@@ -22,16 +22,18 @@ fn test_devices_parsing() {
let devices: &DevicesController = cg.controller_of().unwrap();
// Deny access to all devices first
devices.deny_device(
DeviceType::All,
-1,
-1,
&vec![
DevicePermissions::Read,
DevicePermissions::Write,
DevicePermissions::MkNod,
],
);
devices
.deny_device(
DeviceType::All,
-1,
-1,
&vec![
DevicePermissions::Read,
DevicePermissions::Write,
DevicePermissions::MkNod,
],
)
.unwrap();
// Acquire the list of allowed devices after we denied all
let allowed_devices = devices.allowed_devices();
// Verify that there are no devices that we can access.
@@ -39,7 +41,9 @@ fn test_devices_parsing() {
assert_eq!(allowed_devices.unwrap(), Vec::new());
// Now add mknod access to /dev/null device
devices.allow_device(DeviceType::Char, 1, 3, &vec![DevicePermissions::MkNod]);
devices
.allow_device(DeviceType::Char, 1, 3, &vec![DevicePermissions::MkNod])
.unwrap();
let allowed_devices = devices.allowed_devices();
assert!(allowed_devices.is_ok());
let allowed_devices = allowed_devices.unwrap();
@@ -56,12 +60,14 @@ fn test_devices_parsing() {
);
// Now deny, this device explicitly.
devices.deny_device(DeviceType::Char, 1, 3, &DevicePermissions::all());
devices
.deny_device(DeviceType::Char, 1, 3, &DevicePermissions::all())
.unwrap();
// Finally, check that.
let allowed_devices = devices.allowed_devices();
// Verify that there are no devices that we can access.
assert!(allowed_devices.is_ok());
assert_eq!(allowed_devices.unwrap(), Vec::new());
}
cg.delete();
cg.delete().unwrap();
}