Skip to contentSkip to conversation

Rewrite shmctl() testcases

PATCH Superseded Cyril Hrubis 3 participants 16 messages Sep 7, 2020 – Sep 10, 2020 Library code

lore
Share & tools
lore
#0 lore raw

v2 cover Rewrite shmctl() testcases

This patchset mostly rewrites old shmctl testcases from scratch and also increases the coverage at least threefold.

There are still missing pieces though, there are no test that would check that shm_atime and shm_dtime are valid as well as shm_lpid as well as the coverage of ipc_perm is still lacking and should be added later on.

Changes in v2:

* Redesing shmctl04, the check for max_idx was bogus before

* Fixed shmctl07 to re-read the IPC_STAT and corrected the check

* Fixed shmctl08 ctime check to make sure the field gets updated

* Added fallback for SHM_STAT_ANY

+ Many smaller fixes mostly pointed out by Martin

Cyril Hrubis (10):
syscalls/ipc: shmctl02: Convert to the new library syscalls/ipc: shmctl03: Remove. lapi/shm.h: Add SHM_STAT_ANY
syscalls/ipc: shmctl04: Rewrite from scratch. syscalls/ipc: shmctl05 remove lib dependency lib/tst_assert: Add TST_ASSERT_ULONG() syscalls/ipc: Add shmctl() IPC_INFO test syscalls/ipc: Add shmctl07 test syscalls/ipc: Add shmctl IPC_SET test syscalls/ipc: Rewrite shmctl01

 include/lapi/shm.h                            |  13 +
 include/tst_assert.h                          |   9 +
 lib/tst_assert.c                              |  14 +
 runtest/syscalls                              |   2 +
 runtest/syscalls-ipc                          |   2 +
 .../kernel/syscalls/ipc/shmctl/.gitignore     |   2 +
 testcases/kernel/syscalls/ipc/shmctl/Makefile |   3 +-
 .../kernel/syscalls/ipc/shmctl/shmctl01.c     | 586 ++++++------------
 .../kernel/syscalls/ipc/shmctl/shmctl02.c     | 263 +++-----
 .../kernel/syscalls/ipc/shmctl/shmctl03.c     | 216 +------
 .../kernel/syscalls/ipc/shmctl/shmctl04.c     | 203 +++---
 .../kernel/syscalls/ipc/shmctl/shmctl07.c     |  68 ++
 .../kernel/syscalls/ipc/shmctl/shmctl08.c     | 103 +++
 13 files changed, 625 insertions(+), 859 deletions(-)
 create mode 100644 include/lapi/shm.h
 create mode 100644 testcases/kernel/syscalls/ipc/shmctl/shmctl07.c
 create mode 100644 testcases/kernel/syscalls/ipc/shmctl/shmctl08.c
Signature · 1 line
2.26.2
#1 lore raw

PATCH v2 1/10 syscalls/ipc: shmctl02: Convert to the new library

---
 testcases/kernel/syscalls/ipc/shmctl/Makefile |   4 +-
 .../kernel/syscalls/ipc/shmctl/shmctl02.c     | 263 ++++++------------
 2 files changed, 89 insertions(+), 178 deletions(-)
testcases/kernel/syscalls/ipc/shmctl/Makefile +2 -2
index 2e0ed0ceb..10db57fcc 100644
@@ -10,7 +10,7 @@ shmctl05: LDLIBS += -lrt
 
 include $(top_srcdir)/include/mk/testcases.mk
 
-shmctl01 shmctl02 shmctl03 shmctl04 shmctl05: LTPLDLIBS = -lltpipc
-shmctl06: LTPLDLIBS = -lltpnewipc
+shmctl01 shmctl03 shmctl04 shmctl05: LTPLDLIBS = -lltpipc
+shmctl02 shmctl06: LTPLDLIBS = -lltpnewipc
 
 include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/syscalls/ipc/shmctl/shmctl02.c +87 -176

300 lines not on this page · raw message

Signature · 1 line
2.26.2
#2 lore raw

PATCH v2 2/10 syscalls/ipc: shmctl03: Remove.

