[LTP] [PATCH 6/9] syscalls/ipc: Add shmctl() IPC_INFO test
Cyril Hrubis
chrubis@suse.cz
Fri Jul 17 18:34:50 CEST 2020
Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
---
runtest/syscalls | 1 +
runtest/syscalls-ipc | 1 +
.../kernel/syscalls/ipc/shmctl/.gitignore | 1 +
.../kernel/syscalls/ipc/shmctl/shmctl03.c | 38 +++++++++++++++++++
4 files changed, 41 insertions(+)
create mode 100644 testcases/kernel/syscalls/ipc/shmctl/shmctl03.c
diff --git a/runtest/syscalls b/runtest/syscalls
index 5ce482dc7..819e8d8ee 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -1355,6 +1355,7 @@ shmat03 shmat03
shmctl01 shmctl01
shmctl02 shmctl02
+shmctl03 shmctl03
shmctl04 shmctl04
shmctl05 shmctl05
shmctl06 shmctl06
diff --git a/runtest/syscalls-ipc b/runtest/syscalls-ipc
index 10cb92c7d..c3a35896c 100644
--- a/runtest/syscalls-ipc
+++ b/runtest/syscalls-ipc
@@ -53,6 +53,7 @@ shmat02 shmat02
shmctl01 shmctl01
shmctl02 shmctl02
+shmctl03 shmctl03
shmctl04 shmctl04
shmctl05 shmctl05
shmctl06 shmctl06
diff --git a/testcases/kernel/syscalls/ipc/shmctl/.gitignore b/testcases/kernel/syscalls/ipc/shmctl/.gitignore
index 08aa83c19..46b107344 100644
--- a/testcases/kernel/syscalls/ipc/shmctl/.gitignore
+++ b/testcases/kernel/syscalls/ipc/shmctl/.gitignore
@@ -1,5 +1,6 @@
/shmctl01
/shmctl02
+/shmctl03
/shmctl04
/shmctl05
/shmctl06
diff --git a/testcases/kernel/syscalls/ipc/shmctl/shmctl03.c b/testcases/kernel/syscalls/ipc/shmctl/shmctl03.c
new file mode 100644
index 000000000..7df8c12ce
--- /dev/null
+++ b/testcases/kernel/syscalls/ipc/shmctl/shmctl03.c
@@ -0,0 +1,38 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (C) 2020 Cyril Hrubis <chrubis@suse.cz>
+ */
+/*
+ * Call shmctl() with IPC_INFO flag and check that the data are consistent with
+ * /proc/sys/kernel/shm*.
+ */
+
+#define _GNU_SOURCE
+#include "tst_test.h"
+#include "tst_safe_sysv_ipc.h"
+#include "libnewipc.h"
+
+static void verify_ipcinfo(void)
+{
+ struct shminfo info;
+
+ TEST(shmctl(0, IPC_INFO, (struct shmid_ds *)&info));
+
+ if (TST_RET == -1) {
+ tst_res(TFAIL | TTERRNO, "shmctl(0, IPC_INFO, ...)");
+ return;
+ }
+
+ if (info.shmmin != 1)
+ tst_res(TFAIL, "shmmin = %li, expected 1", info.shmmin);
+ else
+ tst_res(TPASS, "shmmin = 1");
+
+ TST_ASSERT_ULONG("/proc/sys/kernel/shmmax", info.shmmax);
+ TST_ASSERT_ULONG("/proc/sys/kernel/shmmni", info.shmmni);
+ TST_ASSERT_ULONG("/proc/sys/kernel/shmall", info.shmall);
+}
+
+static struct tst_test test = {
+ .test_all = verify_ipcinfo,
+};
--
2.26.2
More information about the ltp
mailing list