Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: test case ut_lind_fs_pwrite_to_directory #60

Merged
merged 1 commit into from
Oct 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions src/tests/fs_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4153,14 +4153,22 @@ pub mod fs_tests {
// supported.
let path = "/test_dir";
assert_eq!(cage.mkdir_syscall(path, S_IRWXA), 0);
let fd = cage.open_syscall(path, O_WRONLY, S_IRWXA);
// Open the directory with O_RDONLY
let fd = cage.open_syscall(path, O_RDONLY, S_IRWXA);
assert!(fd >= 0, "Failed to open directory: invalid file descriptor");

let write_data = "hello";
// Attempt to pwrite to the directory, expecting EBADF.
let result = cage.pwrite_syscall(fd, write_data.as_ptr(), write_data.len(), 0);
// Expect EBADF (Bad file descriptor) as directories cannot be written to.
assert_eq!(
cage.pwrite_syscall(fd, write_data.as_ptr(), write_data.len(), 0),
-(Errno::EISDIR as i32)
result,
-(Errno::EBADF as i32),
"Expected EBADF error when attempting to write to a directory"
);

// Clean up
assert_eq!(cage.rmdir_syscall(path), 0);
assert_eq!(cage.exit_syscall(libc::EXIT_SUCCESS), libc::EXIT_SUCCESS);
lindrustfinalize();
}
Expand Down
Loading