In reply to Cyril Hrubis

All these cases are now covered by shmctl02.

---
 runtest/syscalls                              |   1 -
 runtest/syscalls-ipc                          |   1 -
 .../kernel/syscalls/ipc/shmctl/.gitignore     |   1 -
 testcases/kernel/syscalls/ipc/shmctl/Makefile |   2 +-
 .../kernel/syscalls/ipc/shmctl/shmctl03.c     | 204 ------------------
 5 files changed, 1 insertion(+), 208 deletions(-)
 delete mode 100644 testcases/kernel/syscalls/ipc/shmctl/shmctl03.c
runtest/syscalls +0 -1
index 35770e6db..557fa7155 100644
@@ -1355,7 +1355,6 @@ shmat03 shmat03
 
 shmctl01 shmctl01
 shmctl02 shmctl02
-shmctl03 shmctl03
 shmctl04 shmctl04
 shmctl05 shmctl05
 shmctl06 shmctl06
runtest/syscalls-ipc +0 -1
index e6837414c..a40ff083f 100644
@@ -51,7 +51,6 @@ shmat02 shmat02
 
 shmctl01 shmctl01
 shmctl02 shmctl02
-shmctl03 shmctl03
 shmctl04 shmctl04
 shmctl05 shmctl05
 shmctl06 shmctl06
testcases/kernel/syscalls/ipc/shmctl/.gitignore +0 -1
index 46b107344..08aa83c19 100644
@@ -1,6 +1,5 @@
 /shmctl01
 /shmctl02
-/shmctl03
 /shmctl04
 /shmctl05
 /shmctl06
testcases/kernel/syscalls/ipc/shmctl/Makefile +1 -1
index 10db57fcc..176592e85 100644
@@ -10,7 +10,7 @@ shmctl05: LDLIBS += -lrt
 
 include $(top_srcdir)/include/mk/testcases.mk
 
-shmctl01 shmctl03 shmctl04 shmctl05: LTPLDLIBS = -lltpipc
+shmctl01 shmctl04 shmctl05: LTPLDLIBS = -lltpipc
 shmctl02 shmctl06: LTPLDLIBS = -lltpnewipc
 
 include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/syscalls/ipc/shmctl/shmctl03.c deleted +0 -204

204 lines not on this page · raw message

Signature · 1 line
2.26.2
#3 lore raw

PATCH v2 3/10 lapi/shm.h: Add SHM_STAT_ANY

In reply to Cyril Hrubis
---
 include/lapi/shm.h | 13 +++++++++++++
 1 file changed, 13 insertions(+)
 create mode 100644 include/lapi/shm.h
include/lapi/shm.h new file +13 -0
new file mode 100644
index 000000000..61c4e37bf
@@ -0,0 +1,13 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2020 Cyril Hrubis <[email protected]>
+ */
+
+#ifndef LAPI_SHM_H__
+#define LAPI_SHM_H__
+
+#ifndef SHM_STAT_ANY
+# define SHM_STAT_ANY 15
+#endif
+
+#endif /* LAPI_SHM_H__ */
Signature · 1 line
2.26.2
#4 lore raw

PATCH v2 4/10 syscalls/ipc: shmctl04: Rewrite from scratch.

In reply to Cyril Hrubis

Write the test from a scratch and validate the content of the shm_info structure and the return value.

The return value is highest used index to a kernel table, so we call shmctl() with SHM_STAT_ANY which shouldn't fail if the value is correct.

We also parse /proc/sysvipc/shm and check that the information is consistent with the content of shm_info structure.

---
 testcases/kernel/syscalls/ipc/shmctl/Makefile |   4 +-
 .../kernel/syscalls/ipc/shmctl/shmctl04.c     | 203 +++++++++++-------
 2 files changed, 122 insertions(+), 85 deletions(-)
testcases/kernel/syscalls/ipc/shmctl/Makefile +2 -2
index 176592e85..789fd4227 100644
@@ -10,7 +10,7 @@ shmctl05: LDLIBS += -lrt
 
 include $(top_srcdir)/include/mk/testcases.mk
 
