Skip to contentSkip to conversation

Rewrite shmctl() testcases

PATCH Superseded Cyril Hrubis 5 participants 24 messages Jul 17, 2020 – Sep 7, 2020 Library code

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

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.

Cyril Hrubis (9):
syscalls/ipc: shmctl02: Convert to the new library syscalls/ipc: shmctl03: Remove. 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/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     | 214 +------
 .../kernel/syscalls/ipc/shmctl/shmctl04.c     | 190 +++---
 .../kernel/syscalls/ipc/shmctl/shmctl07.c     |  66 ++
 .../kernel/syscalls/ipc/shmctl/shmctl08.c     | 101 +++
 12 files changed, 593 insertions(+), 859 deletions(-)
 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 1/9 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 0172bb495..bc5bd7c2e 100644
@@ -10,7 +10,7 @@ shmctl05: LDLIBS += -lrt
 
 include $(top_srcdir)/include/mk/testcases.mk
 
-shmctl01 shmctl02 shmctl03 shmctl04 shmctl05: LDLIBS += -lltpipc
-shmctl06: LDLIBS += -lltpnewipc
+shmctl01 shmctl03 shmctl04 shmctl05: LDLIBS += -lltpipc
+shmctl02 shmctl06: LDLIBS += -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 1/9 syscalls/ipc: shmctl02: Convert to the new library

Hi Cyril,

This patch looks quite good except for some typos. (Test get passed on both RHEL8(x86_64) and RHEL7(ppc64))

Quoted 2 lines · Cyril Hrubis
Quoted 20 lines
---
 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 0172bb495..bc5bd7c2e 100644
@@ -10,7 +10,7 @@ shmctl05: LDLIBS += -lrt
 
 include $(top_srcdir)/include/mk/testcases.mk
 
-shmctl01 shmctl02 shmctl03 shmctl04 shmctl05: LDLIBS += -lltpipc
-shmctl06: LDLIBS += -lltpnewipc
+shmctl01 shmctl03 shmctl04 shmctl05: LDLIBS += -lltpipc
+shmctl02 shmctl06: LDLIBS += -lltpnewipc
 

testcases/kernel/syscalls/ipc/shmctl/Makefile shmctl05: LDLIBS += -lrt

Quoted 10 lines
testcases/kernel/syscalls/ipc/shmctl/Makefile +6 -2
...
+ * * EFAULT - IPC_SET & buf isn't valid
+ * * EFAULT - IPC_STAT & buf isn't valid
+ * * EINVAL - the command is not valid
+ * * EINVAL - the shmid is not valid
+ * * EINVAL - the shmid belongs to removed shm
  *
- * RESTRICTIONS
- *     none
+ * * EPERM - attempt to stat root owned shm

^ EACCES

testcases/kernel/syscalls/ipc/shmctl/Makefile

Quoted 12 lines

+ * * EPERM - attempt delete root owned shm
+ * * EPERM - attempt to change root owned shm
+ * * EPERM - attempt to lock root owned shm
+ * * EPERM - attempt to unlock root owned shm
*/

...

testcases/kernel/syscalls/ipc/shmctl/Makefile +2 -1
-       cleanup();
+       if (TST_ERR == tc[i].error) {
+               tst_res(TPASS | TTERRNO, "msgctl(%i, %i, %p)",

Here should be shmctl() but not msgctl().

testcases/kernel/syscalls/ipc/shmctl/Makefile

Quoted 7 lines
testcases/kernel/syscalls/ipc/shmctl/Makefile +4 -1
+                       *tc[i].shm_id, tc[i].cmd, tc[i].buf);
+               return;
+       }
 
