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
+10 -9
View File
@@ -5,10 +5,7 @@
//! Simple unit tests about the CPU control groups system.
use cgroups::cpu::CpuController;
use cgroups::error::ErrorKind;
use cgroups::{Cgroup, CgroupPid, CpuResources, Hierarchy, Resources};
use std::fs;
use cgroups::Cgroup;
#[test]
fn test_cfs_quota_and_periods() {
@@ -26,7 +23,7 @@ fn test_cfs_quota_and_periods() {
assert_eq!(100000, current_peroid);
// case 1 set quota
let r = cpu_controller.set_cfs_quota(2000);
let _ = cpu_controller.set_cfs_quota(2000);
let current_quota = cpu_controller.cfs_quota().unwrap();
let current_peroid = cpu_controller.cfs_period().unwrap();
@@ -34,14 +31,16 @@ fn test_cfs_quota_and_periods() {
assert_eq!(100000, current_peroid);
// case 2 set period
cpu_controller.set_cfs_period(1000000);
cpu_controller.set_cfs_period(1000000).unwrap();
let current_quota = cpu_controller.cfs_quota().unwrap();
let current_peroid = cpu_controller.cfs_period().unwrap();
assert_eq!(2000, current_quota);
assert_eq!(1000000, current_peroid);
// case 3 set both quota and period
cpu_controller.set_cfs_quota_and_period(Some(5000), Some(100000));
cpu_controller
.set_cfs_quota_and_period(Some(5000), Some(100000))
.unwrap();
let current_quota = cpu_controller.cfs_quota().unwrap();
let current_peroid = cpu_controller.cfs_period().unwrap();
@@ -49,12 +48,14 @@ fn test_cfs_quota_and_periods() {
assert_eq!(100000, current_peroid);
// case 4 set both quota and period, set quota to -1
cpu_controller.set_cfs_quota_and_period(Some(-1), None);
cpu_controller
.set_cfs_quota_and_period(Some(-1), None)
.unwrap();
let current_quota = cpu_controller.cfs_quota().unwrap();
let current_peroid = cpu_controller.cfs_period().unwrap();
assert_eq!(-1, current_quota);
assert_eq!(100000, current_peroid);
cg.delete();
cg.delete().unwrap();
}