-shmctl01 shmctl04 shmctl05: LTPLDLIBS = -lltpipc
-shmctl02 shmctl06: LTPLDLIBS = -lltpnewipc
+shmctl01 shmctl05: LTPLDLIBS = -lltpipc
+shmctl02 shmctl04 shmctl06: LTPLDLIBS = -lltpnewipc
 
 include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/syscalls/ipc/shmctl/shmctl04.c +120 -83

235 lines not on this page · raw message

Signature · 1 line
2.26.2
#5 lore raw

PATCH v2 5/10 syscalls/ipc: shmctl05 remove lib dependency

In reply to Cyril Hrubis

The shmctl05 does not need any SHM library.

---
 testcases/kernel/syscalls/ipc/shmctl/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
testcases/kernel/syscalls/ipc/shmctl/Makefile +1 -1
index 789fd4227..9d535014f 100644
@@ -10,7 +10,7 @@ shmctl05: LDLIBS += -lrt
 
 include $(top_srcdir)/include/mk/testcases.mk
 
-shmctl01 shmctl05: LTPLDLIBS = -lltpipc
+shmctl01: LTPLDLIBS = -lltpipc
 shmctl02 shmctl04 shmctl06: LTPLDLIBS = -lltpnewipc
 
 include $(top_srcdir)/include/mk/generic_leaf_target.mk
Signature · 1 line
2.26.2
#6 lore raw

PATCH v2 6/10 lib/tst_assert: Add TST_ASSERT_ULONG()

In reply to Cyril Hrubis
---
 include/tst_assert.h |  9 +++++++++
 lib/tst_assert.c     | 14 ++++++++++++++
 2 files changed, 23 insertions(+)