-       tst_exit();
+       tst_res(TFAIL | TTERRNO, "msgctl(%i, %i, %p) expected %s",

msgctl -- > shmctl().

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

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

In reply to Cyril Hrubis

Hello,
Li Wang already suggested the most important fixes so I'll just add two more typos on top. Otherwise it looks good.

Quoted 1 line · Cyril Hrubis
Quoted 17 lines
---
 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/shmctl02.c +1 -3
index 0b97bb240..7b05325ee 100644
@@ -1,213 +1,124 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
 /*
...
  *
- *      06/03/2008 Renaud Lottiaux ([email protected])
- *      - Fix concurrency issue. The second key used for this test could
- *        conflict with the key from another task.

testcases/kernel/syscalls/ipc/shmctl/shmctl02.c line 21

Quoted 10 lines
testcases/kernel/syscalls/ipc/shmctl/shmctl02.c +7 -2
+ * * EACCES - segment has no read or write permissions
+ * * EFAULT - IPC_SET & buf isn't valid
+ * * EFAULT - IPC_STAT & buf isn't valid
+ * * EINVAL - the command is not valid
+ * * EINVAL - the shmid is not valid
+ * * EINVAL - the shmid belongs to removed shm
  *
- * RESTRICTIONS
- *	none
+ * * EPERM - attempt to stat root owned shm

^ "root-owned" is missing a dash throughout this file

Quoted 1 line

+ * * EPERM - attempt delete root owned shm

^ attempt *TO* delete ...

Quoted 7 lines

+ * * EPERM - attempt to change root owned shm
+ * * EPERM - attempt to lock root owned shm
+ * * EPERM - attempt to unlock root owned shm
*/

testcases/kernel/syscalls/ipc/shmctl/shmctl02.c +0 -1
-#include "ipcshm.h"
 #include <pwd.h>

testcases/kernel/syscalls/ipc/shmctl/shmctl02.c line 56

Quoted 10 lines
testcases/kernel/syscalls/ipc/shmctl/shmctl02.c +8 -0
 
...
+} tc[] = {
+	{&shm_id1, IPC_STAT, &buf, EACCES},
+	{&shm_id2, IPC_SET, (struct shmid_ds *)-1, EFAULT},
+	{&shm_id2, IPC_STAT, (struct shmid_ds *)-1, EFAULT},
+	{&shm_id2, -1, &buf, EINVAL},
+	{&shm_bad, IPC_STAT, &buf, EINVAL},
+	{&shm_rem, IPC_STAT, &buf, EINVAL},
+	/* Operations on root owned shm */

^ Last instance of "root-owned" without a dash

Signature · 7 lines
Martin Doucha   [email protected]
QA Engineer for Software Maintenance
SUSE LINUX, s.r.o.
CORSO IIa
Krizikova 148/34
186 00 Prague 8
Czech Republic
#4 lore raw

PATCH 2/9 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 819e8d8ee..5ce482dc7 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 c3a35896c..10cb92c7d 100644
@@ -53,7 +53,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 bc5bd7c2e..33e102797 100644
@@ -10,7 +10,7 @@ shmctl05: LDLIBS += -lrt
 
 include $(top_srcdir)/include/mk/testcases.mk
 
-shmctl01 shmctl03 shmctl04 shmctl05: LDLIBS += -lltpipc
+shmctl01 shmctl04 shmctl05: LDLIBS += -lltpipc
 shmctl02 shmctl06: LDLIBS += -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
#5 lore raw

PATCH 3/9 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     | 190 ++++++++++--------
 2 files changed, 109 insertions(+), 85 deletions(-)
testcases/kernel/syscalls/ipc/shmctl/Makefile +2 -2
index 33e102797..30bb1a537 100644
@@ -10,7 +10,7 @@ shmctl05: LDLIBS += -lrt
 
 include $(top_srcdir)/include/mk/testcases.mk
 
-shmctl01 shmctl04 shmctl05: LDLIBS += -lltpipc
-shmctl02 shmctl06: LDLIBS += -lltpnewipc
+shmctl01 shmctl05: LDLIBS += -lltpipc
+shmctl02 shmctl04 shmctl06: LDLIBS += -lltpnewipc
 
 include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/syscalls/ipc/shmctl/shmctl04.c +107 -83

222 lines not on this page · raw message

Signature · 1 line
2.26.2
#6 lore raw

PATCH 3/9 syscalls/ipc: shmctl04: Rewrite from scratch.

Quoted 18 lines · Cyril Hrubis

...

(quoted diff) +2 -0
+       /*
+        * Sum rss, swap and size for all elements listed, which should

equal

testcases/kernel/syscalls/ipc/shmctl/shmctl04.c +3 -0
+        * the data returned in the shm_info structure.
+        *
+        * Note that the size has to be rounded up to nearest multiple of

page

testcases/kernel/syscalls/ipc/shmctl/shmctl04.c +3 -0
+        * size.
+        */
+       while (fscanf(f, "%*i %i %*i %i %*i %*i %*i %*i %*i %*i %*i %*i

%*i %*i %i %i",

testcases/kernel/syscalls/ipc/shmctl/shmctl04.c +5 -0
+                     &shmid, &size, &rss, &swap) > 0) {
+               used_ids++;
+               shm_rss += rss/page_size;
+               shm_swp += swap/page_size;
+               shm_tot += (size + page_size - 1) / page_size;

testcases/kernel/syscalls/ipc/shmctl/shmctl04.c line 96

Quoted 10 lines
testcases/kernel/syscalls/ipc/shmctl/shmctl04.c +6 -1
+               if (shmid > shmid_max)
+                       shmid_max = shmid;
+       }
 
...
 
-       tst_exit();
+       if (max_id != shmid_max) {
+               tst_res(TFAIL, "highest shmid = %i, expected %i",
+                       max_id, shmid_max);

It failed many times on my personal laptop (5.4.19-100.fc30.x86_64).

$ cat /proc/sysvipc/shm
       key      shmid   perms        size      cpid    lpid    nattch   uid
  gid    cuid    cgid      atime         dtime              ctime
     rss        swap
         0          6         1600      524288   2778   5447      2     1000
 1000  1000  1000 1595120306 1595120306 1595119412      4096        0
         0          8         1600      524288   1903   2043      2     1000
 1000  1000  1000 1595119515     0                 1595119515     24576
   0
$ ./shmctl04
tst_test.c:1245: INFO: Timeout per run is 0h 05m 00s
shmctl04.c:119: PASS: SHM_INFO returned valid index 8
shmctl04.c:70: PASS: used_ids = 3
shmctl04.c:77: PASS: shm_rss = 7
shmctl04.c:84: PASS: shm_swp = 0
shmctl04.c:91: PASS: shm_tot = 257
shmctl04.c:95: FAIL: highest shmid = 8, expected 65537

Summary:

passed   5
failed   1
skipped  0

warnings 0

After printing the shm_proc during test running, I guess the 'shmid' is not listing in number order sometimes which probably caused that failure.

key shmid perms size cpid lpid nattch uid
gid cuid cgid atime dtime ctime rss

               swap
         0      98306   600                  2048 29586     0      0  1000
 1000  1000  1000          0          0 1595144682                     0
                  0
         0          6  1600                524288  2778 26559      2  1000
 1000  1000  1000 1595142041 1595142041 1595119412                  4096
                  0
         0          8  1600                524288  1903  2043      2  1000
 1000  1000  1000 1595119515          0 1595119515                 24576
                  0
Quoted 21 lines
testcases/kernel/syscalls/ipc/shmctl/shmctl04.c +9 -6
+       } else {
+               tst_res(TPASS, "highest shmid = %i", max_id);
+       }
 }
 
