Skip to content

Commit

Permalink
tests added
Browse files Browse the repository at this point in the history
  • Loading branch information
lind committed Jul 18, 2024
1 parent a785271 commit 53f5510
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/tests/fs_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4060,5 +4060,32 @@ pub mod fs_tests {

lindrustfinalize();
}

pub fn ut_lind_fs_shmget_syscall(){
// acquire locks and start env cleanup
let _thelock = setup::lock_and_init();
let cage = interface::cagetable_getref(1);

let key = 33123;
// Get shmid of a memory segment / create a new one if it doesn't exist
let shmid = cage.shmget_syscall(33123, 1024, IPC_CREAT);
assert_eq!(shmid,4);

// Check error upon asking for a valid key and passing the IPC_CREAT or IPC_EXCL flag
assert_eq!(cage.shmget_syscall(key, 1024, IPC_CREAT),-(Errno::EEXIST as i32 ));
// assert_eq!(cage.shmget_syscall(key, 1024, IPC_EXCL),-(Errno::EEXIST as i32));

// Check if the function returns a correct shmid upon asking with a key that we know exists
assert_eq!(cage.shmget_syscall(key, 1024,0666),shmid);

// Check if the function returns the correct error when we don't pass IPC_CREAT for a key that doesn't exist
assert_eq!(cage.shmget_syscall(123456, 1024, 0),-(Errno::ENOENT as i32));

// Check if the size error is returned correctly
assert_eq!(cage.shmget_syscall(123456, (SHMMAX + 10 )as usize, IPC_CREAT),-(Errno::EINVAL as i32));
assert_eq!(cage.shmget_syscall(123456, 0 as usize, IPC_CREAT),-(Errno::EINVAL as i32));

lindrustfinalize();
}
}
}

0 comments on commit 53f5510

Please sign in to comment.