include/tst_assert.h +9 -0
index 9969a8169..dcb62dfea 100644
@@ -21,6 +21,15 @@ void tst_assert_int(const char *file, const int lineno,
 #define TST_ASSERT_FILE_INT(path, prefix, val) \
 	tst_assert_file_int(__FILE__, __LINE__, path, prefix, val)
 
+/*
+ * Same as tst_assert_int() but for unsigned long.
+ */
+void tst_assert_ulong(const char *file, const int lineno,
+                      const char *path, unsigned long val);
+
+#define TST_ASSERT_ULONG(path, val) \
+	tst_assert_ulong(__FILE__, __LINE__, path, val)
+
 /*
  * Asserts that integer value stored in the prefix field of file pointed by path
  * equals to the value passed to this function. This is mostly useful for
lib/tst_assert.c +14 -0
index c7908f64f..9b8ebc167 100644
@@ -23,6 +23,20 @@ void tst_assert_int(const char *file, const int lineno, const char *path, int va
 	tst_res_(file, lineno, TFAIL, "%s != %d got %d", path, val, sys_val);
 }
 
+void tst_assert_ulong(const char *file, const int lineno, const char *path, unsigned long val)
+{
+	unsigned long sys_val;
+
+	safe_file_scanf(file, lineno, NULL, path, "%lu", &sys_val);
+
+	if (val == sys_val) {
+		tst_res_(file, lineno, TPASS, "%s = %lu", path, val);
+		return;
+	}
+
+	tst_res_(file, lineno, TFAIL, "%s != %lu got %lu", path, val, sys_val);
+}
+
 void tst_assert_file_int(const char *file, const int lineno, const char *path, const char *prefix, int val)
 {
 	int sys_val;
Signature · 1 line
2.26.2
#7 lore raw

PATCH v2 7/10 syscalls/ipc: Add shmctl() IPC_INFO test

In reply to Cyril Hrubis
---
 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
runtest/syscalls +1 -0
index 557fa7155..35770e6db 100644
@@ -1355,6 +1355,7 @@ shmat03 shmat03
 
 shmctl01 shmctl01
 shmctl02 shmctl02
+shmctl03 shmctl03
 shmctl04 shmctl04
 shmctl05 shmctl05
 shmctl06 shmctl06
runtest/syscalls-ipc +1 -0
index a40ff083f..e6837414c 100644
@@ -51,6 +51,7 @@ shmat02 shmat02
 
 shmctl01 shmctl01
 shmctl02 shmctl02
+shmctl03 shmctl03
 shmctl04 shmctl04
 shmctl05 shmctl05
 shmctl06 shmctl06
testcases/kernel/syscalls/ipc/shmctl/.gitignore +1 -0
index 08aa83c19..46b107344 100644
@@ -1,5 +1,6 @@
 /shmctl01
 /shmctl02
+/shmctl03
 /shmctl04
 /shmctl05
 /shmctl06
testcases/kernel/syscalls/ipc/shmctl/shmctl03.c new file +40 -0
new file mode 100644
index 000000000..8868ab1cb
@@ -0,0 +1,40 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (C) 2020 Cyril Hrubis <[email protected]>
+ */
+/*
+ * 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,
+};
Signature · 1 line
2.26.2
#8 lore raw

PATCH v2 8/10 syscalls/ipc: Add shmctl07 test

In reply to Cyril Hrubis

A new test for SHM_LOCK and SHM_UNLOCK.

---
 runtest/syscalls                              |  1 +
 runtest/syscalls-ipc                          |  1 +
 .../kernel/syscalls/ipc/shmctl/.gitignore     |  1 +
 .../kernel/syscalls/ipc/shmctl/shmctl07.c     | 66 +++++++++++++++++++
 4 files changed, 69 insertions(+)
 create mode 100644 testcases/kernel/syscalls/ipc/shmctl/shmctl07.c
runtest/syscalls +1 -0
index 35770e6db..448b893ea 100644
@@ -1359,6 +1359,7 @@ shmctl03 shmctl03
 shmctl04 shmctl04
 shmctl05 shmctl05
 shmctl06 shmctl06
+shmctl07 shmctl07
 
 shmdt01 shmdt01
 shmdt02 shmdt02
runtest/syscalls-ipc +1 -0
index e6837414c..5b50820d2 100644
@@ -55,6 +55,7 @@ shmctl03 shmctl03
 shmctl04 shmctl04
 shmctl05 shmctl05
 shmctl06 shmctl06
+shmctl07 shmctl07
 
 shmdt01 shmdt01
 shmdt02 shmdt02
testcases/kernel/syscalls/ipc/shmctl/.gitignore +1 -0
index 46b107344..4322d03b7 100644
@@ -4,3 +4,4 @@
 /shmctl04
 /shmctl05
 /shmctl06
+/shmctl07
testcases/kernel/syscalls/ipc/shmctl/shmctl07.c new file +66 -0

66 lines not on this page · raw message

Signature · 1 line
2.26.2
#9 lore raw

PATCH v2 9/10 syscalls/ipc: Add shmctl IPC_SET test

In reply to Cyril Hrubis
---
 runtest/syscalls                              |   1 +
 runtest/syscalls-ipc                          |   1 +
 .../kernel/syscalls/ipc/shmctl/.gitignore     |   1 +
 .../kernel/syscalls/ipc/shmctl/shmctl07.c     |   6 +-
 .../kernel/syscalls/ipc/shmctl/shmctl08.c     | 103 ++++++++++++++++++
 5 files changed, 110 insertions(+), 2 deletions(-)
 create mode 100644 testcases/kernel/syscalls/ipc/shmctl/shmctl08.c
runtest/syscalls +1 -0
index 448b893ea..9f1c9ee0c 100644
@@ -1360,6 +1360,7 @@ shmctl04 shmctl04
 shmctl05 shmctl05
 shmctl06 shmctl06
 shmctl07 shmctl07
+shmctl08 shmctl08
 
 shmdt01 shmdt01
 shmdt02 shmdt02
runtest/syscalls-ipc +1 -0
index 5b50820d2..4eb71e3cb 100644
@@ -56,6 +56,7 @@ shmctl04 shmctl04
 shmctl05 shmctl05
 shmctl06 shmctl06
 shmctl07 shmctl07
+shmctl08 shmctl08
 
 shmdt01 shmdt01
 shmdt02 shmdt02
testcases/kernel/syscalls/ipc/shmctl/.gitignore +1 -0
index 4322d03b7..f3f88ee17 100644
@@ -5,3 +5,4 @@
 /shmctl05
 /shmctl06
 /shmctl07
+/shmctl08
testcases/kernel/syscalls/ipc/shmctl/shmctl07.c +4 -2
index 409203db7..39b9ad78a 100644
@@ -42,10 +42,12 @@ static void verify_shmlock(void)
 	else
 		tst_res(TPASS, "shmctl(%i, SHM_UNLOCK, NULL)", shm_id);
 
+	SAFE_SHMCTL(shm_id, IPC_STAT, &ds);
+
 	if (ds.shm_perm.mode & SHM_LOCKED)
-		tst_res(TPASS, "SHM_LOCKED bit is off in shm_perm.mode");
-	else
 		tst_res(TFAIL, "SMH_LOCKED bit is on in shm_perm.mode");
+	else
+		tst_res(TPASS, "SHM_LOCKED bit is off in shm_perm.mode");
 }
 
 static void setup(void)
testcases/kernel/syscalls/ipc/shmctl/shmctl08.c new file +103 -0

103 lines not on this page · raw message

Signature · 1 line
2.26.2
#10 lore raw

PATCH v2 9/10 syscalls/ipc: Add shmctl IPC_SET test

Hi Cyril

Quoted 51 lines
---
  runtest/syscalls                              |   1 +
  runtest/syscalls-ipc                          |   1 +
  .../kernel/syscalls/ipc/shmctl/.gitignore     |   1 +
  .../kernel/syscalls/ipc/shmctl/shmctl07.c     |   6 +-
  .../kernel/syscalls/ipc/shmctl/shmctl08.c     | 103 ++++++++++++++++++
  5 files changed, 110 insertions(+), 2 deletions(-)

create mode 100644 testcases/kernel/syscalls/ipc/shmctl/shmctl08.c

runtest/syscalls +1 -0
index 448b893ea..9f1c9ee0c 100644
@@ -1360,6 +1360,7 @@ shmctl04 shmctl04
  shmctl05 shmctl05
  shmctl06 shmctl06
  shmctl07 shmctl07
+shmctl08 shmctl08
 
  shmdt01 shmdt01
  shmdt02 shmdt02
runtest/syscalls-ipc +1 -0
index 5b50820d2..4eb71e3cb 100644
@@ -56,6 +56,7 @@ shmctl04 shmctl04
  shmctl05 shmctl05
  shmctl06 shmctl06
  shmctl07 shmctl07
+shmctl08 shmctl08
 
  shmdt01 shmdt01
  shmdt02 shmdt02
testcases/kernel/syscalls/ipc/shmctl/.gitignore +1 -0
index 4322d03b7..f3f88ee17 100644
@@ -5,3 +5,4 @@
  /shmctl05
  /shmctl06
  /shmctl07
+/shmctl08
testcases/kernel/syscalls/ipc/shmctl/shmctl07.c +0 -0
index 409203db7..39b9ad78a 100644
@@ -42,10 +42,12 @@ static void verify_shmlock(void)
  	else
  		tst_res(TPASS, "shmctl(%i, SHM_UNLOCK, NULL)", shm_id);
 

testcases/kernel/syscalls/ipc/shmctl/shmctl07.c static void verify_shmlock(void) · line 52

Quoted 10 lines
testcases/kernel/syscalls/ipc/shmctl/shmctl07.c +4 -2
+	SAFE_SHMCTL(shm_id, IPC_STAT, &ds);
+
  	if (ds.shm_perm.mode & SHM_LOCKED)
-		tst_res(TPASS, "SHM_LOCKED bit is off in shm_perm.mode");
-	else
  		tst_res(TFAIL, "SMH_LOCKED bit is on in shm_perm.mode");
+	else
+		tst_res(TPASS, "SHM_LOCKED bit is off in shm_perm.mode");
  }
 

This change should belong to "syscalls/ipc: Add shmctl07 test" patch.

Quoted 111 lines
testcases/kernel/syscalls/ipc/shmctl/shmctl07.c +0 -0
  static void setup(void)
testcases/kernel/syscalls/ipc/shmctl/shmctl08.c new file +103 -0
new file mode 100644
index 000000000..157ced608
@@ -0,0 +1,103 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (C) 2020 Cyril Hrubis <[email protected]>
+ */
+/*
+ * Test for a SHM_SET.
+ *
+ * The test clears the group and others bits from the shm_perm.mode and checks
+ * the result as well as if the ctime was updated correctly.
+ */
+
+#define _GNU_SOURCE
+#include <stdio.h>
+#include "tst_test.h"
+#include "tst_safe_sysv_ipc.h"
+#include "libnewipc.h"
+
+#define SHM_SIZE 2048
+
+static int shm_id = -1;
+
+static int test_ipc_set(struct shmid_ds *ds)
+{
+	TEST(shmctl(shm_id, IPC_SET, ds));
+
+	if (TST_RET != 0) {
+		tst_res(TFAIL, "shmctl(%i, IPC_SET, ...)", shm_id);
+		return 1;
+	}
+
+	tst_res(TPASS, "shmctl(%i, IPC_SET, {shm_perm.mode=%04o})",
+		shm_id, ds->shm_perm.mode);
+	return 0;
+}
+
+static void check_mode(struct shmid_ds *ds, short exp_mode)
+{
+	if (ds->shm_perm.mode == exp_mode) {
+		tst_res(TPASS, "shm_perm.mode=%04o", exp_mode);
+		return;
+	}
+
+	tst_res(TFAIL, "shm_perm.mode=%04o, expected %i",
+	        ds->shm_perm.mode, exp_mode);
+}
+
+static void verify_shmset(void)
+{
+	struct shmid_ds ds;
+	unsigned short old_mode;
+	time_t old_ctime;
+
+	SAFE_SHMCTL(shm_id, IPC_STAT, &ds);
+
+	old_mode = ds.shm_perm.mode;
+	old_ctime = ds.shm_ctime;
+
+	check_mode(&ds, 0666);
+
+	sleep(1);
+
+	ds.shm_perm.mode &= ~0066;
+
+	if (test_ipc_set(&ds))
+		return;
+
+	memset(&ds, 0, sizeof(ds));
+	SAFE_SHMCTL(shm_id, IPC_STAT, &ds);
+	check_mode(&ds, old_mode & ~0066);
+
+	if (ds.shm_ctime <= old_ctime || ds.shm_ctime > old_ctime + 10) {
+		tst_res(TFAIL, "shm_ctime not updated old %li new %li",
+		        (long)old_ctime, (long)ds.shm_ctime);
+	} else {
+		tst_res(TPASS, "shm_ctime updated correctly diff=%li",
+		        (long)(ds.shm_ctime - old_ctime));
+	}
+
+	ds.shm_perm.mode = old_mode;
+	if (test_ipc_set(&ds))
+		return;
+
+	memset(&ds, 0, sizeof(ds));
+	SAFE_SHMCTL(shm_id, IPC_STAT, &ds);
+	check_mode(&ds, old_mode & MODE_MASK);
+}
+
+static void setup(void)
+{
+	shm_id = SAFE_SHMGET(IPC_PRIVATE, SHM_SIZE, IPC_CREAT | 0666);
+}
+
+static void cleanup(void)
+{
+	if (shm_id >= 0)
+		SAFE_SHMCTL(shm_id, IPC_RMID, NULL);
+}
+
+static struct tst_test test = {
+	.setup = setup,
+	.cleanup = cleanup,
+	.test_all = verify_shmset,
+};
#11 lore raw

PATCH v2 9/10 syscalls/ipc: Add shmctl IPC_SET test

Hi!

Quoted 8 lines
Quoted 8 lines
testcases/kernel/syscalls/ipc/shmctl/shmctl07.c +0 -0
index 409203db7..39b9ad78a 100644
@@ -42,10 +42,12 @@ static void verify_shmlock(void)
  	else
  		tst_res(TPASS, "shmctl(%i, SHM_UNLOCK, NULL)", shm_id);
 
Quoted 11 lines

testcases/kernel/syscalls/ipc/shmctl/shmctl07.c static void verify_shmlock(void) · line 52

Quoted 10 lines
testcases/kernel/syscalls/ipc/shmctl/shmctl07.c +4 -2
+	SAFE_SHMCTL(shm_id, IPC_STAT, &ds);
+
  	if (ds.shm_perm.mode & SHM_LOCKED)
-		tst_res(TPASS, "SHM_LOCKED bit is off in shm_perm.mode");
-	else
  		tst_res(TFAIL, "SMH_LOCKED bit is on in shm_perm.mode");
+	else
+		tst_res(TPASS, "SHM_LOCKED bit is off in shm_perm.mode");
  }
 

