Merge pull request #84 from ericho/ci-and-rustfmt

agent: Fix CI and rustfmt issues
This commit is contained in:
Fupan Li 2019-11-11 11:01:51 +08:00 committed by GitHub
commit cb1849cd2c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 10 additions and 15 deletions

View File

@ -9,5 +9,4 @@ set -e
cidir=$(dirname "$0")
source "${cidir}/lib.sh"
cd ${TRAVIS_BUILD_DIR}/src/agent
run_static_checks

View File

@ -138,8 +138,8 @@ mod tests {
use super::*;
use std::fs::File;
use std::io::Write;
use tempfile::tempdir;
use std::time;
use tempfile::tempdir;
const ERR_INVALID_LOG_LEVEL: &str = "invalid log level";
const ERR_INVALID_LOG_LEVEL_PARAM: &str = "invalid log level parameter";

View File

@ -13,11 +13,9 @@ use std::path::Path;
use std::sync::mpsc;
use std::sync::{Arc, Mutex};
use crate::mount::{
DRIVERBLKTYPE, DRIVERMMIOBLKTYPE, DRIVERNVDIMMTYPE, DRIVERSCSITYPE,
};
use crate::mount::{DRIVERBLKTYPE, DRIVERMMIOBLKTYPE, DRIVERNVDIMMTYPE, DRIVERSCSITYPE};
use crate::sandbox::Sandbox;
use crate::{GLOBAL_DEVICE_WATCHER, AGENT_CONFIG};
use crate::{AGENT_CONFIG, GLOBAL_DEVICE_WATCHER};
use protocols::agent::Device;
use protocols::oci::Spec;

View File

@ -51,9 +51,10 @@ pub mod netlink;
mod network;
pub mod random;
mod sandbox;
#[cfg(test)]
mod test_utils;
mod uevent;
mod version;
#[cfg(test)] mod test_utils;
use mount::{cgroups_mount, general_mount};
use sandbox::Sandbox;
@ -71,7 +72,8 @@ const CONSOLE_PATH: &'static str = "/dev/console";
lazy_static! {
static ref GLOBAL_DEVICE_WATCHER: Arc<Mutex<HashMap<String, Sender<String>>>> =
Arc::new(Mutex::new(HashMap::new()));
static ref AGENT_CONFIG: Arc<RwLock<agentConfig>> = Arc::new(RwLock::new(config::agentConfig::new()));
static ref AGENT_CONFIG: Arc<RwLock<agentConfig>> =
Arc::new(RwLock::new(config::agentConfig::new()));
}
use std::mem::MaybeUninit;
@ -299,12 +301,12 @@ lazy_static! {
// pub static mut LOG_LEVEL: ;
// pub static mut TRACE_MODE: ;
use crate::config::agentConfig;
use nix::fcntl::{self, OFlag};
use nix::sys::stat::Mode;
use std::os::unix::io::{FromRawFd, RawFd};
use std::path::PathBuf;
use std::process::{Command, Stdio};
use crate::config::agentConfig;
fn setup_debug_console(shells: Vec<String>) -> Result<()> {
for shell in shells.iter() {

View File

@ -600,7 +600,7 @@ pub fn get_cgroup_mounts(logger: &Logger, cg_path: &str) -> Result<Vec<INIT_MOUN
fstype: "cgroup",
src: "cgroup",
dest: *value,
options: vec!["nosuid", "nodev", "noexec", "relatime", key]
options: vec!["nosuid", "nodev", "noexec", "relatime", key],
});
}
}
@ -688,17 +688,13 @@ fn parse_options(option_list: Vec<String>) -> HashMap<String, String> {
#[cfg(test)]
mod tests {
use super::*;
use crate::{skip_if_not_root, skip_loop_if_not_root, skip_loop_if_root};
use libc::umount;
use std::fs::File;
use std::fs::OpenOptions;
use std::io::Write;
use std::path::PathBuf;
use tempfile::tempdir;
use crate::{
skip_if_not_root,
skip_loop_if_not_root,
skip_loop_if_root,
};
#[derive(Debug, PartialEq)]
enum TestUserType {