Skip to content

Commit

Permalink
agent: fix failing unit tests on ppc64le
Browse files Browse the repository at this point in the history
- 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

Signed-off-by: Amulyam24 <[email protected]>
  • Loading branch information
Amulyam24 committed Jan 9, 2024
1 parent d07a458 commit 1d4f116
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
6 changes: 6 additions & 0 deletions src/agent/src/random.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,13 @@ use std::os::unix::io::{AsRawFd, FromRawFd};
use tracing::instrument;

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;
#[cfg(not(target_arch = "powerpc64"))]
pub const RNDRESEEDCRNG: libc::c_int = 0x5207;

// Handle the differing ioctl(2) request types for different targets
Expand Down
12 changes: 10 additions & 2 deletions src/agent/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2694,8 +2694,16 @@ OtherField:other
fs::write(mount_dir.path().join("file.dat"), "foobar").unwrap();
stats = get_volume_capacity_stats(mount_dir.path().to_str().unwrap()).unwrap();

assert_eq!(stats.used, 4 * 1024);
assert_eq!(stats.available, available - 4 * 1024);
let size = get_block_size(mount_dir.path().to_str().unwrap()).unwrap();

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]
Expand Down

0 comments on commit 1d4f116

Please sign in to comment.