This change should belong to "syscalls/ipc: Add shmctl07 test" patch.

My bad I messed up, will fix that later on.

Anything else I missed there?

Signature · 2 lines
Cyril Hrubis
[email protected]
#12 lore raw

PATCH v2 9/10 syscalls/ipc: Add shmctl IPC_SET test

Hi Cyril

Quoted 21 lines

Hi!

Quoted 8 lines
Quoted 8 lines
testcases/kernel/syscalls/ipc/shmctl/shmctl07.c +0 -0
index 409203db7..39b9ad78a 100644
@@ -42,10 +42,12 @@ static void verify_shmlock(void)
   	else
   		tst_res(TPASS, "shmctl(%i, SHM_UNLOCK, NULL)", shm_id);
 
Quoted 11 lines

testcases/kernel/syscalls/ipc/shmctl/shmctl07.c static void verify_shmlock(void) · line 52

Quoted 10 lines
testcases/kernel/syscalls/ipc/shmctl/shmctl07.c +4 -2
+	SAFE_SHMCTL(shm_id, IPC_STAT, &ds);
+
   	if (ds.shm_perm.mode & SHM_LOCKED)
-		tst_res(TPASS, "SHM_LOCKED bit is off in shm_perm.mode");
-	else
   		tst_res(TFAIL, "SMH_LOCKED bit is on in shm_perm.mode");
