diff --git a/youki_integration_test/src/tests/linux_ns_itype/ns_itype_test.rs b/youki_integration_test/src/tests/linux_ns_itype/ns_itype_test.rs index 62702f5a3..d2a7b4cdb 100644 --- a/youki_integration_test/src/tests/linux_ns_itype/ns_itype_test.rs +++ b/youki_integration_test/src/tests/linux_ns_itype/ns_itype_test.rs @@ -33,27 +33,33 @@ fn get_test<'a>(test_name: &'static str) -> Test<'a> { Test::new( test_name, Box::new(move || { - let host_proc = Process::myself().unwrap(); + let host_proc = Process::myself().expect("error in getting /proc/self"); let host_namespaces = match host_proc.namespaces() { Ok(n) => n, Err(e) => { - return TestResult::Err(anyhow!("Error in resolving host namespaces : {}", e)) + return TestResult::Failed(anyhow!( + "error in resolving host namespaces : {}", + e + )) } }; let spec = get_spec(); test_outside_container(spec, &move |data| { let pid = match data.state { Some(s) => s.pid.unwrap(), - None => return TestResult::Err(anyhow!("State command returned error")), + None => return TestResult::Failed(anyhow!("state command returned error")), }; - let container_process = Process::new(pid).unwrap(); - let container_namespaces = container_process.namespaces().unwrap(); + let container_process = + Process::new(pid).expect("error in getting /proc for container process"); + let container_namespaces = container_process + .namespaces() + .expect("error in getting namespaces of container process"); if container_namespaces != host_namespaces { - return TestResult::Err(anyhow!( - "Error : namespaces are not correctly inherited" + return TestResult::Failed(anyhow!( + "error : namespaces are not correctly inherited" )); } - TestResult::Ok + TestResult::Passed }) }), ) diff --git a/youki_integration_test/src/tests/pidfile/pidfile_test.rs b/youki_integration_test/src/tests/pidfile/pidfile_test.rs index 7892047ed..1d5197f81 100644 --- a/youki_integration_test/src/tests/pidfile/pidfile_test.rs +++ b/youki_integration_test/src/tests/pidfile/pidfile_test.rs @@ -46,7 +46,7 @@ fn test_pidfile() -> TestResult { if !err.is_empty() { cleanup(&container_id, &bundle); - return TestResult::Failed(anyhow!("Error in state : {}", err)); + return TestResult::Failed(anyhow!("error in state : {}", err)); } let state: State = serde_json::from_str(&out).unwrap(); @@ -54,7 +54,7 @@ fn test_pidfile() -> TestResult { if state.id != container_id.to_string() { cleanup(&container_id, &bundle); return TestResult::Failed(anyhow!( - "Error in state : ID not matched ,expected {} got {}", + "error in state : id not matched ,expected {} got {}", container_id, state.id )); @@ -63,7 +63,7 @@ fn test_pidfile() -> TestResult { if state.status != "created" { cleanup(&container_id, &bundle); return TestResult::Failed(anyhow!( - "Error in state : Status not matched ,expected 'created' got {}", + "error in state : status not matched ,expected 'created' got {}", state.status )); } @@ -78,7 +78,7 @@ fn test_pidfile() -> TestResult { if state.pid.unwrap() != pidfile { cleanup(&container_id, &bundle); return TestResult::Failed(anyhow!( - "Error : Pid not matched ,expected {} as per state, but got {} from pidfile instead", + "error : pid not matched ,expected {} as per state, but got {} from pidfile instead", state.pid.unwrap(), pidfile )); diff --git a/youki_integration_test/src/tests/tlb/tlb_test.rs b/youki_integration_test/src/tests/tlb/tlb_test.rs index be3e3047d..34509efb7 100644 --- a/youki_integration_test/src/tests/tlb/tlb_test.rs +++ b/youki_integration_test/src/tests/tlb/tlb_test.rs @@ -5,7 +5,7 @@ use oci_spec::runtime::LinuxBuilder; use oci_spec::runtime::{LinuxHugepageLimitBuilder, LinuxResourcesBuilder}; use oci_spec::runtime::{Spec, SpecBuilder}; use std::path::PathBuf; -use test_framework::{ConditionalTest, TestGroup, TestResult}; +use test_framework::{test_result, ConditionalTest, TestGroup, TestResult}; fn check_hugetlb() -> bool { PathBuf::from("/sys/fs/cgroup/hugetlb").exists() @@ -21,7 +21,7 @@ fn make_hugetlb_spec(page_size: &str, limit: i64) -> Spec { .page_size(page_size.to_owned()) .limit(limit) .build() - .expect("Could not build")]) + .expect("could not build")]) .build() .unwrap(), ) @@ -52,7 +52,7 @@ fn test_wrong_tlb() -> TestResult { } if res.success() { // The operation should not have succeeded as pagesize was not power of 2 - TestResult::Failed(anyhow!("Invalid page size of {} was allowed", page)) + TestResult::Failed(anyhow!("invalid page size of {} was allowed", page)) } else { TestResult::Passed } @@ -77,8 +77,10 @@ fn extract_page_size(dir_name: &str) -> String { fn get_tlb_sizes() -> Vec { let mut sizes = Vec::new(); - for hugetlb_entry in std::fs::read_dir("/sys/kernel/mm/hugepages").unwrap() { - let hugetlb_entry = hugetlb_entry.unwrap(); + for hugetlb_entry in std::fs::read_dir("/sys/kernel/mm/hugepages") + .expect("error in reading /sys/kernel/mm/hugepages") + { + let hugetlb_entry = hugetlb_entry.expect("error in reading /sys/kernel/mm/hugepages entry"); if !hugetlb_entry.path().is_dir() { continue; } @@ -100,7 +102,7 @@ fn validate_tlb(id: &str, size: &str, limit: i64) -> TestResult { TestResult::Passed } else { TestResult::Failed(anyhow!( - "Page limit not set correctly : for size {}, expected {}, got {}", + "page limit not set correctly : for size {}, expected {}, got {}", size, limit, val @@ -117,7 +119,7 @@ fn test_valid_tlb() -> TestResult { for size in tlb_sizes.iter() { let spec = make_hugetlb_spec(size, limit); let res = test_outside_container(spec, &|data| { - check_container_created(&data).unwrap(); + test_result!(check_container_created(&data)); let r = validate_tlb(&data.id, size, limit); if matches!(r, TestResult::Failed(_)) {