mirror of
https://github.com/kata-containers/cgroups-rs.git
synced 2026-08-05 02:13:23 +00:00
Run rustfmt
This commit is contained in:
committed by
Levente Kurusa
parent
5660656e3a
commit
2149e1c0c4
+2
-2
@@ -2,8 +2,8 @@
|
||||
extern crate cgroups;
|
||||
use cgroups::{Cgroup, CgroupPid};
|
||||
|
||||
extern crate nix;
|
||||
extern crate libc;
|
||||
extern crate nix;
|
||||
|
||||
#[test]
|
||||
fn test_tasks_iterator() {
|
||||
@@ -17,7 +17,7 @@ fn test_tasks_iterator() {
|
||||
// Verify that the task is indeed in the control group
|
||||
assert_eq!(tasks.next(), Some(CgroupPid::from(pid)));
|
||||
assert_eq!(tasks.next(), None);
|
||||
|
||||
|
||||
// Now, try removing it.
|
||||
cg.remove_task(CgroupPid::from(pid));
|
||||
tasks = cg.tasks().into_iter();
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
extern crate cgroups;
|
||||
|
||||
use cgroups::{Cgroup, CgroupError};
|
||||
use cgroups::cpuset::CpuSetController;
|
||||
use cgroups::{Cgroup, CgroupError};
|
||||
|
||||
#[test]
|
||||
fn test_cpuset_memory_pressure_root_cg() {
|
||||
|
||||
+21
-9
@@ -1,8 +1,8 @@
|
||||
//! Integration tests about the devices subsystem
|
||||
|
||||
extern crate cgroups;
|
||||
use cgroups::devices::{DevicePermissions, DeviceType, DevicesController};
|
||||
use cgroups::{Cgroup, DeviceResource};
|
||||
use cgroups::devices::{DevicesController, DevicePermissions, DeviceType};
|
||||
|
||||
#[test]
|
||||
fn test_devices_parsing() {
|
||||
@@ -12,7 +12,16 @@ 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,
|
||||
],
|
||||
);
|
||||
// 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.
|
||||
@@ -25,13 +34,16 @@ fn test_devices_parsing() {
|
||||
assert!(allowed_devices.is_ok());
|
||||
let allowed_devices = allowed_devices.unwrap();
|
||||
assert_eq!(allowed_devices.len(), 1);
|
||||
assert_eq!(allowed_devices[0], DeviceResource {
|
||||
allow: true,
|
||||
devtype: DeviceType::Char,
|
||||
major: 1,
|
||||
minor: 3,
|
||||
access: vec![DevicePermissions::MkNod],
|
||||
});
|
||||
assert_eq!(
|
||||
allowed_devices[0],
|
||||
DeviceResource {
|
||||
allow: true,
|
||||
devtype: DeviceType::Char,
|
||||
major: 1,
|
||||
minor: 3,
|
||||
access: vec![DevicePermissions::MkNod],
|
||||
}
|
||||
);
|
||||
|
||||
// Now deny, this device explicitly.
|
||||
devices.deny_device(DeviceType::Char, 1, 3, &DevicePermissions::all());
|
||||
|
||||
+10
-12
@@ -1,12 +1,12 @@
|
||||
//! Integration tests about the pids subsystem
|
||||
extern crate cgroups;
|
||||
use cgroups::{CgroupError, CgroupPid, Cgroup, Resources, PidResources};
|
||||
use cgroups::pid::{PidController, PidMax};
|
||||
use cgroups::Controller;
|
||||
use cgroups::{Cgroup, CgroupError, CgroupPid, PidResources, Resources};
|
||||
|
||||
extern crate nix;
|
||||
use nix::unistd::{Pid, fork, ForkResult};
|
||||
use nix::sys::wait::{waitpid, WaitStatus};
|
||||
use nix::unistd::{fork, ForkResult, Pid};
|
||||
|
||||
extern crate libc;
|
||||
use libc::pid_t;
|
||||
@@ -86,16 +86,14 @@ fn test_pid_events_is_not_zero() {
|
||||
let events = pids.get_pid_events();
|
||||
assert!(events.is_ok());
|
||||
assert_eq!(events.unwrap(), before + 1);
|
||||
},
|
||||
Ok(ForkResult::Child) => {
|
||||
loop {
|
||||
let pids_max = pids.get_pid_max();
|
||||
if pids_max.is_ok() && pids_max.unwrap() == PidMax::Value(1) {
|
||||
if let Err(_) = fork() {
|
||||
unsafe { libc::exit(0) };
|
||||
} else {
|
||||
unsafe { libc::exit(1) };
|
||||
}
|
||||
}
|
||||
Ok(ForkResult::Child) => loop {
|
||||
let pids_max = pids.get_pid_max();
|
||||
if pids_max.is_ok() && pids_max.unwrap() == PidMax::Value(1) {
|
||||
if let Err(_) = fork() {
|
||||
unsafe { libc::exit(0) };
|
||||
} else {
|
||||
unsafe { libc::exit(1) };
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
+1
-1
@@ -1,8 +1,8 @@
|
||||
//! Integration test about setting resources using `apply()`
|
||||
extern crate cgroups;
|
||||
|
||||
use cgroups::{Cgroup, Resources, PidResources};
|
||||
use cgroups::pid::{PidController, PidMax};
|
||||
use cgroups::{Cgroup, PidResources, Resources};
|
||||
|
||||
#[test]
|
||||
fn pid_resources() {
|
||||
|
||||
Reference in New Issue
Block a user