diff options
author | Costin-Robert Sin <sin.costinrobert@gmail.com> | 2022-06-21 15:36:05 +0300 |
---|---|---|
committer | Costin-Robert Sin <sin.costinrobert@gmail.com> | 2022-06-24 00:35:52 +0300 |
commit | 3e6cb639f0d9afde57d9cc03526c2e488641231b (patch) | |
tree | c882f2947fa5b22e67a58918c45012655b892b30 /test/test_kmod/mod.rs | |
parent | 8f08a69c28fad5ee875d69e4c8a1b8eed2203cb4 (diff) | |
download | nix-3e6cb639f0d9afde57d9cc03526c2e488641231b.zip |
Fix all formating problems to pass CI formating test
Signed-off-by: Costin-Robert Sin <sin.costinrobert@gmail.com>
Diffstat (limited to 'test/test_kmod/mod.rs')
-rw-r--r-- | test/test_kmod/mod.rs | 58 |
1 files changed, 41 insertions, 17 deletions
diff --git a/test/test_kmod/mod.rs b/test/test_kmod/mod.rs index 8eef5384..5ebc2423 100644 --- a/test/test_kmod/mod.rs +++ b/test/test_kmod/mod.rs @@ -1,22 +1,25 @@ +use crate::*; use std::fs::copy; use std::path::PathBuf; use std::process::Command; use tempfile::{tempdir, TempDir}; -use crate::*; fn compile_kernel_module() -> (PathBuf, String, TempDir) { let _m = crate::FORK_MTX.lock(); - let tmp_dir = tempdir().expect("unable to create temporary build directory"); + let tmp_dir = + tempdir().expect("unable to create temporary build directory"); copy( "test/test_kmod/hello_mod/hello.c", &tmp_dir.path().join("hello.c"), - ).expect("unable to copy hello.c to temporary build directory"); + ) + .expect("unable to copy hello.c to temporary build directory"); copy( "test/test_kmod/hello_mod/Makefile", &tmp_dir.path().join("Makefile"), - ).expect("unable to copy Makefile to temporary build directory"); + ) + .expect("unable to copy Makefile to temporary build directory"); let status = Command::new("make") .current_dir(tmp_dir.path()) @@ -51,12 +54,16 @@ fn test_finit_and_delete_module() { delete_module( &CString::new(kmod_name).unwrap(), DeleteModuleFlags::empty(), - ).expect("unable to unload kernel module"); + ) + .expect("unable to unload kernel module"); } #[test] fn test_finit_and_delete_module_with_params() { - require_capability!("test_finit_and_delete_module_with_params", CAP_SYS_MODULE); + require_capability!( + "test_finit_and_delete_module_with_params", + CAP_SYS_MODULE + ); let _m0 = crate::KMOD_MTX.lock(); let _m1 = crate::CWD_LOCK.read(); @@ -67,12 +74,14 @@ fn test_finit_and_delete_module_with_params() { &f, &CString::new("who=Rust number=2018").unwrap(), ModuleInitFlags::empty(), - ).expect("unable to load kernel module"); + ) + .expect("unable to load kernel module"); delete_module( &CString::new(kmod_name).unwrap(), DeleteModuleFlags::empty(), - ).expect("unable to unload kernel module"); + ) + .expect("unable to unload kernel module"); } #[test] @@ -87,17 +96,22 @@ fn test_init_and_delete_module() { let mut contents: Vec<u8> = Vec::new(); f.read_to_end(&mut contents) .expect("unable to read kernel module content to buffer"); - init_module(&contents, &CString::new("").unwrap()).expect("unable to load kernel module"); + init_module(&contents, &CString::new("").unwrap()) + .expect("unable to load kernel module"); delete_module( &CString::new(kmod_name).unwrap(), DeleteModuleFlags::empty(), - ).expect("unable to unload kernel module"); + ) + .expect("unable to unload kernel module"); } #[test] fn test_init_and_delete_module_with_params() { - require_capability!("test_init_and_delete_module_with_params", CAP_SYS_MODULE); + require_capability!( + "test_init_and_delete_module_with_params", + CAP_SYS_MODULE + ); let _m0 = crate::KMOD_MTX.lock(); let _m1 = crate::CWD_LOCK.read(); @@ -113,7 +127,8 @@ fn test_init_and_delete_module_with_params() { delete_module( &CString::new(kmod_name).unwrap(), DeleteModuleFlags::empty(), - ).expect("unable to unload kernel module"); + ) + .expect("unable to unload kernel module"); } #[test] @@ -125,14 +140,18 @@ fn test_finit_module_invalid() { let kmod_path = "/dev/zero"; let f = File::open(kmod_path).expect("unable to open kernel module"); - let result = finit_module(&f, &CString::new("").unwrap(), ModuleInitFlags::empty()); + let result = + finit_module(&f, &CString::new("").unwrap(), ModuleInitFlags::empty()); assert_eq!(result.unwrap_err(), Errno::EINVAL); } #[test] fn test_finit_module_twice_and_delete_module() { - require_capability!("test_finit_module_twice_and_delete_module", CAP_SYS_MODULE); + require_capability!( + "test_finit_module_twice_and_delete_module", + CAP_SYS_MODULE + ); let _m0 = crate::KMOD_MTX.lock(); let _m1 = crate::CWD_LOCK.read(); @@ -142,14 +161,16 @@ fn test_finit_module_twice_and_delete_module() { finit_module(&f, &CString::new("").unwrap(), ModuleInitFlags::empty()) .expect("unable to load kernel module"); - let result = finit_module(&f, &CString::new("").unwrap(), ModuleInitFlags::empty()); + let result = + finit_module(&f, &CString::new("").unwrap(), ModuleInitFlags::empty()); assert_eq!(result.unwrap_err(), Errno::EEXIST); delete_module( &CString::new(kmod_name).unwrap(), DeleteModuleFlags::empty(), - ).expect("unable to unload kernel module"); + ) + .expect("unable to unload kernel module"); } #[test] @@ -158,7 +179,10 @@ fn test_delete_module_not_loaded() { let _m0 = crate::KMOD_MTX.lock(); let _m1 = crate::CWD_LOCK.read(); - let result = delete_module(&CString::new("hello").unwrap(), DeleteModuleFlags::empty()); + let result = delete_module( + &CString::new("hello").unwrap(), + DeleteModuleFlags::empty(), + ); assert_eq!(result.unwrap_err(), Errno::ENOENT); } |