Skip to contentSkip to conversation

syscalls/semop: Migrate to new test framework

PATCH Superseded Viresh Kumar 3 participants 13 messages Jul 29, 2020 – Sep 2, 2020

v8 of 9 Superseded Latest is v9 →

lore
Share & tools
lore
#0 lore raw

PATCH v8 1/5 syscalls/semop: Migrate to new test framework

This migrates the semop tests to the new test framework.

---
V8:
- 1/5 remains unchanged and I have added four new patches as suggested by Cyril.
- I have kept 2/5 separate to make it more reviewable, but you can merge it while applying if you want to.
- I was required to keep 3/5 and 4/5 separate as well to make review easier.

 testcases/kernel/syscalls/ipc/semop/Makefile  |   4 +-
 testcases/kernel/syscalls/ipc/semop/semop01.c | 140 +++++-------
 testcases/kernel/syscalls/ipc/semop/semop02.c | 145 +++++-------
 testcases/kernel/syscalls/ipc/semop/semop03.c | 150 +++++--------
 testcases/kernel/syscalls/ipc/semop/semop04.c | 165 +++++---------
 testcases/kernel/syscalls/ipc/semop/semop05.c | 303 +++++++++++---------------
 6 files changed, 348 insertions(+), 559 deletions(-)
testcases/kernel/syscalls/ipc/semop/Makefile +2 -2
index f62cd1f481d9..a11cbcf2e699 100644
@@ -3,10 +3,10 @@
 
 top_srcdir              ?= ../../../../..
 
-LTPLIBS = ltpipc
+LTPLIBS = ltpnewipc
 
 include $(top_srcdir)/include/mk/testcases.mk
 
-LDLIBS  += -lltpipc
+LDLIBS  += -lltpnewipc
 
 include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/syscalls/ipc/semop/semop01.c +57 -83

181 lines not on this page · raw message

testcases/kernel/syscalls/ipc/semop/semop02.c +53 -92

204 lines not on this page · raw message

testcases/kernel/syscalls/ipc/semop/semop03.c +50 -100

180 lines not on this page · raw message

testcases/kernel/syscalls/ipc/semop/semop04.c +54 -111

201 lines not on this page · raw message

testcases/kernel/syscalls/ipc/semop/semop05.c +132 -171

367 lines not on this page · raw message

Signature · 1 line
2.14.1
#1 lore raw

PATCH v8 2/5 syscalls: semop: Do code cleanup

This gets rid of not so useful stuff like unnecessary comments and uClinux support which isn't used anymore.

---
 testcases/kernel/syscalls/ipc/semop/semop01.c |  46 +----------
 testcases/kernel/syscalls/ipc/semop/semop02.c |  31 +++-----
 testcases/kernel/syscalls/ipc/semop/semop03.c |  49 +-----------
 testcases/kernel/syscalls/ipc/semop/semop04.c |  50 ++----------
 testcases/kernel/syscalls/ipc/semop/semop05.c | 105 ++------------------------
 5 files changed, 31 insertions(+), 250 deletions(-)
testcases/kernel/syscalls/ipc/semop/semop01.c +4 -42
index bcb45fa69320..19607ee6d653 100644
@@ -1,39 +1,10 @@
 // SPDX-License-Identifier: GPL-2.0-or-later
-/* Copyright (c) International Business Machines  Corp., 2001 */
-
 /*
- * NAME
- *	semop01.c
- *
- * DESCRIPTION
- *	semop01 - test that semop() basic functionality is correct
- *
- * ALGORITHM
- *	create a semaphore set and initialize some values
- *	loop if that option was specified
- *	call semop() to set values for the primitive semaphores
- *	check the return code
- *	  if failure, issue a FAIL message.
- *	otherwise,
- *	  if doing functionality testing
- *		get the semaphore values and compare with expected values
- *		if correct,
- *			issue a PASS message
- *		otherwise
- *			issue a FAIL message
- *	  else issue a PASS message
- *	call cleanup
+ * Test that semop() basic functionality is correct
  *
- * HISTORY
- *	03/2001  - Written by Wayne Boyer
+ * Copyright (c) International Business Machines Corp., 2001
+ *	03/2001 - Written by Wayne Boyer
  *	17/01/02 - Modified. Manoj Iyer, IBM Austin. TX. [email protected]
- *	           4th argument to semctl() system call was modified according
- *	           to man pages.
- *	           In my opinion The test should not even have compiled but
- *	           it was working due to some mysterious reason.
- *
- * RESTRICTIONS
- *	none
  */
 
 #include <stdlib.h>
@@ -57,14 +28,9 @@ static void run(void)
 	int i;
 
 	TEST(semop(sem_id, sops, NSEMS));
-
 	if (TST_RET == -1) {
 		tst_res(TFAIL | TTERRNO, "semop() failed");
 	} else {
-		/*
-		 * Get the values and make sure they are the same as what was
-		 * set
-		 */
 		if (semctl(sem_id, 0, GETALL, get_arr) == -1) {
 			tst_brk(TBROK | TERRNO, "semctl() failed in functional test");
 		}
@@ -80,13 +46,9 @@ static void run(void)
 			tst_res(TPASS, "semaphore values are correct");
 	}
 
-	/*
-	 * clean up things in case we are looping
-	 */
 	for (i = 0; i < NSEMS; i++) {
-		if (semctl(sem_id, i, SETVAL, arr) == -1) {
+		if (semctl(sem_id, i, SETVAL, arr) == -1)
 			tst_brk(TBROK | TERRNO, "semctl failed");
-		}
 	}
 }
 
testcases/kernel/syscalls/ipc/semop/semop02.c +10 -21
index f24d284776a4..66b0bef56257 100644
@@ -1,16 +1,10 @@
 // SPDX-License-Identifier: GPL-2.0-or-later
-/* Copyright (c) International Business Machines  Corp., 2001 */
-
 /*
- * DESCRIPTION
- *	semop02 - test for E2BIG, EACCES, EFAULT, EINVAL and ERANGE errors
+ * semop02 - test for E2BIG, EACCES, EFAULT, EINVAL and ERANGE errors
  *
- * HISTORY
+ * Copyright (c) International Business Machines  Corp., 2001
  *	03/2001 - Written by Wayne Boyer
- *
- *      10/03/2008 Renaud Lottiaux ([email protected])
- *      - Fix concurrency issue. The second key used for this test could
- *        conflict with the key from another task.
+ *	10/03/2008 Renaud Lottiaux ([email protected])
  */
 
 #define _GNU_SOURCE