-/*
- * setup() - performs all the ONE TIME setup for this test.
- */
-void setup(void)
+static void verify_shminfo(void)
 {
+       struct shm_info info;
+       struct shmid_ds ds;
 
-       tst_sig(NOFORK, DEF_HANDLER, cleanup);
+       TEST(shmctl(0, SHM_INFO, (struct shmid_ds *)&info));
 
-       TEST_PAUSE;
+       if (TST_RET == -1) {
+               tst_res(TFAIL | TTERRNO, "shmctl(0, SHM_INFO, ...)");

testcases/kernel/syscalls/ipc/shmctl/shmctl04.c line 114

Quoted 10 lines
testcases/kernel/syscalls/ipc/shmctl/shmctl04.c +3 -6
+               return;
+       }
 
-       /*
-        * Create a temporary directory and cd into it.
-        * This helps to ensure that a unique msgkey is created.
-        * See libs/libltpipc/libipc.c for more information.
-        */
-       tst_tmpdir();
+       TEST(shmctl(TST_RET, SHM_STAT_ANY, &ds));

'SHM_STAT_ANY' is introduced since Linux 4.17. We have to confirm the SUT supporting before we running it.

Also, we'd better define it in "ipcshm.h" to avoid compiling errors with the old distro.

shmctl04.c: In function 'verify_shminfo':
shmctl04.c:114: error: 'SHM_STAT_ANY' undeclared (first use in this function)
shmctl04.c:114: error: (Each undeclared identifier is reported only once shmctl04.c:114: error: for each function it appears in.)

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

PATCH 3/9 syscalls/ipc: shmctl04: Rewrite from scratch.

Hi!

Quoted 21 lines

It failed many times on my personal laptop (5.4.19-100.fc30.x86_64).

$ cat /proc/sysvipc/shm
       key      shmid   perms        size      cpid    lpid    nattch   uid
  gid    cuid    cgid      atime         dtime              ctime
     rss        swap
         0          6         1600      524288   2778   5447      2     1000
 1000  1000  1000 1595120306 1595120306 1595119412      4096        0
         0          8         1600      524288   1903   2043      2     1000
 1000  1000  1000 1595119515     0                 1595119515     24576
   0
$ ./shmctl04
tst_test.c:1245: INFO: Timeout per run is 0h 05m 00s
shmctl04.c:119: PASS: SHM_INFO returned valid index 8
shmctl04.c:70: PASS: used_ids = 3
shmctl04.c:77: PASS: shm_rss = 7
shmctl04.c:84: PASS: shm_swp = 0
shmctl04.c:91: PASS: shm_tot = 257
shmctl04.c:95: FAIL: highest shmid = 8, expected 65537
Quoted 8 lines

Summary:

passed   5
failed   1
skipped  0

warnings 0

After printing the shm_proc during test running, I guess the 'shmid' is not listing in number order sometimes which probably caused that failure.

Looking at the result closely, I guess that I messed up and got confused here, the return value from SHM_INFO is highest index into the kernel array, which is equal to highest shmid only by an accident on a freshly booted machine. I will fix that part in v2.

Quoted 11 lines

'SHM_STAT_ANY' is introduced since Linux 4.17. We have to confirm the SUT supporting before we running it.

Also, we'd better define it in "ipcshm.h" to avoid compiling errors with the old distro.

shmctl04.c: In function 'verify_shminfo':
shmctl04.c:114: error: 'SHM_STAT_ANY' undeclared (first use in this function)
shmctl04.c:114: error: (Each undeclared identifier is reported only once shmctl04.c:114: error: for each function it appears in.)

Will fix as well.

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

PATCH 3/9 syscalls/ipc: shmctl04: Rewrite from scratch.

In reply to Cyril Hrubis

Hi Cyril,

Review

Quoted 7 lines
(quoted diff) +1 -6
-	/*
-	 * Create a temporary directory and cd into it.
-	 * This helps to ensure that a unique msgkey is created.
-	 * See libs/libltpipc/libipc.c for more information.
-	 */
-	tst_tmpdir();
+	TEST(shmctl(TST_RET, SHM_STAT_ANY, &ds));

Several old distros fail [1] as they miss SHM_STAT_ANY in <bits/shm.h> (added to glibc in 2.28, to kernel in 4.17).
Of course, it's just enough to add the definition to include/tst_safe_sysv_ipc.h (or some LAPI file).

Kind regards,
Petr

[1] https://travis-ci.org/github/pevik/ltp/builds/712476731

tst_safe_sysv_ipc.h +4 -0
index 3e0e50e8d..dea85f97c 100644
@@ -10,6 +10,10 @@
 #include <sys/msg.h>
 #include <sys/shm.h>
 
+#ifndef SHM_STAT_ANY
+# define SHM_STAT_ANY	15
+#endif
+
 int safe_msgget(const char *file, const int lineno, key_t key, int msgflg);
 #define SAFE_MSGGET(key, msgflg) \
 	safe_msgget(__FILE__, __LINE__, (key), (msgflg))
#9 lore raw

PATCH 4/9 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 30bb1a537..a004084ad 100644
@@ -10,7 +10,7 @@ shmctl05: LDLIBS += -lrt
 
 include $(top_srcdir)/include/mk/testcases.mk
 
-shmctl01 shmctl05: LDLIBS += -lltpipc
+shmctl01: LDLIBS += -lltpipc
 shmctl02 shmctl04 shmctl06: LDLIBS += -lltpnewipc
 
 include $(top_srcdir)/include/mk/generic_leaf_target.mk
Signature · 1 line
2.26.2
#10 lore raw

PATCH 5/9 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
#11 lore raw

PATCH 6/9 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     | 38 +++++++++++++++++++
 4 files changed, 41 insertions(+)
 create mode 100644 testcases/kernel/syscalls/ipc/shmctl/shmctl03.c
runtest/syscalls +1 -0
index 5ce482dc7..819e8d8ee 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 10cb92c7d..c3a35896c 100644
@@ -53,6 +53,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 +38 -0
new file mode 100644
index 000000000..7df8c12ce
@@ -0,0 +1,38 @@
+// 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 == -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,
+};
Signature · 1 line
2.26.2
#12 lore raw

PATCH 6/9 syscalls/ipc: Add shmctl() IPC_INFO test

For patches 2/4/5/6:

Signature · 5 lines
Regards,
Li Wang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20200719/63958bb9/attachment-0001.htm>
#13 lore raw

PATCH 6/9 syscalls/ipc: Add shmctl() IPC_INFO test

In reply to Cyril Hrubis

Hello,
for patches 2, 4 and 5:

Patch 3 needs a test scenario redesign as reported by Li Wang.

In this patch, you should also check for other negative return values from shmctl() besides -1.

Quoted 65 lines · Cyril Hrubis
---
 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
runtest/syscalls +1 -0
index 5ce482dc7..819e8d8ee 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 10cb92c7d..c3a35896c 100644
@@ -53,6 +53,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 +15 -0
new file mode 100644
index 000000000..7df8c12ce
@@ -0,0 +1,38 @@
+// 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)

testcases/kernel/syscalls/ipc/shmctl/shmctl03.c line 25

