Skip to content

Commit

Permalink
Fix statfs_fstatfs.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
facundopoblete committed Jan 14, 2025
1 parent a8d54d6 commit df28b10
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
4 changes: 2 additions & 2 deletions mirrord/layer/tests/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -509,13 +509,13 @@ impl TestIntProxy {
}

/// Makes a [`FileRequest::Xstatefs`] and answers it.
pub async fn expect_fstatfs(&mut self, expected_fd: Option<u64>) {
pub async fn expect_fstatfs(&mut self, expected_fd: u64) {
// Expecting `fstatfs` call with path.
assert_matches!(
self.recv().await,
ClientMessage::FileRequest(FileRequest::XstatFs(
mirrord_protocol::file::XstatFsRequest { fd }
)) if expected_fd.is_none() || expected_fd.unwrap() == fd
)) if expected_fd == fd
);

// Answer `fstatfs`.
Expand Down
2 changes: 1 addition & 1 deletion mirrord/layer/tests/fileops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ async fn go_stat(
.await;

intproxy.expect_statfs("/tmp/test_file.txt").await;
intproxy.expect_fstatfs(Some(fd)).await;
intproxy.expect_fstatfs(fd).await;

test_process.wait_assert_success().await;
test_process.assert_no_error_in_stderr().await;
Expand Down
8 changes: 7 additions & 1 deletion mirrord/layer/tests/statfs_fstatfs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,17 @@ async fn mkdir(dylib_path: &Path) {
.expect_make_dir("/statfs_fstatfs_test_path", 0o777)
.await;

println!("waiting for file request.");
let fd: u64 = 1;
intproxy
.expect_file_open_for_reading("/statfs_fstatfs_test_path", fd)
.await;

println!("waiting for file request.");
intproxy.expect_statfs("/statfs_fstatfs_test_path").await;

println!("waiting for file request.");
intproxy.expect_fstatfs(None).await;
intproxy.expect_fstatfs(fd).await;

assert_eq!(intproxy.try_recv().await, None);

Expand Down

0 comments on commit df28b10

Please sign in to comment.