@@ -27,21 +21,21 @@ static int bad_id = -1;
 static key_t semkey;
 static struct sembuf s_buf[PSEMS];
 
-#define NSOPS	5		/* a resonable number of operations */
+#define NSOPS	5		/* a reasonable number of operations */
 #define	BIGOPS	1024		/* a value that is too large for the number */
-				/* of semop operations that are permitted   */
+				/* of semop operations that are permitted */
 static struct test_case_t {
 	int *semid;
 	struct sembuf *t_sbuf;
 	unsigned t_ops;
 	int error;
 } tc[] = {
-	{&sem_id_1, (struct sembuf *)&s_buf, BIGOPS, E2BIG},
-	{&sem_id_2, (struct sembuf *)&s_buf, NSOPS, EACCES},
+	{&sem_id_1, s_buf, BIGOPS, E2BIG},
+	{&sem_id_2, s_buf, NSOPS, EACCES},
 	{&sem_id_1, (struct sembuf *)-1, NSOPS, EFAULT},
-	{&sem_id_1, (struct sembuf *)&s_buf, 0, EINVAL},
-	{&bad_id, (struct sembuf *)&s_buf, NSOPS, EINVAL},
-	{&sem_id_1, (struct sembuf *)&s_buf, 1, ERANGE}
+	{&sem_id_1, s_buf, 0, EINVAL},
+	{&bad_id, s_buf, NSOPS, EINVAL},
+	{&sem_id_1, s_buf, 1, ERANGE}
 };
 
 static void setup(void)
@@ -55,18 +49,14 @@ static void setup(void)
 	ltpuser = SAFE_GETPWNAM(nobody_uid);
 	SAFE_SETUID(ltpuser->pw_uid);
 
-	/* get an IPC resource key */
 	semkey = GETIPCKEY();
 
-	/* create a semaphore set with read and alter permissions */
 	sem_id_1 = semget(semkey, PSEMS, IPC_CREAT | IPC_EXCL | SEM_RA);
 	if (sem_id_1 == -1)
 		tst_brk(TBROK | TERRNO, "couldn't create semaphore in setup");
 
-	/* Get an new IPC resource key. */
 	semkey2 = GETIPCKEY();
 
-	/* create a semaphore set without read and alter permissions */
 	sem_id_2 = semget(semkey2, PSEMS, IPC_CREAT | IPC_EXCL);
 	if (sem_id_2 == -1)
 		tst_brk(TBROK | TERRNO, "couldn't create semaphore in setup");
@@ -75,7 +65,6 @@ static void setup(void)
 	if (semctl(sem_id_1, 0, IPC_INFO, arr) == -1)
 		tst_brk(TBROK | TERRNO, "semctl() IPC_INFO failed");
 
-	/* for ERANGE errno test */
 	arr.val = 1;
 	s_buf[0].sem_op = ipc_buf.semvmx;
 	if (semctl(sem_id_1, 0, SETVAL, arr) == -1)
testcases/kernel/syscalls/ipc/semop/semop03.c +4 -45

73 lines not on this page · raw message

testcases/kernel/syscalls/ipc/semop/semop04.c +5 -45

85 lines not on this page · raw message

testcases/kernel/syscalls/ipc/semop/semop05.c +8 -97

159 lines not on this page · raw message

Signature · 1 line
2.14.1
#2 lore raw

PATCH v8 3/5 syscalls: semop: Merge semop0[234].c files

In reply to Viresh Kumar

All these can be handled together in semop02.c easily.

---
 runtest/syscalls                               |  2 -
 runtest/syscalls-ipc                           |  2 -
 testcases/kernel/syscalls/ipc/semop/.gitignore |  2 -
 testcases/kernel/syscalls/ipc/semop/semop02.c  | 47 ++++++++++-----
 testcases/kernel/syscalls/ipc/semop/semop03.c  | 67 ---------------------
 testcases/kernel/syscalls/ipc/semop/semop04.c  | 80 --------------------------
 6 files changed, 34 insertions(+), 166 deletions(-)
 delete mode 100644 testcases/kernel/syscalls/ipc/semop/semop03.c
 delete mode 100644 testcases/kernel/syscalls/ipc/semop/semop04.c
runtest/syscalls +0 -2
index 70b3277d38ea..99831f6aa36e 100644
@@ -1169,8 +1169,6 @@ semget06 semget06
 
 semop01 semop01
 semop02 semop02
-semop03 semop03
-semop04 semop04
 semop05 semop05
 
 send01 send01
runtest/syscalls-ipc +0 -2
index c3a35896c5a8..1a63071b22cf 100644
@@ -44,8 +44,6 @@ semget06 semget06
 
 semop01 semop01
 semop02 semop02
-semop03 semop03
-semop04 semop04
 semop05 semop05
 
 shmat01 shmat01
testcases/kernel/syscalls/ipc/semop/.gitignore +0 -2
index cc67b1862f41..35b7af66c465 100644
@@ -1,5 +1,3 @@
 /semop01
 /semop02
-/semop03
-/semop04
 /semop05
testcases/kernel/syscalls/ipc/semop/semop02.c +34 -13

80 lines not on this page · raw message

testcases/kernel/syscalls/ipc/semop/semop03.c deleted +0 -67

67 lines not on this page · raw message

testcases/kernel/syscalls/ipc/semop/semop04.c deleted +0 -80

80 lines not on this page · raw message

Signature · 1 line
2.14.1
#3 lore raw

PATCH v8 4/5 syscalls: semop: Rename semop05.c

In reply to Viresh Kumar

Rename it to semop03.c.

---
 runtest/syscalls                                             | 2 +-
 runtest/syscalls-ipc                                         | 2 +-
 testcases/kernel/syscalls/ipc/semop/.gitignore               | 2 +-
 testcases/kernel/syscalls/ipc/semop/{semop05.c => semop03.c} | 0
 4 files changed, 3 insertions(+), 3 deletions(-)
 rename testcases/kernel/syscalls/ipc/semop/{semop05.c => semop03.c} (100%)
runtest/syscalls +1 -1
index 99831f6aa36e..7bbf3a76611f 100644
@@ -1169,7 +1169,7 @@ semget06 semget06
 
 semop01 semop01
 semop02 semop02
-semop05 semop05
+semop03 semop03
 
 send01 send01
 
runtest/syscalls-ipc +1 -1
index 1a63071b22cf..690ccb214b15 100644
@@ -44,7 +44,7 @@ semget06 semget06
 
 semop01 semop01
 semop02 semop02