Quoted 10 lines
testcases/kernel/syscalls/ipc/shmctl/shmctl03.c new file +10 -0
+{
+	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 (TST_RET < 0)

	tst_res(TFAIL...)
Quoted 14 lines
testcases/kernel/syscalls/ipc/shmctl/shmctl03.c new file +13 -0
+	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 · 7 lines
Martin Doucha   [email protected]
QA Engineer for Software Maintenance
SUSE LINUX, s.r.o.
CORSO IIa
Krizikova 148/34
186 00 Prague 8
Czech Republic
#14 lore raw

PATCH 7/9 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 819e8d8ee..1dc4973e7 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 c3a35896c..613987589 100644
@@ -57,6 +57,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
#15 lore raw

PATCH 7/9 syscalls/ipc: Add shmctl07 test

Quoted 28 lines · Cyril Hrubis

...

(quoted diff) +9 -0
+
+static void verify_shmlock(void)
+{
+       struct shmid_ds ds;
+
+       TEST(shmctl(shm_id, SHM_LOCK, NULL));
+
+       if (TST_RET != 0)
+               tst_res(TFAIL | TTERRNO, "shmctl(%i, SHM_LOCK, NULL)",

shm_id);

(quoted diff) +15 -0
+       else
+               tst_res(TPASS, "shmctl(%i, SHM_LOCK, NULL)", shm_id);
+
+
+       SAFE_SHMCTL(shm_id, IPC_STAT, &ds);
+
+       if (ds.shm_perm.mode & SHM_LOCKED)
+               tst_res(TPASS, "SMH_LOCKED bit is on in shm_perm.mode");
+       else
+               tst_res(TFAIL, "SHM_LOCKED bit is off in shm_perm.mode");
+
+       TEST(shmctl(shm_id, SHM_UNLOCK, NULL));
+
+       if (TST_RET != 0)
+               tst_res(TFAIL | TTERRNO, "shmctl(%i, SHM_UNLOCK, NULL)",

shm_id);

Review

Quoted 3 lines
(quoted diff) +3 -0
+       else
+               tst_res(TPASS, "shmctl(%i, SHM_UNLOCK, NULL)", shm_id);
+

Shouldn't we do update 'ds' before checking the ds.shm_perm.mode?

testcases/kernel/syscalls/ipc/shmctl/shmctl07.c +3 -2
@@ -42,10 +42,11 @@ 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");
 }
 
 

Review

Quoted 3 lines
(quoted diff) +2 -0
+       if (ds.shm_perm.mode & SHM_LOCKED)
+               tst_res(TPASS, "SHM_LOCKED bit is off in shm_perm.mode");

And in this branch, the status should be "on" but not "off".

Quoted 28 lines
(quoted diff) +20 -1
+       else
+               tst_res(TFAIL, "SMH_LOCKED bit is on in shm_perm.mode");
+}
+
+static void setup(void)
+{
+       shm_id = SAFE_SHMGET(IPC_PRIVATE, SHM_SIZE, IPC_CREAT | SHM_RW);
+}
+
+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_shmlock,
+};
--

2.26.2

--
Mailing list info: https://lists.linux.it/listinfo/ltp

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

PATCH 7/9 syscalls/ipc: Add shmctl07 test

Hi!

Quoted 19 lines

Shouldn't we do update 'ds' before checking the ds.shm_perm.mode?

testcases/kernel/syscalls/ipc/shmctl/shmctl07.c +3 -2
@@ -42,10 +42,11 @@ 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");
 }
 
 
Quoted 5 lines

Review

Quoted 3 lines
(quoted diff) +2 -0
+       if (ds.shm_perm.mode & SHM_LOCKED)
+               tst_res(TPASS, "SHM_LOCKED bit is off in shm_perm.mode");

And in this branch, the status should be "on" but not "off".

And also TFAIL.

All will be fixed in v2, thx for the review.

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

PATCH 8/9 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/shmctl08.c     | 101 ++++++++++++++++++
 4 files changed, 104 insertions(+)
 create mode 100644 testcases/kernel/syscalls/ipc/shmctl/shmctl08.c
runtest/syscalls +1 -0
index 1dc4973e7..00c8d6d66 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 613987589..d3d477741 100644
@@ -58,6 +58,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/shmctl08.c new file +101 -0

101 lines not on this page · raw message

Signature · 1 line
2.26.2
#18 lore raw

PATCH 8/9 syscalls/ipc: Add shmctl IPC_SET test

Quoted 15 lines · Cyril Hrubis

...

testcases/kernel/syscalls/ipc/shmctl/shmctl08.c new file +13 -0
+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;
+
+       sleep(1);
+

testcases/kernel/syscalls/ipc/shmctl/shmctl08.c line 69

Quoted 10 lines
testcases/kernel/syscalls/ipc/shmctl/shmctl08.c new file +10 -0
+       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 > 10) {

Maybe we also need to consider a situation that timestamp is just as previous value?
i.e.

    if (ds.shm_ctime - old_ctime > 10 || ds.shm_ctime - old_ctime == 0)
Quoted 8 lines
testcases/kernel/syscalls/ipc/shmctl/shmctl08.c new file +7 -0
+               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));
+       }
+
Signature · 5 lines
Regards,
Li Wang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20200720/3ac9f733/attachment.htm>
#19 lore raw

PATCH 8/9 syscalls/ipc: Add shmctl IPC_SET test

Hi!

Quoted 4 lines

Maybe we also need to consider a situation that timestamp is just as previous value?
i.e.

    if (ds.shm_ctime - old_ctime > 10 || ds.shm_ctime - old_ctime == 0)

I will change that to a range check, I.e. the ds.shm_ctime must be greater than old_ctime and smaller than old_ctime + 10.

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

PATCH 8/9 syscalls/ipc: Add shmctl IPC_SET test

In reply to Cyril Hrubis

Hi,
I'm skipping patch 7 because Li Wang already reported the missing shmctl(IPC_STAT) before the (flipped) final check for SHM_LOCKED flag.

Here, Li Wang already reported the issue with ctime check so I'll just add two minor suggestions for improvement.

Quoted 69 lines · Cyril Hrubis
---
 runtest/syscalls                              |   1 +
 runtest/syscalls-ipc                          |   1 +
 .../kernel/syscalls/ipc/shmctl/.gitignore     |   1 +
 .../kernel/syscalls/ipc/shmctl/shmctl08.c     | 101 ++++++++++++++++++
 4 files changed, 104 insertions(+)
 create mode 100644 testcases/kernel/syscalls/ipc/shmctl/shmctl08.c
runtest/syscalls +1 -0
index 1dc4973e7..00c8d6d66 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 613987589..d3d477741 100644
@@ -58,6 +58,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/shmctl08.c new file +21 -0
new file mode 100644
index 000000000..2c83e9901
@@ -0,0 +1,101 @@
+// 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;
+

