[LTP] [PATCH v2 07/10] syscalls/ipc: Add shmctl() IPC_INFO test
Cyril Hrubis
chrubis@suse.cz
Mon Sep 7 17:01:54 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 | 40 +++++++++++++++++++
4 files changed, 43 insertions(+)
create mode 100644 testcases/kernel/syscalls/ipc/shmctl/shmctl03.c
diff --git a/runtest/syscalls b/runtest/syscalls
index 557fa7155..35770e6db 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 a40ff083f..e6837414c 100644
--- a/runtest/syscalls-ipc
+++ b/runtest/syscalls-ipc
@@ -51,6 +51,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..8868ab1cb
--- /dev/null
+++ b/testcases/kernel/syscalls/ipc/shmctl/shmctl03.c
@@ -0,0 +1,40 @@
+// 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 < 0) {
+ tst_res(TFAIL | TTERRNO,
+ "shmctl(0, IPC_INFO, ...) returned %li",
+ TST_RET);
+ 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