From c0ca6fb8ee74442cded35f0213a11a08d61e7f9c Mon Sep 17 00:00:00 2001 From: lind Date: Wed, 23 Oct 2024 18:00:46 +0000 Subject: [PATCH] fix: test case ut_lind_fs_mmap_no_read --- src/tests/fs_tests.rs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/tests/fs_tests.rs b/src/tests/fs_tests.rs index 4a82a12..f2eb733 100644 --- a/src/tests/fs_tests.rs +++ b/src/tests/fs_tests.rs @@ -507,11 +507,14 @@ pub mod fs_tests { //Checking if trying to map a file that does not //allow reading correctly results in `File descriptor //is not open for reading` error. - assert_eq!( - cage.mmap_syscall(0 as *mut u8, 5, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0), - -(Errno::EACCES as i32) - ); - + let mmap_result = cage.mmap_syscall(0 as *mut u8, 5, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); + assert_eq!(mmap_result, -1, "Expected mmap to fail"); + // Fetch and print the errno for debugging + let error = get_errno(); + // Assert that the error is EACCES (Permission denied) + assert_eq!(error, libc::EACCES, "Expected errno to be EACCES for no read permission"); + // Clean up and finalize + assert_eq!(cage.unlink_syscall(filepath), 0); assert_eq!(cage.exit_syscall(libc::EXIT_SUCCESS), libc::EXIT_SUCCESS); lindrustfinalize(); }