testcases/kernel/syscalls/ipc/shmctl/shmctl08.c line 31

Quoted 10 lines
testcases/kernel/syscalls/ipc/shmctl/shmctl08.c new file +10 -0
+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=%i})",

Formatting mode values with %04o would be better here, also in check_mode() below.

Quoted 15 lines
testcases/kernel/syscalls/ipc/shmctl/shmctl08.c new file +15 -0
+		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=%i was updated", exp_mode);
+		return;
+	}
+
+	tst_res(TFAIL, "shm_perm.mode=%i wasn't updated, expected %i",
+	        ds->shm_perm.mode, exp_mode);
+}
+

testcases/kernel/syscalls/ipc/shmctl/shmctl08.c line 56

Quoted 10 lines
testcases/kernel/syscalls/ipc/shmctl/shmctl08.c new file +10 -0
+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;

I'd recommend validating old_mode as well.

Quoted 46 lines
testcases/kernel/syscalls/ipc/shmctl/shmctl08.c new file +45 -0
+
+	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 > 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,
+};
Signature · 7 lines
Martin Doucha   [email protected]
QA Engineer for Software Maintenance
SUSE LINUX, s.r.o.
CORSO IIa
Krizikova 148/34
186 00 Prague 8
Czech Republic
#21 lore raw

PATCH 9/9 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 a004084ad..64d76112a 100644
@@ -10,7 +10,6 @@ shmctl05: LDLIBS += -lrt
 
 include $(top_srcdir)/include/mk/testcases.mk
 
-shmctl01: LDLIBS += -lltpipc
 shmctl02 shmctl04 shmctl06: LDLIBS += -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
#22 lore raw

PATCH 9/9 syscalls/ipc: Rewrite shmctl01

Hello,
redesigned test scenario looks good so the only thing blocking merge here are the bugs in preceding patches.

Quoted 4 lines · Cyril Hrubis

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

Quoted 700 lines
---
 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 a004084ad..64d76112a 100644
@@ -10,7 +10,6 @@ shmctl05: LDLIBS += -lrt
 
 include $(top_srcdir)/include/mk/testcases.mk
 
-shmctl01: LDLIBS += -lltpipc
 shmctl02 shmctl04 shmctl06: LDLIBS += -lltpnewipc
 
 include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/syscalls/ipc/shmctl/shmctl01.c +178 -408
index 52bf23a40..3a39a4d74 100644
@@ -1,499 +1,269 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
 /*
  * Copyright (c) International Business Machines  Corp., 2001
- *
- * This program is free software;  you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY;  without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
- * the GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program;  if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ * Copyright (C) 2020 Cyril Hrubis <[email protected]>
  */
-
 /*
- * NAME
- *	shmctl01.c
+ * Verify that shmctl() IPC_STAT and SHM_STAT reports correct data.
+ *
+ * The shm_nattach is excercised by:
  *
- * DESCRIPTION
- *	shmctl01 - test the IPC_STAT, IPC_SET and IPC_RMID commands as
- *		   they are used with shmctl()
+ * 1. forking() children that attach and detach SHM
+ * 2. attaching the SHM before fork and letting the children detach it
  *
- * ALGORITHM
- *	loop if that option was specified
- *	create a shared memory segment with read and write permission
- *	set up any test case specific conditions
- *	call shmctl() using the TEST macro
- *	check the return code
- *	  if failure, issue a FAIL message.
- *	otherwise,
- *	  if doing functionality testing
- *		call the correct test function
- *		if the conditions are correct,
- *			issue a PASS message
- *		otherwise
- *			issue a FAIL message
- *	  otherwise
- *	    issue a PASS message
- *	call cleanup
+ * We check that the number shm_nattach is correct after each step we do.
  */
 
-#ifndef _GNU_SOURCE
 #define _GNU_SOURCE
-#endif
-#include "ipcshm.h"
-#include "safe_macros.h"
-
-char *TCID = "shmctl01";
-
-static int shm_id_1 = -1;
-static int shm_index;
-static struct shmid_ds buf;
-static struct shminfo info;
-static long save_time;
-
-#define FIRST	0
-#define SECOND	1
-static int stat_time;
-
-static void *set_shared;
-
-#define N_ATTACH	4
-
-static pid_t pid_arr[N_ATTACH];
-
-/* Setup, cleanup and check routines for IPC_STAT */
-static void stat_setup(void), func_istat(int ret);
-static void stat_cleanup(void);
-
-/* Setup and check routines for IPC_SET */
-static void set_setup(void), func_set(int ret);
-
-/* Check routine for IPC_INFO */
-static void func_info(int ret);
-
-/* Check routine for SHM_STAT */
-static void func_sstat(int ret);
-static void func_sstat_setup(void);
-
-/* Check routine for SHM_LOCK */
-static void func_lock(int ret);
-
-/* Check routine for SHM_UNLOCK */
-static void func_unlock(int ret);
-
-/* Check routine for IPC_RMID */
-static void func_rmid(int ret);
-
-/* Child function */
-static void do_child(void);
-
-static struct test_case_t {
-	int *shmid;
-	int cmd;
-	struct shmid_ds *arg;
-	void (*func_test) (int);
-	void (*func_setup) (void);
-} TC[] = {
-	{&shm_id_1, IPC_STAT, &buf, func_istat, stat_setup},
-#ifndef UCLINUX
-	    /*
-	     * The second test is not applicable to uClinux;
-	     * shared memory segments are detached on exec(),
-	     * so cannot be passed to uClinux children.
-	     */
-	{&shm_id_1, IPC_STAT, &buf, func_istat, stat_setup},
-#endif
-	{&shm_id_1, IPC_SET, &buf, func_set, set_setup},
-	{&shm_id_1, IPC_INFO, (struct shmid_ds *) &info, func_info, NULL},
-	{&shm_index, SHM_STAT, &buf, func_sstat, func_sstat_setup},
-	{&shm_id_1, SHM_LOCK, NULL, func_lock, NULL},
-	{&shm_id_1, SHM_UNLOCK, NULL, func_unlock, NULL},
-	{&shm_id_1, IPC_RMID, NULL, func_rmid, NULL},
-};
+#include <stdlib.h>
+#include "tst_test.h"
+#include "tst_safe_sysv_ipc.h"
+#include "libnewipc.h"
 