-semop05 semop05
+semop03 semop03
 
 shmat01 shmat01
 shmat02 shmat02
testcases/kernel/syscalls/ipc/semop/.gitignore +1 -1
index 35b7af66c465..bb57f08afda8 100644
@@ -1,3 +1,3 @@
 /semop01
 /semop02
-/semop05
+/semop03
testcases/kernel/syscalls/ipc/semop/semop03.c renamed from testcases/kernel/syscalls/ipc/semop/semop05.c +0 -0
similarity index 100%
rename from testcases/kernel/syscalls/ipc/semop/semop05.c
rename to testcases/kernel/syscalls/ipc/semop/semop03.c
Signature · 1 line
2.14.1
#4 lore raw

PATCH v8 4/5 syscalls: semop: Rename semop05.c

Hi!
I've merget all these changes into a single patch and added bunch of cleanups on the top. My diff against your patchset follows. Thanks a lot for the cleanups.

testcases/kernel/syscalls/ipc/semop/semop01.c +20 -25
index 19607ee6d..2daf6bbc5 100644
@@ -13,12 +13,13 @@
 #include "libnewipc.h"
 #include "lapi/semun.h"
 
-#define NSEMS	4		/* the number of primitive semaphores to test */
+#define NSEMS 4
 
-static int sem_id = -1;		/* a semaphore set with read & alter permissions */
+static int sem_id = -1;
 static key_t semkey;
 
-static union semun get_arr;
+static unsigned short int sarr[PSEMS];
+static union semun get_arr = {.array = sarr};
 static struct sembuf sops[PSEMS];
 
 static void run(void)
@@ -30,25 +31,26 @@ static void run(void)
 	TEST(semop(sem_id, sops, NSEMS));
 	if (TST_RET == -1) {
 		tst_res(TFAIL | TTERRNO, "semop() failed");
-	} else {
-		if (semctl(sem_id, 0, GETALL, get_arr) == -1) {
-			tst_brk(TBROK | TERRNO, "semctl() failed in functional test");
-		}
+		return;
+	}
 
-		for (i = 0; i < NSEMS; i++) {
-			if (get_arr.array[i] != i * i) {
-				fail = 1;
-			}
+	if (semctl(sem_id, 0, GETALL, get_arr) == -1)
+		tst_brk(TBROK | TERRNO, "semctl(%i, 0, GETALL, ...)", sem_id);
+
+	for (i = 0; i < NSEMS; i++) {
+		if (get_arr.array[i] != i * i) {
+			fail = 1;
 		}
-		if (fail)
-			tst_res(TFAIL | TERRNO, "semaphore values are wrong");
-		else
-			tst_res(TPASS, "semaphore values are correct");
 	}
 
+	if (fail)
+		tst_res(TFAIL, "semaphore values are wrong");
+	else
+		tst_res(TPASS, "semaphore values are correct");
+
 	for (i = 0; i < NSEMS; i++) {
 		if (semctl(sem_id, i, SETVAL, arr) == -1)
-			tst_brk(TBROK | TERRNO, "semctl failed");
+			tst_brk(TBROK | TERRNO, "semctl(%i, %i, SETVAL, ...)", sem_id, i);
 	}
 }
 