+	else
+		tst_res(TPASS, "SHM_LOCKED bit is off in shm_perm.mode");
   }
 

This change should belong to "syscalls/ipc: Add shmctl07 test" patch.

Quoted 3 lines

My bad I messed up, will fix that later on.

Anything else I missed there?

I have seen the whole patchset, only find this.

Quoted 1 line
#13 lore raw

PATCH v2 10/10 syscalls/ipc: Rewrite shmctl01

In reply to Cyril Hrubis

This commit rewrites the shmctl01 and only keep testcases not covered by the rest of the testcases.

---
 testcases/kernel/syscalls/ipc/shmctl/Makefile |   1 -
 .../kernel/syscalls/ipc/shmctl/shmctl01.c     | 586 ++++++------------
 2 files changed, 178 insertions(+), 409 deletions(-)
testcases/kernel/syscalls/ipc/shmctl/Makefile +0 -1
index 9d535014f..106b73697 100644
@@ -10,7 +10,6 @@ shmctl05: LDLIBS += -lrt
 
 include $(top_srcdir)/include/mk/testcases.mk
 
-shmctl01: LTPLDLIBS = -lltpipc
 shmctl02 shmctl04 shmctl06: LTPLDLIBS = -lltpnewipc
 
 include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/syscalls/ipc/shmctl/shmctl01.c +178 -408

677 lines not on this page · raw message

Signature · 1 line
2.26.2
#14 lore raw

v2 cover Rewrite shmctl() testcases

In reply to Cyril Hrubis

For the series:

Signature · 5 lines
Regards,
Li Wang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20200909/787b8589/attachment.htm>
#15 lore raw

v2 cover Rewrite shmctl() testcases

Hi!
Thanks for the review, pushed.

I've fixed the patch that was incorrectly ammended as well.

Signature · 2 lines
Cyril Hrubis
[email protected]