summaryrefslogtreecommitdiffhomepage
path: root/test/syscalls/linux/semaphore.cc
diff options
context:
space:
mode:
Diffstat (limited to 'test/syscalls/linux/semaphore.cc')
-rw-r--r--test/syscalls/linux/semaphore.cc11
1 files changed, 11 insertions, 0 deletions
diff --git a/test/syscalls/linux/semaphore.cc b/test/syscalls/linux/semaphore.cc
index f72957f89..87b66aa98 100644
--- a/test/syscalls/linux/semaphore.cc
+++ b/test/syscalls/linux/semaphore.cc
@@ -1019,6 +1019,17 @@ TEST(SemaphoreTest, SemInfo) {
EXPECT_EQ(info.semvmx, kSemVmx);
}
+TEST(SempahoreTest, RemoveNonExistentSemaphore) {
+ EXPECT_THAT(semctl(-1, 0, IPC_RMID), SyscallFailsWithErrno(EINVAL));
+}
+
+TEST(SempahoreTest, RemoveDeletedSemaphore) {
+ int id;
+ EXPECT_THAT(id = semget(IPC_PRIVATE, 1, 0), SyscallSucceeds());
+ EXPECT_THAT(semctl(id, 0, IPC_RMID), SyscallSucceeds());
+ EXPECT_THAT(semctl(id, 0, IPC_RMID), SyscallFailsWithErrno(EINVAL));
+}
+
} // namespace
} // namespace testing
} // namespace gvisor