Skip to content

Commit

Permalink
Merge pull request #69 from Lind-Project/fix-ut-lind-fs-mmap-unsuppor…
Browse files Browse the repository at this point in the history
…ted-file

fix: test case `ut_lind_fs_mmap_unsupported_file`
  • Loading branch information
JustinCappos authored Oct 24, 2024
2 parents f1e8454 + 036a80a commit d66c2ff
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/tests/fs_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,8 @@ pub mod fs_tests {
let _thelock = setup::lock_and_init();

let cage = interface::cagetable_getref(1);
// Removing the test directory if it exists
let _ = cage.rmdir_syscall("/testdir");

//Creating a directory.
assert_eq!(cage.mkdir_syscall("/testdir", S_IRWXA), 0);
Expand All @@ -662,13 +664,17 @@ pub mod fs_tests {
//`mmap_syscall()` correctly results in `The `fildes`
//argument refers to a file whose type is not
//supported by mmap` error.

let mmap_result = unsafe {
libc::mmap(
0 as *mut c_void, 5, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0
)
};
// Verify errno is set to ENODEV
let errno = get_errno();
/* Native linux will return ENODEV */
assert_eq!(
cage.mmap_syscall(0 as *mut u8, 5, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0),
-(Errno::ENODEV as i32)
);

assert_eq!(errno, libc::ENODEV, "Expected errno to be ENODEV for unsupported file type");
// Clean up and finalize
assert_eq!(cage.rmdir_syscall("/testdir"), 0);
assert_eq!(cage.exit_syscall(libc::EXIT_SUCCESS), libc::EXIT_SUCCESS);
lindrustfinalize();
}
Expand Down

0 comments on commit d66c2ff

Please sign in to comment.