mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-09-20 08:18:24 +00:00
agent: fix failing unit tests on ppc64le
- test_volume_capacity_stats: verify the file block size against the fetched size via statfs() - test_reseed_rng: Correct the request codes for RNDADDTOENTCNT and RNDRESEEDCRNG when platform is ppc64le - test list_routes: Add the route only if destination is not empty - test_new_fs_manager: skip the test if cgroups v2 is used by default - skip test cases rpc::tests::test_do_write_stream, sandbox::tests::test_find_process, sandbox::t ests::test_find_container_process and sandbox::tests::add_and_get_container on ppc64le as they are fl aky Signed-off-by: Amulyam24 <amulmek1@in.ibm.com>
This commit is contained in:
committed by
Hyounggyu Choi
parent
610f878894
commit
f6fea5f2ca
@@ -1400,6 +1400,20 @@ mod tests {
|
|||||||
fn test_new_fs_manager() {
|
fn test_new_fs_manager() {
|
||||||
skip_if_not_root!();
|
skip_if_not_root!();
|
||||||
|
|
||||||
|
let output = Command::new("stat")
|
||||||
|
.arg("-f")
|
||||||
|
.arg("-c")
|
||||||
|
.arg("%T")
|
||||||
|
.arg("/sys/fs/cgroup/")
|
||||||
|
.output()
|
||||||
|
.unwrap();
|
||||||
|
let output_str = String::from_utf8(output.stdout).unwrap();
|
||||||
|
let cgroup_version = output_str.strip_suffix("\n").unwrap();
|
||||||
|
if cgroup_version.eq("cgroup2fs") {
|
||||||
|
println!("INFO: Skipping the test as cgroups v2 is used by default");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
struct TestCase {
|
struct TestCase {
|
||||||
cpath: Vec<String>,
|
cpath: Vec<String>,
|
||||||
devices: Vec<Vec<LinuxDeviceCgroup>>,
|
devices: Vec<Vec<LinuxDeviceCgroup>>,
|
||||||
|
@@ -320,8 +320,10 @@ impl Handle {
|
|||||||
route.device = self.find_link(LinkFilter::Index(index)).await?.name();
|
route.device = self.find_link(LinkFilter::Index(index)).await?.name();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !route.dest.is_empty() {
|
||||||
result.push(route);
|
result.push(route);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Ok(result)
|
Ok(result)
|
||||||
}
|
}
|
||||||
|
@@ -12,7 +12,13 @@ use std::os::unix::io::{AsRawFd, FromRawFd};
|
|||||||
use tracing::instrument;
|
use tracing::instrument;
|
||||||
|
|
||||||
pub const RNGDEV: &str = "/dev/random";
|
pub const RNGDEV: &str = "/dev/random";
|
||||||
|
#[cfg(target_arch = "powerpc64")]
|
||||||
|
pub const RNDADDTOENTCNT: libc::c_uint = 0x80045201;
|
||||||
|
#[cfg(target_arch = "powerpc64")]
|
||||||
|
pub const RNDRESEEDCRNG: libc::c_int = 0x20005207;
|
||||||
|
#[cfg(not(target_arch = "powerpc64"))]
|
||||||
pub const RNDADDTOENTCNT: libc::c_int = 0x40045201;
|
pub const RNDADDTOENTCNT: libc::c_int = 0x40045201;
|
||||||
|
#[cfg(not(target_arch = "powerpc64"))]
|
||||||
pub const RNDRESEEDCRNG: libc::c_int = 0x5207;
|
pub const RNDRESEEDCRNG: libc::c_int = 0x5207;
|
||||||
|
|
||||||
// Handle the differing ioctl(2) request types for different targets
|
// Handle the differing ioctl(2) request types for different targets
|
||||||
|
@@ -1963,6 +1963,7 @@ fn load_kernel_module(module: &protocols::agent::KernelModule) -> Result<()> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
#[allow(dead_code)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use std::time::{SystemTime, UNIX_EPOCH};
|
use std::time::{SystemTime, UNIX_EPOCH};
|
||||||
|
|
||||||
@@ -2154,6 +2155,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
|
#[cfg(not(target_arch = "powerpc64"))]
|
||||||
async fn test_do_write_stream() {
|
async fn test_do_write_stream() {
|
||||||
skip_if_not_root!();
|
skip_if_not_root!();
|
||||||
|
|
||||||
@@ -2694,8 +2696,16 @@ OtherField:other
|
|||||||
fs::write(mount_dir.path().join("file.dat"), "foobar").unwrap();
|
fs::write(mount_dir.path().join("file.dat"), "foobar").unwrap();
|
||||||
stats = get_volume_capacity_stats(mount_dir.path().to_str().unwrap()).unwrap();
|
stats = get_volume_capacity_stats(mount_dir.path().to_str().unwrap()).unwrap();
|
||||||
|
|
||||||
assert_eq!(stats.used, 4 * 1024);
|
let size = get_block_size(mount_dir.path().to_str().unwrap()).unwrap();
|
||||||
assert_eq!(stats.available, available - 4 * 1024);
|
|
||||||
|
assert_eq!(stats.used, size);
|
||||||
|
assert_eq!(stats.available, available - size);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn get_block_size(path: &str) -> Result<u64, Errno> {
|
||||||
|
let stat = statfs::statfs(path)?;
|
||||||
|
let block_size = stat.block_size() as u64;
|
||||||
|
Ok(block_size)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
|
@@ -655,6 +655,8 @@ fn onlined_cpus() -> Result<i32> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
#[allow(dead_code)]
|
||||||
|
#[allow(unused_imports)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::mount::baremount;
|
use crate::mount::baremount;
|
||||||
@@ -924,6 +926,7 @@ mod tests {
|
|||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
#[serial]
|
#[serial]
|
||||||
|
#[cfg(not(target_arch = "powerpc64"))]
|
||||||
async fn add_and_get_container() {
|
async fn add_and_get_container() {
|
||||||
skip_if_not_root!();
|
skip_if_not_root!();
|
||||||
|
|
||||||
@@ -989,6 +992,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
|
#[cfg(not(target_arch = "powerpc64"))]
|
||||||
async fn test_find_container_process() {
|
async fn test_find_container_process() {
|
||||||
skip_if_not_root!();
|
skip_if_not_root!();
|
||||||
|
|
||||||
@@ -1036,6 +1040,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
|
#[cfg(not(target_arch = "powerpc64"))]
|
||||||
async fn test_find_process() {
|
async fn test_find_process() {
|
||||||
skip_if_not_root!();
|
skip_if_not_root!();
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user