@@ -56,10 +58,6 @@ static void setup(void)
 {
 	int i;
 
-	get_arr.array = malloc(sizeof(unsigned short int) * PSEMS);
-	if (get_arr.array == NULL)
-		tst_brk(TBROK, "malloc failed");
-
 	semkey = GETIPCKEY();
 
 	sem_id = semget(semkey, PSEMS, IPC_CREAT | IPC_EXCL | SEM_RA);
@@ -75,13 +73,10 @@ static void setup(void)
 
 static void cleanup(void)
 {
-	union semun arr;
-
 	if (sem_id != -1) {
-		if (semctl(sem_id, 0, IPC_RMID, arr) == -1)
-			tst_res(TINFO, "WARNING: semaphore deletion failed.");
+		if (semctl(sem_id, 0, IPC_RMID) == -1)
+			tst_res(TWARN, "semaphore deletion failed.");
 	}
-	free(get_arr.array);
 }
 
 static struct tst_test test = {
testcases/kernel/syscalls/ipc/semop/semop02.c +63 -54

177 lines not on this page · raw message

testcases/kernel/syscalls/ipc/semop/semop03.c +14 -44

105 lines not on this page · raw message

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

PATCH v8 5/5 syscalls/semtimedop: Add support for semtimedop and its time64 version

In reply to Viresh Kumar

This adds support for semtimedop() and its time64 variant to the existing semop() syscall tests.

---
 testcases/kernel/syscalls/ipc/semop/semop.h   | 55 +++++++++++++++++++++++++++
 testcases/kernel/syscalls/ipc/semop/semop01.c | 14 ++++++-
 testcases/kernel/syscalls/ipc/semop/semop02.c | 15 +++++++-
 testcases/kernel/syscalls/ipc/semop/semop03.c | 16 +++++++-
 4 files changed, 97 insertions(+), 3 deletions(-)
 create mode 100644 testcases/kernel/syscalls/ipc/semop/semop.h
testcases/kernel/syscalls/ipc/semop/semop.h new file +55 -0
new file mode 100644
index 000000000000..584d12c68e0d
@@ -0,0 +1,55 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#ifndef SEMOP_VAR__
+#define SEMOP_VAR__
+
+#include <sys/sem.h>
+#include "tst_timer.h"
+
+static inline int sys_semtimedop(int semid, struct sembuf *sops, size_t nsops,
+		void *timeout)
+{
+	return tst_syscall(__NR_semtimedop, semid, sops, nsops, timeout);
+}
+
+static inline int sys_semtimedop_time64(int semid, struct sembuf *sops,
+					size_t nsops, void *timeout)
+{
+	return tst_syscall(__NR_semtimedop_time64, semid, sops, nsops, timeout);
+}
+
+struct test_variants {
+	int (*semop)(int semid, struct sembuf *sops, size_t nsops);
+	int (*semtimedop)(int semid, struct sembuf *sops, size_t nsops, void *timeout);
+	enum tst_ts_type type;
+	char *desc;
+} variants[] = {
+	{ .semop = semop, .type = TST_LIBC_TIMESPEC, .desc = "semop: vDSO or syscall"},
+
+#if (__NR_semtimedop != __LTP__NR_INVALID_SYSCALL)
+	{ .semtimedop = sys_semtimedop, .type = TST_KERN_OLD_TIMESPEC, .desc = "semtimedop: syscall with old kernel spec"},
+#endif
+
+#if (__NR_semtimedop_time64 != __LTP__NR_INVALID_SYSCALL)
+	{ .semtimedop = sys_semtimedop_time64, .type = TST_KERN_TIMESPEC, .desc = "semtimedop: syscall time64 with kernel spec"},
+#endif
+};
+
+static inline int call_semop(struct test_variants *tv, int semid,
+		struct sembuf *sops, size_t nsops, struct tst_ts *timeout)
+{
+	if (tv->semop)
+		return tv->semop(semid, sops, nsops);
+
+	return tv->semtimedop(semid, sops, nsops, tst_ts_get(timeout));
+}
+
+static inline void semop_supported_by_kernel(struct test_variants *tv)
+{
+       /* Check if the syscall is implemented on the platform */
+       TEST(call_semop(tv, 0, NULL, 0, NULL));
+       if (TST_RET == -1 && TST_ERR == ENOSYS)
+               tst_brk(TCONF, "Test not supported on kernel/platform");
+}
+
+#endif /* SEMOP_VAR__ */
testcases/kernel/syscalls/ipc/semop/semop01.c +13 -1
index 19607ee6d653..c3443da58af4 100644
@@ -12,6 +12,7 @@
 #include "tst_test.h"
 #include "libnewipc.h"
 #include "lapi/semun.h"
+#include "semop.h"
 
 #define NSEMS	4		/* the number of primitive semaphores to test */
 
@@ -23,11 +24,17 @@ static struct sembuf sops[PSEMS];
 
 static void run(void)
 {
+	struct test_variants *tv = &variants[tst_variant];
 	union semun arr = { .val = 0 };
+	struct tst_ts timeout;
 	int fail = 0;
 	int i;
 
-	TEST(semop(sem_id, sops, NSEMS));
+	timeout.type = tv->type;
+	tst_ts_set_sec(&timeout, 1);
+	tst_ts_set_nsec(&timeout, 10000);
+
+	TEST(call_semop(tv, sem_id, sops, NSEMS, &timeout));
 	if (TST_RET == -1) {
 		tst_res(TFAIL | TTERRNO, "semop() failed");
 	} else {
@@ -54,8 +61,12 @@ static void run(void)
 
 static void setup(void)
 {
+	struct test_variants *tv = &variants[tst_variant];
 	int i;
 
+	tst_res(TINFO, "Testing variant: %s", tv->desc);
+	semop_supported_by_kernel(tv);
+
 	get_arr.array = malloc(sizeof(unsigned short int) * PSEMS);
 	if (get_arr.array == NULL)
 		tst_brk(TBROK, "malloc failed");
@@ -86,6 +97,7 @@ static void cleanup(void)
 
 static struct tst_test test = {
 	.test_all = run,
+	.test_variants = ARRAY_SIZE(variants),
 	.setup = setup,
 	.cleanup = cleanup,
 	.needs_tmpdir = 1,
testcases/kernel/syscalls/ipc/semop/semop02.c +14 -1
index 7a49b2648b2b..1b9b768f5e63 100644
@@ -14,6 +14,7 @@
 #include "tst_test.h"
 #include "libnewipc.h"
 #include "lapi/semun.h"
+#include "semop.h"
 
 static int sem_id_1 = -1;	/* a semaphore set with read & alter permissions */
 static int sem_id_2 = -1;	/* a semaphore set without read & alter permissions */
@@ -53,11 +54,15 @@ static struct test_case_t {
 
 static void setup(void)
 {
+	struct test_variants *tv = &variants[tst_variant];
 	char nobody_uid[] = "nobody";
 	struct passwd *ltpuser;
 	key_t semkey2;
 	struct seminfo ipc_buf;
 
+	tst_res(TINFO, "Testing variant: %s", tv->desc);
+	semop_supported_by_kernel(tv);
+
 	ltpuser = SAFE_GETPWNAM(nobody_uid);
 	SAFE_SETUID(ltpuser->pw_uid);
 
@@ -83,6 +88,13 @@ static void setup(void)
 
 static void run(unsigned int i)
 {
+	struct test_variants *tv = &variants[tst_variant];
+	struct tst_ts timeout;
+
+	timeout.type = tv->type;
+	tst_ts_set_sec(&timeout, 1);
+	tst_ts_set_nsec(&timeout, 10000);
+
 	if (*tc[i].buf != faulty_buf) {
 		arr.val = tc[i].arr_val;
 
@@ -94,7 +106,7 @@ static void run(unsigned int i)
 		s_buf[0].sem_num = tc[i].sem_num;
 	}
 
-	TEST(semop(*(tc[i].semid), *tc[i].buf, tc[i].t_ops));
+	TEST(call_semop(tv, *(tc[i].semid), *tc[i].buf, tc[i].t_ops, &timeout));
 
 	if (TST_RET != -1) {
 		tst_res(TFAIL | TTERRNO, "call succeeded unexpectedly");
@@ -127,6 +139,7 @@ static void cleanup(void)
 static struct tst_test test = {
 	.test = run,
 	.tcnt = ARRAY_SIZE(tc),
+	.test_variants = ARRAY_SIZE(variants),
 	.setup = setup,
 	.cleanup = cleanup,
 	.needs_tmpdir = 1,
testcases/kernel/syscalls/ipc/semop/semop03.c +15 -1
index df8ce7d16ee5..d0fea1ed1dd5 100644
@@ -15,6 +15,7 @@
 #include "tst_test.h"
 #include "libnewipc.h"
 #include "lapi/semun.h"
+#include "semop.h"
 
 static key_t semkey;
 static int sem_id = -1;
@@ -64,7 +65,14 @@ static inline int process_state_wait2(pid_t pid, const char state)
 
 static void do_child(int i)
 {
-	TEST(semop(sem_id, &s_buf, 1));
+	struct test_variants *tv = &variants[tst_variant];
+	struct tst_ts timeout;
+
+	timeout.type = tv->type;
+	tst_ts_set_sec(&timeout, 1);
+	tst_ts_set_nsec(&timeout, 10000);
+
+	TEST(call_semop(tv, sem_id, &s_buf, 1, &timeout));
 	if (TST_RET != -1) {
 		tst_res(TFAIL, "call succeeded when error expected");
 		exit(-1);
@@ -86,6 +94,11 @@ static void sighandler(int sig)
 
 static void setup(void)
 {
+	struct test_variants *tv = &variants[tst_variant];
+
+	tst_res(TINFO, "Testing variant: %s", tv->desc);
+	semop_supported_by_kernel(tv);
+
 	SAFE_SIGNAL(SIGHUP, sighandler);
 	semkey = GETIPCKEY();
 
@@ -149,6 +162,7 @@ static void run(unsigned int i)
 static struct tst_test test = {
 	.test = run,
 	.tcnt = ARRAY_SIZE(tc),
+	.test_variants = ARRAY_SIZE(variants),
 	.setup = setup,
 	.cleanup = cleanup,
 	.needs_tmpdir = 1,
Signature · 1 line
2.14.1
#6 lore raw

PATCH v8 5/5 syscalls/semtimedop: Add support for semtimedop and its time64 version

Hi!

Quoted 20 lines
testcases/kernel/syscalls/ipc/semop/semop.h new file +17 -0
@@ -0,0 +1,55 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#ifndef SEMOP_VAR__
+#define SEMOP_VAR__
+
+#include <sys/sem.h>
+#include "tst_timer.h"
+
+static inline int sys_semtimedop(int semid, struct sembuf *sops, size_t nsops,
+		void *timeout)
+{
+	return tst_syscall(__NR_semtimedop, semid, sops, nsops, timeout);
+}
+
+static inline int sys_semtimedop_time64(int semid, struct sembuf *sops,
+					size_t nsops, void *timeout)
+{

testcases/kernel/syscalls/ipc/semop/semop.h line 27

Quoted 10 lines
testcases/kernel/syscalls/ipc/semop/semop.h new file +10 -0
+	return tst_syscall(__NR_semtimedop_time64, semid, sops, nsops, timeout);
+}
+
+struct test_variants {
+	int (*semop)(int semid, struct sembuf *sops, size_t nsops);
+	int (*semtimedop)(int semid, struct sembuf *sops, size_t nsops, void *timeout);
+	enum tst_ts_type type;
+	char *desc;
+} variants[] = {
+	{ .semop = semop, .type = TST_LIBC_TIMESPEC, .desc = "semop: vDSO or syscall"},

I'm pretty sure semop will never be vDSO :-).

Quoted 43 lines
testcases/kernel/syscalls/ipc/semop/semop.h new file +27 -0
+#if (__NR_semtimedop != __LTP__NR_INVALID_SYSCALL)
+	{ .semtimedop = sys_semtimedop, .type = TST_KERN_OLD_TIMESPEC, .desc = "semtimedop: syscall with old kernel spec"},
+#endif
+
+#if (__NR_semtimedop_time64 != __LTP__NR_INVALID_SYSCALL)
+	{ .semtimedop = sys_semtimedop_time64, .type = TST_KERN_TIMESPEC, .desc = "semtimedop: syscall time64 with kernel spec"},
+#endif
+};
+
+static inline int call_semop(struct test_variants *tv, int semid,
+		struct sembuf *sops, size_t nsops, struct tst_ts *timeout)
+{
+	if (tv->semop)
+		return tv->semop(semid, sops, nsops);
+
+	return tv->semtimedop(semid, sops, nsops, tst_ts_get(timeout));
+}
+
+static inline void semop_supported_by_kernel(struct test_variants *tv)
+{
+       /* Check if the syscall is implemented on the platform */
+       TEST(call_semop(tv, 0, NULL, 0, NULL));
+       if (TST_RET == -1 && TST_ERR == ENOSYS)
+               tst_brk(TCONF, "Test not supported on kernel/platform");
+}
+
+#endif /* SEMOP_VAR__ */
testcases/kernel/syscalls/ipc/semop/semop01.c +1 -0
index 19607ee6d653..c3443da58af4 100644
@@ -12,6 +12,7 @@
 #include "tst_test.h"
 #include "libnewipc.h"
 #include "lapi/semun.h"
+#include "semop.h"
 
 #define NSEMS	4		/* the number of primitive semaphores to test */
 
@@ -23,11 +24,17 @@ static struct sembuf sops[PSEMS];
 
 static void run(void)
 {

testcases/kernel/syscalls/ipc/semop/semop01.c static struct sembuf sops[PSEMS]; · line 35

Quoted 10 lines
testcases/kernel/syscalls/ipc/semop/semop01.c +5 -1
+	struct test_variants *tv = &variants[tst_variant];
 	union semun arr = { .val = 0 };
+	struct tst_ts timeout;
 	int fail = 0;
 	int i;
 
-	TEST(semop(sem_id, sops, NSEMS));
+	timeout.type = tv->type;
+	tst_ts_set_sec(&timeout, 1);
+	tst_ts_set_nsec(&timeout, 10000);

Can't we just set the timeout once in the test setup?

Other than these we really lack semtimedop testcases that really utilize the timeout.

We need at least:

* Tests with NULL timeout

* A test that we get EAGAIN if semtimedop() timeouted either with:
- semop == 0 and non-zero semaphore
- semop < 0 and semaphore less than abs value of semop

* An EFAULT test for semtimedop() with bad address for timeout

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

PATCH v9 1/2 syscalls/semtimedop: Add support for semtimedop and its time64 version

This adds support for semtimedop() and its time64 variant to the existing semop() syscall tests.

---
V9:
- Removed vDSO from comment
- Add additional failure tests for EGAIN errors
- Moved timeout configuration change to setup()
- Test added for NULL timeout

 testcases/kernel/syscalls/ipc/semop/semop.h   | 55 +++++++++++++++++++
 testcases/kernel/syscalls/ipc/semop/semop01.c | 26 ++++++++-
 testcases/kernel/syscalls/ipc/semop/semop02.c | 42 ++++++++++----
 testcases/kernel/syscalls/ipc/semop/semop03.c | 15 ++++-
 4 files changed, 123 insertions(+), 15 deletions(-)
 create mode 100644 testcases/kernel/syscalls/ipc/semop/semop.h
testcases/kernel/syscalls/ipc/semop/semop.h new file +55 -0
new file mode 100644
index 000000000000..e920d3bc6d5f
@@ -0,0 +1,55 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#ifndef SEMOP_VAR__
+#define SEMOP_VAR__
+
+#include <sys/sem.h>
+#include "tst_timer.h"
+
+static inline int sys_semtimedop(int semid, struct sembuf *sops, size_t nsops,
+		void *timeout)
+{
+	return tst_syscall(__NR_semtimedop, semid, sops, nsops, timeout);
+}
+
+static inline int sys_semtimedop_time64(int semid, struct sembuf *sops,
+					size_t nsops, void *timeout)
+{
+	return tst_syscall(__NR_semtimedop_time64, semid, sops, nsops, timeout);
+}
+
+struct test_variants {
+	int (*semop)(int semid, struct sembuf *sops, size_t nsops);
+	int (*semtimedop)(int semid, struct sembuf *sops, size_t nsops, void *timeout);
+	enum tst_ts_type type;
+	char *desc;
+} variants[] = {
+	{ .semop = semop, .type = TST_LIBC_TIMESPEC, .desc = "semop: syscall"},
+
+#if (__NR_semtimedop != __LTP__NR_INVALID_SYSCALL)
+	{ .semtimedop = sys_semtimedop, .type = TST_KERN_OLD_TIMESPEC, .desc = "semtimedop: syscall with old kernel spec"},
+#endif
+
+#if (__NR_semtimedop_time64 != __LTP__NR_INVALID_SYSCALL)
+	{ .semtimedop = sys_semtimedop_time64, .type = TST_KERN_TIMESPEC, .desc = "semtimedop: syscall time64 with kernel spec"},
+#endif
+};
+
+static inline int call_semop(struct test_variants *tv, int semid,
+		struct sembuf *sops, size_t nsops, struct tst_ts *timeout)
+{
+	if (tv->semop)
+		return tv->semop(semid, sops, nsops);
+
+	return tv->semtimedop(semid, sops, nsops, tst_ts_get(timeout));
+}
+
+static inline void semop_supported_by_kernel(struct test_variants *tv)
+{
+       /* Check if the syscall is implemented on the platform */
+       TEST(call_semop(tv, 0, NULL, 0, NULL));
+       if (TST_RET == -1 && TST_ERR == ENOSYS)
+               tst_brk(TCONF, "Test not supported on kernel/platform");
+}
+
+#endif /* SEMOP_VAR__ */
testcases/kernel/syscalls/ipc/semop/semop01.c +23 -3
index 2daf6bbc5c4e..9e71a2744517 100644
@@ -12,6 +12,7 @@
 #include "tst_test.h"
 #include "libnewipc.h"
 #include "lapi/semun.h"
+#include "semop.h"
 
 #define NSEMS 4
 
@@ -21,14 +22,23 @@ static key_t semkey;
 static unsigned short int sarr[PSEMS];
 static union semun get_arr = {.array = sarr};
 static struct sembuf sops[PSEMS];
+static struct tst_ts timeout;
 
-static void run(void)
+static struct test_case_t {
+	struct tst_ts *to;
+} tc[] = {
+	{NULL},
+	{&timeout}
+};
+
+static void run(unsigned int n)
 {
+	struct test_variants *tv = &variants[tst_variant];
 	union semun arr = { .val = 0 };
 	int fail = 0;
 	int i;
 
-	TEST(semop(sem_id, sops, NSEMS));
+	TEST(call_semop(tv, sem_id, sops, NSEMS, tc[n].to));
 	if (TST_RET == -1) {
 		tst_res(TFAIL | TTERRNO, "semop() failed");
 		return;
@@ -56,8 +66,16 @@ static void run(void)
 
 static void setup(void)
 {
+	struct test_variants *tv = &variants[tst_variant];
 	int i;
 
+	tst_res(TINFO, "Testing variant: %s", tv->desc);
+	semop_supported_by_kernel(tv);
+
+	timeout.type = tv->type;
+	tst_ts_set_sec(&timeout, 1);
+	tst_ts_set_nsec(&timeout, 10000);
+
 	semkey = GETIPCKEY();
 
 	sem_id = semget(semkey, PSEMS, IPC_CREAT | IPC_EXCL | SEM_RA);
@@ -80,7 +98,9 @@ static void cleanup(void)
 }
 
 static struct tst_test test = {
-	.test_all = run,
+	.test = run,
+	.tcnt = ARRAY_SIZE(tc),
+	.test_variants = ARRAY_SIZE(variants),
 	.setup = setup,
 	.cleanup = cleanup,
 	.needs_tmpdir = 1,
testcases/kernel/syscalls/ipc/semop/semop02.c +31 -11

98 lines not on this page · raw message

testcases/kernel/syscalls/ipc/semop/semop03.c +14 -1
index 25123f08c239..dc776a090f48 100644
@@ -15,9 +15,11 @@
 #include "tst_test.h"
 #include "libnewipc.h"
 #include "lapi/semun.h"
+#include "semop.h"
 
 static key_t semkey;
 static int sem_id = -1;
+static struct tst_ts timeout;
 
 struct test_case_t {
 	union semun semunptr;
@@ -34,13 +36,14 @@ struct test_case_t {
 
 static void do_child(int i)
 {
+	struct test_variants *tv = &variants[tst_variant];
 	struct sembuf s_buf = {
 		.sem_op = tc[i].op,
 		.sem_flg = tc[i].flg,
 		.sem_num = tc[i].num,
 	};
 
-	TEST(semop(sem_id, &s_buf, 1));
+	TEST(call_semop(tv, sem_id, &s_buf, 1, &timeout));
 	if (TST_RET != -1) {
 		tst_res(TFAIL, "call succeeded when error expected");
 		exit(0);
@@ -62,6 +65,15 @@ static void sighandler(int sig)
 
 static void setup(void)
 {
+	struct test_variants *tv = &variants[tst_variant];
+
+	tst_res(TINFO, "Testing variant: %s", tv->desc);
+	semop_supported_by_kernel(tv);
+
+	timeout.type = tv->type;
+	tst_ts_set_sec(&timeout, 1);
+	tst_ts_set_nsec(&timeout, 10000);
+
 	SAFE_SIGNAL(SIGHUP, sighandler);
 	semkey = GETIPCKEY();
 
@@ -119,6 +131,7 @@ static void run(unsigned int i)
 static struct tst_test test = {
 	.test = run,
 	.tcnt = ARRAY_SIZE(tc),
+	.test_variants = ARRAY_SIZE(variants),
 	.setup = setup,
 	.cleanup = cleanup,
 	.needs_tmpdir = 1,
Signature · 1 line
2.25.0.rc1.19.g042ed3e048af
#8 lore raw

PATCH v9 1/2 syscalls/semtimedop: Add support for semtimedop and its time64 version

Quoted 10 lines · Viresh Kumar

This adds support for semtimedop() and its time64 variant to the existing semop() syscall tests.

---
V9:
- Removed vDSO from comment
- Add additional failure tests for EGAIN errors
- Moved timeout configuration change to setup()
- Test added for NULL timeout

Ping.

Signature · 1 line
viresh
#9 lore raw

PATCH v9 2/2 syscalls/semtimedop: Add failure test for invalid timeout pointer

In reply to Viresh Kumar

This adds test for invalid timeout pointer.

---
Cyril: This doesn't work as expected and results in the crash of the executable. I am not sure what's going on here though.

---
 testcases/kernel/syscalls/ipc/semop/semop02.c | 34 +++++++++++--------
 1 file changed, 20 insertions(+), 14 deletions(-)
testcases/kernel/syscalls/ipc/semop/semop02.c +20 -14
index d0fed5321502..bf362d1edcc9 100644
@@ -31,6 +31,7 @@ static int bad_sem_id = -1;
 static short sem_op_max, sem_op_1 = 1, sem_op_negative = -1, sem_op_zero = 0;
 static struct sembuf *faulty_buf;
 static struct tst_ts timeout;
+static struct tst_ts *valid_to = &timeout, *invalid_to;
 
 #define NSOPS	1
 #define	BIGOPS	1024
@@ -45,20 +46,22 @@ static struct test_case_t {
 	short sem_flg;
 	unsigned t_ops;
 	int arr_val;
+	struct tst_ts **to;
 	int error;
 } tc[] = {
-	{1, &valid_sem_id, NULL, &sem_op_1, 0, 0, 0, BIGOPS, 1, E2BIG},
-	{1, &noperm_sem_id, NULL, &sem_op_1, 0, 0, 0, NSOPS, 1, EACCES},
-	{1, &valid_sem_id, &faulty_buf, &sem_op_1, 0, 0, 0, NSOPS, 1, EFAULT},
-	{1, &valid_sem_id, NULL, &sem_op_1, 0, 0, 0, 0, 1, EINVAL},
-	{1, &bad_sem_id, NULL, &sem_op_1, 0, 0, 0, NSOPS, 1, EINVAL},
-	{1, &valid_sem_id, NULL, &sem_op_max, 0, 0, 0, 1, 1, ERANGE},
-	{1, &valid_sem_id, NULL, &sem_op_1, 0, -1, SEM_UNDO, 1, 1, EFBIG},
-	{1, &valid_sem_id, NULL, &sem_op_1, 0, PSEMS + 1, SEM_UNDO, 1, 1, EFBIG},
-	{1, &valid_sem_id, NULL, &sem_op_zero, 2, 2, IPC_NOWAIT, 1, 1, EAGAIN},
-	{1, &valid_sem_id, NULL, &sem_op_negative, 2, 2, IPC_NOWAIT, 1, 0, EAGAIN},
-	{0, &valid_sem_id, NULL, &sem_op_zero, 0, 0, SEM_UNDO, 1, 1, EAGAIN},
-	{0, &valid_sem_id, NULL, &sem_op_negative, 0, 0, SEM_UNDO, 1, 0, EAGAIN},
+	{1, &valid_sem_id, NULL, &sem_op_1, 0, 0, 0, BIGOPS, 1, &valid_to, E2BIG},
+	{1, &noperm_sem_id, NULL, &sem_op_1, 0, 0, 0, NSOPS, 1, &valid_to, EACCES},
+	{1, &valid_sem_id, &faulty_buf, &sem_op_1, 0, 0, 0, NSOPS, 1, &valid_to, EFAULT},
+	{1, &valid_sem_id, NULL, &sem_op_1, 0, 0, 0, 0, 1, &valid_to, EINVAL},
+	{1, &bad_sem_id, NULL, &sem_op_1, 0, 0, 0, NSOPS, 1, &valid_to, EINVAL},
+	{1, &valid_sem_id, NULL, &sem_op_max, 0, 0, 0, 1, 1, &valid_to, ERANGE},
+	{1, &valid_sem_id, NULL, &sem_op_1, 0, -1, SEM_UNDO, 1, 1, &valid_to, EFBIG},
+	{1, &valid_sem_id, NULL, &sem_op_1, 0, PSEMS + 1, SEM_UNDO, 1, 1, &valid_to, EFBIG},
+	{1, &valid_sem_id, NULL, &sem_op_zero, 2, 2, IPC_NOWAIT, 1, 1, &valid_to, EAGAIN},
+	{1, &valid_sem_id, NULL, &sem_op_negative, 2, 2, IPC_NOWAIT, 1, 0, &valid_to, EAGAIN},
+	{0, &valid_sem_id, NULL, &sem_op_zero, 0, 0, SEM_UNDO, 1, 1, &valid_to, EAGAIN},
+	{0, &valid_sem_id, NULL, &sem_op_negative, 0, 0, SEM_UNDO, 1, 0, &valid_to, EAGAIN},
+	{0, &valid_sem_id, NULL, &sem_op_zero, 0, 0, SEM_UNDO, 1, 1, &invalid_to, EFAULT},
 };
 
 static void setup(void)
@@ -68,6 +71,7 @@ static void setup(void)
 	key_t semkey;
 	union semun arr;
 	struct seminfo ipc_buf;
+	void *faulty_address;
 
 	tst_res(TINFO, "Testing variant: %s", tv->desc);
 	semop_supported_by_kernel(tv);
@@ -96,7 +100,9 @@ static void setup(void)
 		tst_brk(TBROK | TERRNO, "semctl() IPC_INFO failed");
 
 	sem_op_max = ipc_buf.semvmx;
-	faulty_buf = tst_get_bad_addr(NULL);
+	faulty_address = tst_get_bad_addr(NULL);
+	invalid_to = faulty_address;
+	faulty_buf = faulty_address;
 }
 
 static void run(unsigned int i)
@@ -123,7 +129,7 @@ static void run(unsigned int i)
 	if (tc[i].buf)
 		ptr = *tc[i].buf;
 
-	TEST(call_semop(tv, *(tc[i].semid), ptr, tc[i].t_ops, &timeout));
+	TEST(call_semop(tv, *(tc[i].semid), ptr, tc[i].t_ops, *tc[i].to));
 
 	if (TST_RET != -1) {
 		tst_res(TFAIL | TTERRNO, "call succeeded unexpectedly");
Signature · 1 line
2.25.0.rc1.19.g042ed3e048af
#10 lore raw

PATCH v9 2/2 syscalls/semtimedop: Add failure test for invalid timeout pointer

Hi Viresh,

Quoted 28 lines · Viresh Kumar

+ {1, &valid_sem_id, NULL, &sem_op_1, 0, 0, 0, BIGOPS, 1, &valid_to,
E2BIG},
+ {1, &noperm_sem_id, NULL, &sem_op_1, 0, 0, 0, NSOPS, 1, &valid_to,
EACCES},
+ {1, &valid_sem_id, &faulty_buf, &sem_op_1, 0, 0, 0, NSOPS, 1,
&valid_to, EFAULT},
+ {1, &valid_sem_id, NULL, &sem_op_1, 0, 0, 0, 0, 1, &valid_to,
EINVAL},
+ {1, &bad_sem_id, NULL, &sem_op_1, 0, 0, 0, NSOPS, 1, &valid_to,
EINVAL},
+ {1, &valid_sem_id, NULL, &sem_op_max, 0, 0, 0, 1, 1, &valid_to,
ERANGE},
+ {1, &valid_sem_id, NULL, &sem_op_1, 0, -1, SEM_UNDO, 1, 1,
&valid_to, EFBIG},
+ {1, &valid_sem_id, NULL, &sem_op_1, 0, PSEMS + 1, SEM_UNDO, 1, 1,
&valid_to, EFBIG},
+ {1, &valid_sem_id, NULL, &sem_op_zero, 2, 2, IPC_NOWAIT, 1, 1,
&valid_to, EAGAIN},
+ {1, &valid_sem_id, NULL, &sem_op_negative, 2, 2, IPC_NOWAIT, 1, 0,
&valid_to, EAGAIN},
+ {0, &valid_sem_id, NULL, &sem_op_zero, 0, 0, SEM_UNDO, 1, 1,
&valid_to, EAGAIN},
+ {0, &valid_sem_id, NULL, &sem_op_negative, 0, 0, SEM_UNDO, 1, 0,
&valid_to, EAGAIN},

Quoted 3 lines

+ {0, &valid_sem_id, NULL, &sem_op_zero, 0, 0, SEM_UNDO, 1, 1,
&invalid_to, EFAULT},

This '&invalid_to' can't be passed to the semtimedop(.., timeout) correctly, because in that wrapper function call_semop(), you invoke tst_ts_get(timeout)
to resolve an invalid address which will be caused a segmental fault eventually.

Apart from this, the rest code looks good to me.

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

PATCH v9 2/2 syscalls/semtimedop: Add failure test for invalid timeout pointer

Quoted 5 lines · Li Wang

This '&invalid_to' can't be passed to the semtimedop(.., timeout) correctly, because in that wrapper function call_semop(), you invoke tst_ts_get(timeout)
to resolve an invalid address which will be caused a segmental fault eventually.

Thanks a lot for figuring out the crash that I wasn't able to solve then :)

Signature · 1 line
viresh
#12 lore raw

PATCH v9 2/2 syscalls/semtimedop: Add failure test for invalid timeout pointer

In reply to Viresh Kumar

On Wed, Aug 19, 2020 at 8:28 PM Viresh Kumar <[email protected]> wrote:

- {1, &valid_sem_id, NULL, &sem_op_1, 0, 0, 0, BIGOPS, 1, E2BIG},

Quoted 36 lines
(quoted diff) +0 -2
-       {1, &noperm_sem_id, NULL, &sem_op_1, 0, 0, 0, NSOPS, 1, EACCES},
-       {1, &valid_sem_id, &faulty_buf, &sem_op_1, 0, 0, 0, NSOPS, 1,

EFAULT},

testcases/kernel/syscalls/ipc/semop/semop02.c +0 -5
-       {1, &valid_sem_id, NULL, &sem_op_1, 0, 0, 0, 0, 1, EINVAL},
-       {1, &bad_sem_id, NULL, &sem_op_1, 0, 0, 0, NSOPS, 1, EINVAL},
-       {1, &valid_sem_id, NULL, &sem_op_max, 0, 0, 0, 1, 1, ERANGE},
-       {1, &valid_sem_id, NULL, &sem_op_1, 0, -1, SEM_UNDO, 1, 1, EFBIG},
-       {1, &valid_sem_id, NULL, &sem_op_1, 0, PSEMS + 1, SEM_UNDO, 1, 1,

EFBIG},
- {1, &valid_sem_id, NULL, &sem_op_zero, 2, 2, IPC_NOWAIT, 1, 1,
EAGAIN},
- {1, &valid_sem_id, NULL, &sem_op_negative, 2, 2, IPC_NOWAIT, 1, 0,
EAGAIN},
- {0, &valid_sem_id, NULL, &sem_op_zero, 0, 0, SEM_UNDO, 1, 1,
EAGAIN},
- {0, &valid_sem_id, NULL, &sem_op_negative, 0, 0, SEM_UNDO, 1, 0,
EAGAIN},
+ {1, &valid_sem_id, NULL, &sem_op_1, 0, 0, 0, BIGOPS, 1, &valid_to,
E2BIG},
+ {1, &noperm_sem_id, NULL, &sem_op_1, 0, 0, 0, NSOPS, 1, &valid_to,
EACCES},
+ {1, &valid_sem_id, &faulty_buf, &sem_op_1, 0, 0, 0, NSOPS, 1,
&valid_to, EFAULT},
+ {1, &valid_sem_id, NULL, &sem_op_1, 0, 0, 0, 0, 1, &valid_to,
EINVAL},
+ {1, &bad_sem_id, NULL, &sem_op_1, 0, 0, 0, NSOPS, 1, &valid_to,
EINVAL},
+ {1, &valid_sem_id, NULL, &sem_op_max, 0, 0, 0, 1, 1, &valid_to,
ERANGE},
+ {1, &valid_sem_id, NULL, &sem_op_1, 0, -1, SEM_UNDO, 1, 1,
&valid_to, EFBIG},
+ {1, &valid_sem_id, NULL, &sem_op_1, 0, PSEMS + 1, SEM_UNDO, 1, 1,
&valid_to, EFBIG},
+ {1, &valid_sem_id, NULL, &sem_op_zero, 2, 2, IPC_NOWAIT, 1, 1,
&valid_to, EAGAIN},
+ {1, &valid_sem_id, NULL, &sem_op_negative, 2, 2, IPC_NOWAIT, 1, 0,

Quoted 9 lines

&valid_to, EAGAIN},
+ {0, &valid_sem_id, NULL, &sem_op_zero, 0, 0, SEM_UNDO, 1, 1,
&valid_to, EAGAIN},
+ {0, &valid_sem_id, NULL, &sem_op_negative, 0, 0, SEM_UNDO, 1, 0,
&valid_to, EAGAIN},
+ {0, &valid_sem_id, NULL, &sem_op_zero, 0, 0, SEM_UNDO, 1, 1,
&invalid_to, EFAULT},
};

And btw, these new changes should also be updated in the code comments above the head.

Signature · 5 lines
Regards,
Li Wang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20200902/9c2f9f37/attachment.htm>