-static int TST_TOTAL = ARRAY_SIZE(TC);
+#define NCHILD 20
 
-#define NEWMODE	0066
+static pid_t children[NCHILD];
 
-#ifdef UCLINUX
-#define PIPE_NAME	"shmctl01"
-static char *argv0;
-#endif
+static int shm_id;
+static int shm_idx;
+static time_t ctime_min, ctime_max;
 
-static int stat_i;
+static void *addr;
 
-int main(int argc, char *argv[])
+static void attach_child(void)
 {
-	int lc;
-	int i;
-
-	tst_parse_opts(argc, argv, NULL, NULL);
-#ifdef UCLINUX
-	argv0 = argv[0];
-	maybe_run_child(do_child, "ddd", &stat_i, &stat_time, &shm_id_1);
-#endif
-
-	setup();
-
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-		tst_count = 0;
-
-		stat_time = FIRST;
-
-		/*
-		 * Create a shared memory segment with read and write
-		 * permissions.  Do this here instead of in setup()
-		 * so that looping (-i) will work correctly.
-		 */
-		shm_id_1 = shmget(shmkey, SHM_SIZE,
-				  IPC_CREAT | IPC_EXCL | SHM_RW);
-		if (shm_id_1 == -1)
-			tst_brkm(TBROK, cleanup, "couldn't create the shared"
-				 " memory segment");
-
-		for (i = 0; i < TST_TOTAL; i++) {
-
-			/*
-			 * if needed, set up any required conditions by
-			 * calling the appropriate setup function
-			 */
-			if (TC[i].func_setup != NULL)
-				(*TC[i].func_setup) ();
-
-			TEST(shmctl(*(TC[i].shmid), TC[i].cmd, TC[i].arg));
-
-			if (TEST_RETURN == -1) {
-				tst_resm(TFAIL, "%s call failed - errno "
-					 "= %d : %s", TCID, TEST_ERRNO,
-					 strerror(TEST_ERRNO));
-				continue;
-			}
-			(*TC[i].func_test) (TEST_RETURN);
-		}
-	}
+	pause();
+
+	addr = SAFE_SHMAT(shm_id, NULL, 0);
+
+	pause();
 
-	cleanup();
-	tst_exit();
+	SAFE_SHMDT(addr);
+
+	pause();
+
+	exit(0);
 }
 
-/*
- * set_shmat() - Attach the shared memory and return the pointer.  Use
- *		 this seperate routine to avoid code duplication in
- *		 stat_setup() below.
- */
-void *set_shmat(void)
+static void detach_child(void)
 {
-	void *rval;
-
-	/* attach the shared memory */
-	rval = shmat(shm_id_1, 0, 0);
-
-	/*
-	 * if shmat() fails, the only thing we can do is
-	 * print a message to that effect.
-	 */
-	if (rval == (void *)-1) {
-		tst_resm(TBROK, "shmat() failed - %s", strerror(errno));
-		cleanup();
-	}
+	pause();
+
+	SAFE_SHMDT(addr);
 
-	return rval;
+	pause();
+
+	exit(0);
 }
 
