Skip to content

Commit 99c1d81

Browse files
author
lind
committed
conflicts resolved
1 parent e3da874 commit 99c1d81

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

src/tests/fs_tests.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4034,6 +4034,31 @@ pub mod fs_tests {
40344034

40354035
assert_eq!(cage.close_syscall(fd), 0);
40364036
assert_eq!(cage.exit_syscall(EXIT_SUCCESS), EXIT_SUCCESS);
4037+
pub fn ut_lind_fs_shmget_syscall(){
4038+
// acquire locks and start env cleanup
4039+
let _thelock = setup::lock_and_init();
4040+
let cage = interface::cagetable_getref(1);
4041+
4042+
let key = 33123;
4043+
// Get shmid of a memory segment / create a new one if it doesn't exist
4044+
let shmid = cage.shmget_syscall(33123, 1024, IPC_CREAT);
4045+
assert_eq!(shmid,4);
4046+
4047+
// Check error upon asking for a valid key and passing the IPC_CREAT or IPC_EXCL flag
4048+
assert_eq!(cage.shmget_syscall(key, 1024, IPC_CREAT),-(Errno::EEXIST as i32));
4049+
// assert_eq!(cage.shmget_syscall(key, 1024, IPC_EXCL),-(Errno::EEXIST as i32));
4050+
4051+
// Check if the function returns a correct shmid upon asking with a key that we know exists
4052+
assert_eq!(cage.shmget_syscall(key, 1024,0666),shmid);
4053+
4054+
// Check if the function returns the correct error when we don't pass IPC_CREAT for a key that doesn't exist
4055+
assert_eq!(cage.shmget_syscall(123456, 1024, 0),-(Errno::ENOENT as i32));
4056+
4057+
// Check if the size error is returned correctly
4058+
assert_eq!(cage.shmget_syscall(123456, (SHMMAX + 10 )as usize, IPC_CREAT),-(Errno::EINVAL as i32));
4059+
assert_eq!(cage.shmget_syscall(123456, 0 as usize, IPC_CREAT),-(Errno::EINVAL as i32));
4060+
40374061
lindrustfinalize();
40384062
}
40394063
}
4064+
}

0 commit comments

Comments
 (0)