-/*
- * stat_setup() - Set up for the IPC_STAT command with shmctl().
- *		  Make things interesting by forking some children
- *		  that will either attach or inherit the shared memory.
- */
-void stat_setup(void)
+static void fork_children(void (*child_func)(void))
 {
-	void *set_shmat();
-	pid_t pid;
-
-	/*
-	 * The first time through, let the children attach the memory.
-	 * The second time through, attach the memory first and let
-	 * the children inherit the memory.
-	 */
-
-	if (stat_time == SECOND)
-		/*
-		 * use the global "set_shared" variable here so that
-		 * it can be removed in the stat_func() routine.
-		 */
-		set_shared = set_shmat();
-
-	tst_old_flush();
-	for (stat_i = 0; stat_i < N_ATTACH; stat_i++) {
-		pid = FORK_OR_VFORK();
-		if (pid == -1)
-			tst_brkm(TBROK, cleanup, "could not fork");
-
-		if (pid == 0) {
-#ifdef UCLINUX
-			if (self_exec(argv0, "ddd", stat_i, stat_time,
-				      shm_id_1) < 0)
-				tst_brkm(TBROK, cleanup, "could not self_exec");
-#else
-			do_child();
-#endif
-
-		} else {
-			/* save the child's pid for cleanup later */
-			pid_arr[stat_i] = pid;
-			TST_PROCESS_STATE_WAIT(cleanup, pid, 'S');
-		}
+	unsigned int i;
+
+	for (i = 0; i < NCHILD; i++) {
+		pid_t pid = SAFE_FORK();
+
+		if (!pid)
+			child_func();
+
+		children[i] = pid;
 	}
 }
 
-void do_child(void)
+static void wait_for_children(void)
 {
-	void *test;
+	unsigned int i;
 
-	if (stat_time == FIRST)
-		test = set_shmat();
-	else
-		test = set_shared;
+	for (i = 0; i < NCHILD; i++)
+		TST_PROCESS_STATE_WAIT(children[i], 'S', 0);
+}
 
-	memcpy(test, &stat_i, sizeof(stat_i));
+static void signal_children(void)
+{
+	unsigned int i;
 
-	/* pause until we get a signal from stat_cleanup() */
-	pause();
+	for (i = 0; i < NCHILD; i++)
+		SAFE_KILL(children[i], SIGUSR1);
+}
 
-	/* now we're back - detach the memory and exit */
-	if (shmdt(test) == -1)
-		tst_resm(TBROK, "shmdt() failed - %d", errno);
+static void reap_children(void)
+{
+	unsigned int i;
 
-	tst_exit();
+	for (i = 0; i < NCHILD; i++)
+		SAFE_WAITPID(children[i], NULL, 0);
 }
 
-/*
- * func_istat() - check the functionality of the IPC_STAT command with shmctl()
- *		 by looking at the pid of the creator, the segement size,
- *		 the number of attaches and the mode.
- */
-void func_istat(int ret)
+static void check_nattch(int exp_nattch, const char *msg)
 {
-	int fail = 0;
-	pid_t pid;
+	struct shmid_ds ds1;
+	struct shmid_ds ds2;
 
-	/* check perm, pid, nattach and size */
+	SAFE_SHMCTL(shm_id, IPC_STAT, &ds1);
+	SAFE_SHMCTL(shm_idx, SHM_STAT, &ds2);
 
-	pid = getpid();
-
-	if (buf.shm_cpid != pid) {
-		tst_resm(TFAIL, "creator pid is incorrect");
-		fail = 1;
+	if (ds1.shm_nattch != ds2.shm_nattch) {
+		tst_res(TFAIL, "IPC_STAT nattch=%li SHM_STAT nattch=%li",
+			(long)ds1.shm_nattch, (long)ds2.shm_nattch);
+		return;
 	}
 
-	if (!fail && buf.shm_segsz != SHM_SIZE) {
-		tst_resm(TFAIL, "segment size is incorrect");
-		fail = 1;
+	if ((int)ds1.shm_nattch == exp_nattch) {
+		tst_res(TPASS, "%s shm_nattch=%i", msg, exp_nattch);
+		return;
 	}
 
-	/*
-	 * The first time through, only the children attach the memory, so
-	 * the attaches equal N_ATTACH + stat_time (0).  The second time
-	 * through, the parent attaches the memory and the children inherit
-	 * that memory so the attaches equal N_ATTACH + stat_time (1).
-	 */
-	if (!fail && buf.shm_nattch != N_ATTACH + stat_time) {
-		tst_resm(TFAIL, "# of attaches is incorrect - %ld",
-			 buf.shm_nattch);
-		fail = 1;
-	}
+	tst_res(TFAIL, "%s shm_nattcg=%li expected %i",
+	        msg, (long)ds1.shm_nattch, exp_nattch);
+}
 
-	/* use MODE_MASK to make sure we are comparing the last 9 bits */
-	if (!fail && (buf.shm_perm.mode & MODE_MASK) !=
-			((SHM_RW) & MODE_MASK)) {
-		tst_resm(TFAIL, "segment mode is incorrect");
-		fail = 1;
-	}
+static void verify_shmstat_attach(void)
+{
+	fork_children(attach_child);
+	wait_for_children();
 
-	stat_cleanup();
+	check_nattch(0, "before child shmat()");
 
-	/* save the change time for use in the next test */
-	save_time = buf.shm_ctime;
+	signal_children();
+	wait_for_children();
 
-	if (fail)
-		return;
+	check_nattch(NCHILD, "after child shmat()");
+
+	signal_children();
+	wait_for_children();
+
+	check_nattch(0, "after child shmdt()");
 
-	tst_resm(TPASS, "pid, size, # of attaches and mode are correct "
-		 "- pass #%d", stat_time);
+	signal_children();
+	reap_children();
 }
 
-/*
- * stat_cleanup() - signal the children to clean up after themselves and
- *		    have the parent make dessert, er, um, make that remove
- *		    the shared memory that is no longer needed.
- */
-void stat_cleanup(void)
+static void verify_shmstat_inherit(void)
 {
-	int i;
+	addr = SAFE_SHMAT(shm_id, NULL, 0);
 
-	/* wake up the childern so they can detach the memory and exit */
-	for (i = 0; i < N_ATTACH; i++) {
-		SAFE_KILL(cleanup, pid_arr[i], SIGUSR1);
-	}
+	fork_children(detach_child);
+	wait_for_children();
 
-	/* remove the parent's shared memory the second time through */
-	if (stat_time == SECOND) {
-		if (shmdt(set_shared) == -1)
-			tst_resm(TINFO, "shmdt() failed");
-	}
+	check_nattch(NCHILD+1, "inherited after fork()");
 
-	for (i = 0; i < N_ATTACH; i++) {
-		SAFE_WAITPID(cleanup, pid_arr[i], NULL, 0);
-	}
+	signal_children();
+	wait_for_children();
 
-	stat_time++;
-}
+	check_nattch(1, "after child shmdt()");
 
-/*
- * set_setup() - set up for the IPC_SET command with shmctl()
- */
-void set_setup(void)
-{
-	/* set up a new mode for the shared memory segment */
-	buf.shm_perm.mode = SHM_RW | NEWMODE;
+	SAFE_SHMDT(addr);
 
-	/* sleep for one second to get a different shm_ctime value */
-	sleep(1);
+	check_nattch(0, "after parent shmdt()");
+
+	signal_children();
+	reap_children();
 }
 
-/*
- * func_set() - check the functionality of the IPC_SET command with shmctl()
- */
-void func_set(int ret)
+static void check_ds(struct shmid_ds *ds, const char *desc)
 {
-	int fail = 0;
+	pid_t pid = getpid();
 
-	/* first stat the shared memory to get the new data */
-	if (shmctl(shm_id_1, IPC_STAT, &buf) == -1) {
-		tst_resm(TBROK, "stat failed in func_set()");
-		return;
+	if (ds->shm_segsz != SHM_SIZE) {
+		tst_res(TFAIL, "%s: shm_segsz=%zu, expected %i",
+		        desc, ds->shm_segsz, SHM_SIZE);
+	} else {
+		tst_res(TPASS, "%s: shm_segsz=%i", desc, SHM_SIZE);
 	}
 
-	if ((buf.shm_perm.mode & MODE_MASK) !=
-			((SHM_RW | NEWMODE) & MODE_MASK)) {
-		tst_resm(TFAIL, "new mode is incorrect");
-		fail = 1;
+	if (ds->shm_cpid != pid) {
+		tst_res(TFAIL, "%s: shm_cpid=%i, expected %i",
+		        desc, ds->shm_cpid, pid);
+	} else {
+		tst_res(TPASS, "%s: shm_cpid=%i", desc, pid);
 	}
 
-	if (!fail && save_time >= buf.shm_ctime) {
-		tst_resm(TFAIL, "change time is incorrect");
-		fail = 1;
+	if (ds->shm_ctime < ctime_min || ds->shm_ctime > ctime_max) {
+		tst_res(TFAIL, "%s: shm_ctime=%li, expected <%li,%li>",
+			desc, ds->shm_ctime, ctime_min, ctime_max);
+	} else {
+		tst_res(TPASS, "%s: shm_ctime=%li in range <%li,%li>",
+			desc, ds->shm_ctime, ctime_min, ctime_max);
 	}
-
-	if (fail)
-		return;
-
-	tst_resm(TPASS, "new mode and change time are correct");
 }
 
-static void func_info(int ret)
+static void shmstat_basic_check(void)
 {
-	if (info.shmmin != 1)
-		tst_resm(TFAIL, "value of shmmin is incorrect");
-	else
-		tst_resm(TPASS, "get correct shared memory limits");
-}
+	struct shmid_ds ds;
 
-static void func_sstat(int ret)
-{
-	if (ret >= 0)
-		tst_resm(TPASS, "get correct shared memory id for index: %d",
-			shm_index);
-	else
-		tst_resm(TFAIL, "shared memory id is incorrect, index: %d",
-			shm_index);
-}
+	memset(&ds, 0, sizeof(ds));
+	SAFE_SHMCTL(shm_id, IPC_STAT, &ds);
 
-static void func_sstat_setup(void)
-{
-	struct shm_info tmp;
-	int ret;
-
-	ret = shmctl(shm_id_1, SHM_INFO, (void *)&tmp);
-	if (ret < 0)
-		tst_resm(TFAIL|TERRNO, "shmctl(SHM_INFO)");
-	else
-		shm_index = ret;
-}
+	check_ds(&ds, "IPC_STAT");
 
-static void func_lock(int ret)
-{
-	if (shmctl(shm_id_1, IPC_STAT, &buf) == -1) {
-		tst_resm(TBROK, "stat failed in func_lock()");
-		return;
-	}
+	memset(&ds, 0, sizeof(ds));
+	SAFE_SHMCTL(shm_idx, SHM_STAT, &ds);
 
-	if (buf.shm_perm.mode & SHM_LOCKED)
-		tst_resm(TPASS, "SHM_LOCK is set");
-	else
-		tst_resm(TFAIL, "SHM_LOCK is cleared");
+	check_ds(&ds, "SHM_STAT");
 }
 
-static void func_unlock(int ret)
-{
-	if (shmctl(shm_id_1, IPC_STAT, &buf) == -1) {
-		tst_resm(TBROK, "stat failed in func_unlock()");
-		return;
-	}
+static struct tcase {
+	void (*func)(void);
+	const char *desc;
+} tcases[] = {
+	{shmstat_basic_check, "Basic checks"},
+	{verify_shmstat_attach, "Children attach SHM"},
+	{verify_shmstat_inherit, "Chidlren inherit SHM"},
+};
 
-	if (buf.shm_perm.mode & SHM_LOCKED)
-		tst_resm(TFAIL, "SHM_LOCK is set");
-	else
-		tst_resm(TPASS, "SHM_LOCK is cleared");
+static void verify_shmstat(unsigned int n)
+{
+	tst_res(TINFO, "%s", tcases[n].desc);
+	tcases[n].func();
 }
 
+static void dummy_sighandler(int sig)
+{
+	(void)sig;
+}
 
-/*
- * func_rmid() - check the functionality of the IPC_RMID command with shmctl()
- */
-void func_rmid(int ret)
+static int get_shm_idx_from_id(int shm_id)
 {
-	/* Do another shmctl() - we should get EINVAL */
-	if (shmctl(shm_id_1, IPC_STAT, &buf) != -1)
-		tst_brkm(TBROK, cleanup, "shmctl succeeded on expected fail");
+	struct shm_info dummy;
+	struct shmid_ds dummy_ds;
+	int max_idx, i;
 
-	if (errno != EINVAL)
-		tst_resm(TFAIL, "returned unexpected errno %d", errno);
-	else
-		tst_resm(TPASS, "shared memory appears to be removed");
+	max_idx = SAFE_SHMCTL(shm_id, SHM_INFO, (void*)&dummy);
 
-	shm_id_1 = -1;
-}
+	for (i = 0; i <= max_idx; i++) {
+		if (shmctl(i, SHM_STAT, &dummy_ds) == shm_id)
+			return i;
+	}
 
-/*
- * sighandler() - handle signals, in this case SIGUSR1 is the only one expected
- */
-void sighandler(int sig)
-{
-	if (sig != SIGUSR1)
-		tst_resm(TBROK, "received unexpected signal %d", sig);
+	return -1;
 }
 
-void setup(void)
+static void setup(void)
 {
-	tst_sig(FORK, sighandler, cleanup);
+	ctime_min = time(NULL);
+	shm_id = SAFE_SHMGET(IPC_PRIVATE, SHM_SIZE, IPC_CREAT | SHM_RW);
+	ctime_max = time(NULL);
+
+	shm_idx = get_shm_idx_from_id(shm_id);
 
-	TEST_PAUSE;
+	if (shm_idx < 0)
+		tst_brk(TBROK, "Failed to get shm_id to idx mapping");
 
-	tst_tmpdir();
+	tst_res(TINFO, "shm_id=%i maps to kernel index=%i", shm_id, shm_idx);
 
-	shmkey = getipckey();
+	SAFE_SIGNAL(SIGUSR1, dummy_sighandler);
 }
 
-void cleanup(void)
+static void cleanup(void)
 {
-	rm_shm(shm_id_1);
-
-	tst_rmdir();
+	if (shm_id >= 0)
+		SAFE_SHMCTL(shm_id, IPC_RMID, NULL);
 }
+
+static struct tst_test test = {
+	.setup = setup,
+	.cleanup = cleanup,
+	.forks_child = 1,
+	.test = verify_shmstat,
+	.tcnt = ARRAY_SIZE(tcases),
+};
Signature · 7 lines
Martin Doucha   [email protected]
QA Engineer for Software Maintenance
SUSE LINUX, s.r.o.
CORSO IIa
Krizikova 148/34
186 00 Prague 8
Czech Republic
#23 lore raw

cover Rewrite shmctl() testcases

In reply to Cyril Hrubis

Hi Cyril

Quoted 7 lines

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.

It seems that we miss shm_next_id. Also for msg_next_id, sem_next_id in ltp.

Quoted 28 lines

Cyril Hrubis (9):
syscalls/ipc: shmctl02: Convert to the new library syscalls/ipc: shmctl03: Remove. 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/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     | 214 +------
  .../kernel/syscalls/ipc/shmctl/shmctl04.c     | 190 +++---
  .../kernel/syscalls/ipc/shmctl/shmctl07.c     |  66 ++
  .../kernel/syscalls/ipc/shmctl/shmctl08.c     | 101 +++
  12 files changed, 593 insertions(+), 859 deletions(-)

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