All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH 1/7] getitimer02: Skipped EFAULT tests for libc variant.
@ 2021-06-07 10:45 Vinay Kumar
  2021-06-07 10:45 ` [LTP] [PATCH 2/7] getrusage02: " Vinay Kumar
                   ` (6 more replies)
  0 siblings, 7 replies; 45+ messages in thread
From: Vinay Kumar @ 2021-06-07 10:45 UTC (permalink / raw)
  To: ltp

Tested EFAULT cases only for "__NR_getitimer" syscall.

Signed-off-by: Vinay Kumar <vinay.m.engg@gmail.com>
---
 .../kernel/syscalls/getitimer/getitimer02.c   | 54 +++++++++++++++----
 1 file changed, 45 insertions(+), 9 deletions(-)

diff --git a/testcases/kernel/syscalls/getitimer/getitimer02.c b/testcases/kernel/syscalls/getitimer/getitimer02.c
index b9c03143a..356453d4d 100644
--- a/testcases/kernel/syscalls/getitimer/getitimer02.c
+++ b/testcases/kernel/syscalls/getitimer/getitimer02.c
@@ -30,6 +30,7 @@
 
 #include <errno.h>
 #include <sys/time.h>
+#include "lapi/syscalls.h"
 
 char *TCID = "getitimer02";
 int TST_TOTAL = 1;
@@ -39,9 +40,35 @@ int TST_TOTAL = 1;
 static void cleanup(void);
 static void setup(void);
 
+static int libc_getitimer(int which, void *curr_value)
+{
+	return getitimer(which, curr_value);
+}
+
+static int sys_getitimer(int which, void *curr_value)
+{
+	return ltp_syscall(__NR_getitimer, which, curr_value);
+}
+
+static struct test_variants
+{
+	int (*getitimer)(int which, void *curr_value);
+	char *desc;
+} variants[] = {
+	{ .getitimer = libc_getitimer, .desc = "libc getitimer()"},
+
+#if (__NR_getitimer != __LTP__NR_INVALID_SYSCALL)
+	{ .getitimer = sys_getitimer,  .desc = "__NR_getitimer syscall"},
+#endif
+};
+
+unsigned int tst_variant_t;
+int TST_VARIANTS = ARRAY_SIZE(variants);
+
 int main(int ac, char **av)
 {
-	int lc;
+	int lc, i;
+	struct test_variants *tv = &variants[tst_variant_t];
 
 	tst_parse_opts(ac, av, NULL, NULL);
 
@@ -50,16 +77,25 @@ int main(int ac, char **av)
 	for (lc = 0; TEST_LOOPING(lc); lc++) {
 		tst_count = 0;
 
-		/* call with a bad address */
-		TEST(getitimer(ITIMER_REAL, (struct itimerval *)-1));
+		for (i = 0; i < TST_VARIANTS; i++) {
+			tst_resm(TINFO, "Testing variant: %s", tv->desc);
 
-		if (TEST_RETURN == 0) {
-			tst_resm(TFAIL, "call failed to produce "
-				 "expected error - errno = %d - %s",
-				 TEST_ERRNO, strerror(TEST_ERRNO));
-			continue;
-		}
+			/* call with a bad address */
+			if (tv->getitimer == libc_getitimer) {
+				tst_resm(TCONF, "EFAULT skipped for libc variant");
+				tv++;
+				continue;
+			}
 
+		TEST(tv->getitimer(ITIMER_REAL, (struct itimerval *)-1));
+
+			if (TEST_RETURN == 0) {
+				tst_resm(TFAIL, "call failed to produce "
+					 "expected error - errno = %d - %s",
+					TEST_ERRNO, strerror(TEST_ERRNO));
+				continue;
+			}
+		}
 		switch (TEST_ERRNO) {
 		case EFAULT:
 			tst_resm(TPASS, "expected failure - errno = %d - %s",
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 45+ messages in thread

* [LTP] [PATCH 2/7] getrusage02: Skipped EFAULT tests for libc variant.
  2021-06-07 10:45 [LTP] [PATCH 1/7] getitimer02: Skipped EFAULT tests for libc variant Vinay Kumar
@ 2021-06-07 10:45 ` Vinay Kumar
  2021-06-07 10:45 ` [LTP] [PATCH 3/7] msgctl04: " Vinay Kumar
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 45+ messages in thread
From: Vinay Kumar @ 2021-06-07 10:45 UTC (permalink / raw)
  To: ltp

Tested EFAULT cases only for "__NR_getrusage" syscall.

Signed-off-by: Vinay Kumar <vinay.m.engg@gmail.com>
---
 .../kernel/syscalls/getrusage/getrusage02.c   | 53 ++++++++++++++++---
 1 file changed, 45 insertions(+), 8 deletions(-)

diff --git a/testcases/kernel/syscalls/getrusage/getrusage02.c b/testcases/kernel/syscalls/getrusage/getrusage02.c
index 8077606a2..00c1af805 100644
--- a/testcases/kernel/syscalls/getrusage/getrusage02.c
+++ b/testcases/kernel/syscalls/getrusage/getrusage02.c
@@ -71,6 +71,7 @@
 #include <sched.h>
 #include <sys/resource.h>
 #include "test.h"
+#include "lapi/syscalls.h"
 
 #ifndef RUSAGE_BOTH		/* Removed from user space on RHEL4 */
 #define RUSAGE_BOTH (-2)	/* still works on SuSE      */
@@ -83,6 +84,16 @@ char *TCID = "getrusage02";
 
 static struct rusage usage;
 
+static int libc_getrusage(int who, void *usage)
+{
+	return getrusage(who, usage);
+}
+
+static int sys_getrusage(int who, void *usage)
+{
+	return ltp_syscall(__NR_getrusage, who, usage);
+}
+
 struct test_cases_t {
 	int who;
 	struct rusage *usage;
@@ -96,12 +107,26 @@ struct test_cases_t {
 #endif
 };
 
+static struct test_variants
+{
+	int (*getrusage)(int who, void *usage);
+	char *desc;
+} variants[] = {
+	{ .getrusage = libc_getrusage, .desc = "libc getrusage()"},
+
+#if (__NR_getrusage != __LTP__NR_INVALID_SYSCALL)
+	{ .getrusage = sys_getrusage,  .desc = "__NR_getrusage syscall"},
+#endif
+};
+
+unsigned int tst_variant_t;
+int TST_VARIANTS = ARRAY_SIZE(variants);
 int TST_TOTAL = ARRAY_SIZE(test_cases);
 
 int main(int ac, char **av)
 {
-
-	int lc, i;
+	struct test_variants *tv = &variants[tst_variant_t];
+	int lc, i, j;
 
 	tst_parse_opts(ac, av, NULL, NULL);
 
@@ -111,18 +136,30 @@ int main(int ac, char **av)
 
 		tst_count = 0;
 
-		for (i = 0; i < TST_TOTAL; i++) {
-			TEST(getrusage(test_cases[i].who, test_cases[i].usage));
+		for (j = 0; j < TST_VARIANTS; j++) {
+
+			tst_resm(TINFO, "Testing variant: %s", tv->desc);
+			for (i = 0; i < TST_TOTAL; i++) {
+
+				if (test_cases[i].exp_errno == EFAULT &&
+					tv->getrusage == libc_getrusage) {
+					tst_resm(TCONF, "EFAULT is skipped for libc variant");
+					tv++;
+					continue;
+				}
+
+			TEST(tv->getrusage(test_cases[i].who, test_cases[i].usage));
 
 			if (TEST_RETURN == -1 &&
-			    TEST_ERRNO == test_cases[i].exp_errno)
+				TEST_ERRNO == test_cases[i].exp_errno)
 				tst_resm(TPASS | TTERRNO,
-					 "getrusage failed as expected");
+				"getrusage failed as expected");
 			else
 				tst_resm(TFAIL | TTERRNO,
-					 "getrusage failed unexpectedly");
+				"getrusage failed unexpectedly");
+				}
+			}
 		}
-	}
 
 	cleanup();
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 45+ messages in thread

* [LTP] [PATCH 3/7] msgctl04: Skipped EFAULT tests for libc variant.
  2021-06-07 10:45 [LTP] [PATCH 1/7] getitimer02: Skipped EFAULT tests for libc variant Vinay Kumar
  2021-06-07 10:45 ` [LTP] [PATCH 2/7] getrusage02: " Vinay Kumar
@ 2021-06-07 10:45 ` Vinay Kumar
  2021-06-07 10:45 ` [LTP] [PATCH 4/7] semctl03: " Vinay Kumar
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 45+ messages in thread
From: Vinay Kumar @ 2021-06-07 10:45 UTC (permalink / raw)
  To: ltp

Tested EFAULT cases only for "__NR_msgctl" syscall.

Signed-off-by: Vinay Kumar <vinay.m.engg@gmail.com>
---
 .../kernel/syscalls/ipc/msgctl/msgctl04.c     | 38 ++++++++++++++++++-
 1 file changed, 37 insertions(+), 1 deletion(-)

diff --git a/testcases/kernel/syscalls/ipc/msgctl/msgctl04.c b/testcases/kernel/syscalls/ipc/msgctl/msgctl04.c
index 900b22244..3d0c7f896 100644
--- a/testcases/kernel/syscalls/ipc/msgctl/msgctl04.c
+++ b/testcases/kernel/syscalls/ipc/msgctl/msgctl04.c
@@ -15,6 +15,7 @@
 #include "tst_test.h"
 #include "tst_safe_sysv_ipc.h"
 #include "libnewipc.h"
+#include "lapi/syscalls.h"
 
 static int msg_id1 = -1;
 static int msg_id2 = -1;
@@ -23,6 +24,16 @@ static int bad_q = -1;
 
 struct msqid_ds q_buf;
 
+static int libc_msgctl(int msqid, int cmd, void *buf)
+{
+	return msgctl(msqid, cmd, buf);
+}
+
+static int sys_msgctl(int msqid, int cmd, void *buf)
+{
+	return tst_syscall(__NR_msgctl, msqid, cmd, buf);
+}
+
 struct tcase {
 	int *msg_id;
 	int cmd;
@@ -45,9 +56,29 @@ struct tcase {
 	{&msg_id3, IPC_RMID, NULL, EPERM},
 };
 
+static struct test_variants
+{
+	int (*msgctl)(int msqid, int cmd, void *buf);
+	char *desc;
+} variants[] = {
+	{ .msgctl = libc_msgctl, .desc = "libc msgctl()"},
+
+#if (__NR_msgctl != __LTP__NR_INVALID_SYSCALL)
+	{ .msgctl = sys_msgctl,  .desc = "__NR_msgctl syscall"},
+#endif
+};
+
 static void verify_msgctl(unsigned int i)
 {
-	TEST(msgctl(*(tc[i].msg_id), tc[i].cmd, tc[i].buf));
+	struct test_variants *tv = &variants[tst_variant];
+
+	if (tc[i].error == EFAULT &&
+		tv->msgctl == libc_msgctl) {
+		tst_res(TCONF, "EFAULT is skipped for libc variant");
+		return;
+	}
+
+	TEST(tv->msgctl(*(tc[i].msg_id), tc[i].cmd, tc[i].buf));
 
 	if (TST_RET != -1) {
 		tst_res(TFAIL, "msgctl() returned %li", TST_RET);
@@ -66,6 +97,8 @@ static void verify_msgctl(unsigned int i)
 
 static void setup(void)
 {
+	struct test_variants *tv = &variants[tst_variant];
+
 	key_t msgkey1, msgkey2;
 	struct passwd *ltpuser;
 
@@ -79,6 +112,8 @@ static void setup(void)
 
 	msg_id1 = SAFE_MSGGET(msgkey1, IPC_CREAT | IPC_EXCL);
 	msg_id2 = SAFE_MSGGET(msgkey2, IPC_CREAT | IPC_EXCL | MSG_RD | MSG_WR);
+
+	tst_res(TINFO, "Testing variant: %s", tv->desc);
 }
 
 static void cleanup(void)
@@ -100,6 +135,7 @@ static struct tst_test test = {
 	.cleanup = cleanup,
 	.test = verify_msgctl,
 	.tcnt = ARRAY_SIZE(tc),
+	.test_variants = ARRAY_SIZE(variants),
 	.needs_tmpdir = 1,
 	.needs_root = 1,
 };
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 45+ messages in thread

* [LTP] [PATCH 4/7] semctl03: Skipped EFAULT tests for libc variant.
  2021-06-07 10:45 [LTP] [PATCH 1/7] getitimer02: Skipped EFAULT tests for libc variant Vinay Kumar
  2021-06-07 10:45 ` [LTP] [PATCH 2/7] getrusage02: " Vinay Kumar
  2021-06-07 10:45 ` [LTP] [PATCH 3/7] msgctl04: " Vinay Kumar
@ 2021-06-07 10:45 ` Vinay Kumar
  2021-06-07 10:45 ` [LTP] [PATCH 5/7] shmctl02: " Vinay Kumar
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 45+ messages in thread
From: Vinay Kumar @ 2021-06-07 10:45 UTC (permalink / raw)
  To: ltp

Tested EFAULT cases only for "__NR_semctl" syscall.

Signed-off-by: Vinay Kumar <vinay.m.engg@gmail.com>
---
 .../kernel/syscalls/ipc/semctl/semctl03.c     | 39 ++++++++++++++++++-
 1 file changed, 37 insertions(+), 2 deletions(-)

diff --git a/testcases/kernel/syscalls/ipc/semctl/semctl03.c b/testcases/kernel/syscalls/ipc/semctl/semctl03.c
index ed2a46b16..44030ae47 100644
--- a/testcases/kernel/syscalls/ipc/semctl/semctl03.c
+++ b/testcases/kernel/syscalls/ipc/semctl/semctl03.c
@@ -15,6 +15,7 @@
 #include "tst_test.h"
 #include "lapi/sem.h"
 #include "libnewipc.h"
+#include "lapi/syscalls.h"
 
 static int sem_id = -1;
 static int bad_id = -1;
@@ -23,6 +24,17 @@ static struct semid_ds sem_ds;
 static union semun sem_un = {.buf = &sem_ds};
 static void *semds_ptr = &sem_un;
 static void *bad_ptr;
+static union semun arg = {0};
+
+static int libc_semctl(int semid, int semnum, int cmd, ...)
+{
+	return semctl(semid, semnum, cmd, arg);
+}
+
+static int sys_semctl(int semid, int semnum, int cmd, ...)
+{
+	return tst_syscall(__NR_semctl, semid, semnum, cmd, arg);
+}
 
 static struct tcases {
 	int *sem_id;
@@ -37,17 +49,39 @@ static struct tcases {
 	{&sem_id, IPC_SET, &bad_ptr, EFAULT, "invalid union arg"}
 };
 
+static struct test_variants
+{
+	int (*semctl)(int semid, int semnum, int cmd, ...);
+	char *desc;
+} variants[] = {
+	{ .semctl = libc_semctl, .desc = "libc semctl()"},
+
+#if (__NR_sys_semctl != __LTP__NR_INVALID_SYSCALL)
+	{ .semctl = sys_semctl,  .desc = "__NR_semctl syscall"},
+#endif
+};
+
 static void verify_semctl(unsigned int n)
 {
 	struct tcases *tc = &tests[n];
+	struct test_variants *tv = &variants[tst_variant];
+
+	if (tc->error == EFAULT
+		&& tv->semctl == libc_semctl) {
+		tst_res(TCONF, "EFAULT is skipped for libc variant");
+		return;
+	}
 
-	TST_EXP_FAIL(semctl(*(tc->sem_id), 0, tc->ipc_cmd, *(tc->buf)),
-		     tc->error, "semctl() with %s", tc->message);
+	TST_EXP_FAIL(sys_semctl(*(tc->sem_id), 0, tc->ipc_cmd, *(tc->buf)),
+		tc->error, "semctl() with %s", tc->message);
 }
 
 static void setup(void)
 {
 	static key_t semkey;
+	struct test_variants *tv = &variants[tst_variant];
+
+	tst_res(TINFO, "Testing variant: %s", tv->desc);
 
 	semkey = GETIPCKEY();
 
@@ -67,4 +101,5 @@ static struct tst_test test = {
 	.cleanup = cleanup,
 	.test = verify_semctl,
 	.tcnt = ARRAY_SIZE(tests),
+	.test_variants = ARRAY_SIZE(variants),
 };
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 45+ messages in thread

* [LTP] [PATCH 5/7] shmctl02: Skipped EFAULT tests for libc variant.
  2021-06-07 10:45 [LTP] [PATCH 1/7] getitimer02: Skipped EFAULT tests for libc variant Vinay Kumar
                   ` (2 preceding siblings ...)
  2021-06-07 10:45 ` [LTP] [PATCH 4/7] semctl03: " Vinay Kumar
@ 2021-06-07 10:45 ` Vinay Kumar
  2021-06-07 10:45 ` [LTP] [PATCH 6/7] sched_rr_get_interval03: " Vinay Kumar
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 45+ messages in thread
From: Vinay Kumar @ 2021-06-07 10:45 UTC (permalink / raw)
  To: ltp

Tested EFAULT cases only for "__NR_shmctl"

Signed-off-by: Vinay Kumar <vinay.m.engg@gmail.com>
---
 .../kernel/syscalls/ipc/shmctl/shmctl02.c     | 40 ++++++++++++++++++-
 1 file changed, 38 insertions(+), 2 deletions(-)

diff --git a/testcases/kernel/syscalls/ipc/shmctl/shmctl02.c b/testcases/kernel/syscalls/ipc/shmctl/shmctl02.c
index 9057b7f54..b9a71722d 100644
--- a/testcases/kernel/syscalls/ipc/shmctl/shmctl02.c
+++ b/testcases/kernel/syscalls/ipc/shmctl/shmctl02.c
@@ -32,6 +32,7 @@
 #include "tst_test.h"
 #include "tst_safe_sysv_ipc.h"
 #include "libnewipc.h"
+#include "lapi/syscalls.h"
 
 #define SHM_SIZE 2048
 
@@ -43,6 +44,16 @@ static int shm_rem;
 
 static struct shmid_ds buf;
 
+static int libc_shmctl(int shmid, int cmd, void *buf)
+{
+	return shmctl(shmid, cmd, buf);
+}
+
+static int sys_shmctl(int shmid, int cmd, void *buf)
+{
+	return tst_syscall(__NR_shmctl, shmid, cmd, buf);
+}
+
 static struct tcase {
 	int *shm_id;
 	int cmd;
@@ -63,9 +74,29 @@ static struct tcase {
 	{&shm_id3, SHM_UNLOCK, &buf, EPERM}
 };
 
+static struct test_variants
+{
+	int (*shmctl)(int shmid, int cmd, void *buf);
+	char *desc;
+} variants[] = {
+	{ .shmctl = libc_shmctl, .desc = "libc shmctl()"},
+
+#if (__NR_shmctl != __LTP__NR_INVALID_SYSCALL)
+	{ .shmctl = sys_shmctl,  .desc = "__NR_shmctl syscall"},
+#endif
+};
+
 static void verify_shmctl(unsigned int i)
 {
-	TEST(shmctl(*(tc[i].shm_id), tc[i].cmd, tc[i].buf));
+	struct test_variants *tv = &variants[tst_variant];
+
+	if (tc[i].error == EFAULT
+		&& tv->shmctl == libc_shmctl) {
+		tst_res(TCONF, "EFAULT is skipped for libc variant");
+		return;
+	}
+
+	TEST(tv->shmctl(*(tc[i].shm_id), tc[i].cmd, tc[i].buf));
 
 	if (TST_RET != -1) {
 		tst_res(TFAIL, "shmctl() returned %li", TST_RET);
@@ -74,7 +105,7 @@ static void verify_shmctl(unsigned int i)
 
 	if (TST_ERR == tc[i].error) {
 		tst_res(TPASS | TTERRNO, "shmctl(%i, %i, %p)",
-		        *tc[i].shm_id, tc[i].cmd, tc[i].buf);
+				*tc[i].shm_id, tc[i].cmd, tc[i].buf);
 		return;
 	}
 
@@ -84,10 +115,14 @@ static void verify_shmctl(unsigned int i)
 
 static void setup(void)
 {
+	struct test_variants *tv = &variants[tst_variant];
+
 	key_t shmkey1, shmkey2;
 	struct passwd *ltpuser;
 	int tmp;
 
+	tst_res(TINFO, "Testing variant: %s", tv->desc);
+
 	shm_id3 = SAFE_SHMGET(IPC_PRIVATE, SHM_SIZE, IPC_CREAT | SHM_RW);
 
 	ltpuser = SAFE_GETPWNAM("nobody");
@@ -121,6 +156,7 @@ static struct tst_test test = {
 	.setup = setup,
 	.cleanup = cleanup,
 	.test = verify_shmctl,
+	.test_variants = ARRAY_SIZE(variants),
 	.tcnt = ARRAY_SIZE(tc),
 	.needs_root = 1,
 };
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 45+ messages in thread

* [LTP] [PATCH 6/7] sched_rr_get_interval03: Skipped EFAULT tests for libc variant.
  2021-06-07 10:45 [LTP] [PATCH 1/7] getitimer02: Skipped EFAULT tests for libc variant Vinay Kumar
                   ` (3 preceding siblings ...)
  2021-06-07 10:45 ` [LTP] [PATCH 5/7] shmctl02: " Vinay Kumar
@ 2021-06-07 10:45 ` Vinay Kumar
  2021-06-07 10:45 ` [LTP] [PATCH 7/7] setitimer02: " Vinay Kumar
  2021-06-08 20:43 ` [LTP] [PATCH 1/7] getitimer02: " Petr Vorel
  6 siblings, 0 replies; 45+ messages in thread
From: Vinay Kumar @ 2021-06-07 10:45 UTC (permalink / raw)
  To: ltp

Tested EFAULT cases only for "__NR_sched_rr_get_interval" and "__NR_sched_rr_get_interval_time64"

Signed-off-by: Vinay Kumar <vinay.m.engg@gmail.com>
---
 .../sched_rr_get_interval/sched_rr_get_interval03.c         | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/testcases/kernel/syscalls/sched_rr_get_interval/sched_rr_get_interval03.c b/testcases/kernel/syscalls/sched_rr_get_interval/sched_rr_get_interval03.c
index 0c9887f36..cee9245e6 100644
--- a/testcases/kernel/syscalls/sched_rr_get_interval/sched_rr_get_interval03.c
+++ b/testcases/kernel/syscalls/sched_rr_get_interval/sched_rr_get_interval03.c
@@ -67,6 +67,12 @@ static void run(unsigned int i)
 	struct test_cases_t *tc = &test_cases[i];
 	struct timerspec *ts;
 
+	if (tc->exp_errno == EFAULT
+		&& tv->sched_rr_get_interval == libc_sched_rr_get_interval) {
+		tst_res(TCONF, "EFAULT skipped for libc_variant");
+		return;
+	}
+
 	if (tc->exp_errno == EFAULT)
 		ts = bad_addr;
 	else
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 45+ messages in thread

* [LTP] [PATCH 7/7] setitimer02: Skipped EFAULT tests for libc variant.
  2021-06-07 10:45 [LTP] [PATCH 1/7] getitimer02: Skipped EFAULT tests for libc variant Vinay Kumar
                   ` (4 preceding siblings ...)
  2021-06-07 10:45 ` [LTP] [PATCH 6/7] sched_rr_get_interval03: " Vinay Kumar
@ 2021-06-07 10:45 ` Vinay Kumar
  2021-06-08 20:43 ` [LTP] [PATCH 1/7] getitimer02: " Petr Vorel
  6 siblings, 0 replies; 45+ messages in thread
From: Vinay Kumar @ 2021-06-07 10:45 UTC (permalink / raw)
  To: ltp

Tested EFAULT cases only for "__NR_setitimer"

Signed-off-by: Vinay Kumar <vinay.m.engg@gmail.com>
---
 .../kernel/syscalls/setitimer/setitimer02.c   | 82 +++++++++++++------
 1 file changed, 59 insertions(+), 23 deletions(-)

diff --git a/testcases/kernel/syscalls/setitimer/setitimer02.c b/testcases/kernel/syscalls/setitimer/setitimer02.c
index 4d13cd1e0..ee0748884 100644
--- a/testcases/kernel/syscalls/setitimer/setitimer02.c
+++ b/testcases/kernel/syscalls/setitimer/setitimer02.c
@@ -56,6 +56,7 @@
 
 #include <errno.h>
 #include <sys/time.h>
+#include "lapi/syscalls.h"
 
 void cleanup(void);
 void setup(void);
@@ -63,12 +64,38 @@ void setup(void);
 char *TCID = "setitimer02";
 int TST_TOTAL = 1;
 
+static int libc_setitimer(int which, void *new_value, void *old_value)
+{
+	return setitimer(which, new_value, old_value);
+}
+
+static int sys_setitimer(int which, void *new_value, void *old_value)
+{
+	return ltp_syscall(__NR_setitimer, which, new_value, old_value);
+}
+
+static struct test_variants
+{
+	int (*setitimer)(int which, void *new_value, void *old_value);
+	char *desc;
+} variants[] = {
+	{ .setitimer = libc_setitimer, .desc = "libc setitimer()"},
+
+#if (__NR_setitimer != __LTP__NR_INVALID_SYSCALL)
+	{ .setitimer = sys_setitimer,  .desc = "__NR_setitimer syscall"},
+#endif
+};
+
+unsigned int tst_variant_t;
+int TST_VARIANTS = ARRAY_SIZE(variants);
+
 #if !defined(UCLINUX)
 
 int main(int ac, char **av)
 {
-	int lc;
+	int lc, i;
 	struct itimerval *value;
+	struct test_variants *tv = &variants[tst_variant_t];
 
 	tst_parse_opts(ac, av, NULL, NULL);
 
@@ -87,7 +114,6 @@ int main(int ac, char **av)
 		}
 
 		/* set up some reasonable values */
-
 		value->it_value.tv_sec = 30;
 		value->it_value.tv_usec = 0;
 		value->it_interval.tv_sec = 0;
@@ -97,27 +123,37 @@ int main(int ac, char **av)
 		 * ITIMER_REAL = 0, ITIMER_VIRTUAL = 1 and ITIMER_PROF = 2
 		 */
 
-		/* call with a bad address */
-		TEST(setitimer(ITIMER_REAL, value, (struct itimerval *)-1));
-
-		if (TEST_RETURN == 0) {
-			tst_resm(TFAIL, "call failed to produce EFAULT error "
-				 "- errno = %d - %s", TEST_ERRNO,
-				 strerror(TEST_ERRNO));
-			continue;
+		for (i = 0; i < TST_VARIANTS; i++) {
+
+			tst_resm(TINFO, "Testing variant: %s", tv->desc);
+
+			/* call with a bad address */
+			if (tv->setitimer == libc_setitimer) {
+				tst_resm(TCONF, "EFAULT is skipped for libc variant");
+				tv++;
+				continue;
+			}
+
+			TEST(tv->setitimer(ITIMER_REAL, value, (struct itimerval *)-1));
+
+			if (TEST_RETURN == 0) {
+				tst_resm(TFAIL, "call failed to produce EFAULT error "
+					"- errno = %d - %s", TEST_ERRNO,
+					strerror(TEST_ERRNO));
+					continue;
+			}
+
+			switch (TEST_ERRNO) {
+			case EFAULT:
+				tst_resm(TPASS, "expected failure - errno = %d - %s",
+					 TEST_ERRNO, strerror(TEST_ERRNO));
+				break;
+			default:
+				tst_resm(TFAIL, "call failed to produce EFAULT error "
+					 "- errno = %d - %s", TEST_ERRNO,
+					 strerror(TEST_ERRNO));
+			}
 		}
-
-		switch (TEST_ERRNO) {
-		case EFAULT:
-			tst_resm(TPASS, "expected failure - errno = %d - %s",
-				 TEST_ERRNO, strerror(TEST_ERRNO));
-			break;
-		default:
-			tst_resm(TFAIL, "call failed to produce EFAULT error "
-				 "- errno = %d - %s", TEST_ERRNO,
-				 strerror(TEST_ERRNO));
-		}
-
 		/*
 		 * clean up things in case we are looping
 		 */
@@ -153,7 +189,7 @@ void setup(void)
 
 /*
  * cleanup() - performs all the ONE TIME cleanup for this test at completion
- * 	       or premature exit.
+ *		or premature exit.
  */
 void cleanup(void)
 {
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 45+ messages in thread

* [LTP] [PATCH 1/7] getitimer02: Skipped EFAULT tests for libc variant.
  2021-06-07 10:45 [LTP] [PATCH 1/7] getitimer02: Skipped EFAULT tests for libc variant Vinay Kumar
                   ` (5 preceding siblings ...)
  2021-06-07 10:45 ` [LTP] [PATCH 7/7] setitimer02: " Vinay Kumar
@ 2021-06-08 20:43 ` Petr Vorel
  2021-06-09 17:35   ` [LTP] [PATCH v2 01/10] getitimer02 : Convert getitimer02 to new API Vinay Kumar
  2021-06-09 17:38   ` [LTP] [PATCH 1/7] getitimer02: Skipped EFAULT tests for libc variant Vinay Kumar
  6 siblings, 2 replies; 45+ messages in thread
From: Petr Vorel @ 2021-06-08 20:43 UTC (permalink / raw)
  To: ltp

Hi Vinay,

> Tested EFAULT cases only for "__NR_getitimer" syscall.
Well, you added testing raw syscall via test variant.
That's IMHO the most important thing to mention.

In the text after blank line I'd mention EFAULT skipped on raw syscall.
It'd would deserve to mention why.

Also, as test it's quite simple, it'd be nice, if you first convert it to new
API and in second commit added test variants.
During rewrite you should remove #if !defined(UCLINUX) check as getitimer() is
supported on uclibc-ng.

This apply to whole patchset (some tests are already ported to new API).

Kind regards,
Petr

^ permalink raw reply	[flat|nested] 45+ messages in thread

* [LTP] [PATCH v2 01/10] getitimer02 : Convert getitimer02 to new API
  2021-06-08 20:43 ` [LTP] [PATCH 1/7] getitimer02: " Petr Vorel
@ 2021-06-09 17:35   ` Vinay Kumar
  2021-06-09 17:35     ` [LTP] [PATCH v2 02/10] getitimer02: Skipped EFAULT tests for libc variant Vinay Kumar
                       ` (9 more replies)
  2021-06-09 17:38   ` [LTP] [PATCH 1/7] getitimer02: Skipped EFAULT tests for libc variant Vinay Kumar
  1 sibling, 10 replies; 45+ messages in thread
From: Vinay Kumar @ 2021-06-09 17:35 UTC (permalink / raw)
  To: ltp

Signed-off-by: Vinay Kumar <vinay.m.engg@gmail.com>
---
 .../kernel/syscalls/getitimer/getitimer02.c   | 103 ++++--------------
 1 file changed, 24 insertions(+), 79 deletions(-)

diff --git a/testcases/kernel/syscalls/getitimer/getitimer02.c b/testcases/kernel/syscalls/getitimer/getitimer02.c
index b9c03143a..c2ca8880b 100644
--- a/testcases/kernel/syscalls/getitimer/getitimer02.c
+++ b/testcases/kernel/syscalls/getitimer/getitimer02.c
@@ -1,99 +1,44 @@
+// 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
+ * 03/2001 - Written by Wayne Boyer
  */
 
-/*
-  HISTORY
-  03/2001 - Written by Wayne Boyer
-
-  TEST ITEMS:
-  Check that a getitimer() call fails as expected
-  with an incorrect second argument.
-*/
-
-
-#include "test.h"
+/*\
+ *[Description]
+ *
+ * Check that a getitimer() call fails as expected
+ * with an incorrect second argument.
+ */
 
 #include <errno.h>
 #include <sys/time.h>
+#include "tst_test.h"
 
-char *TCID = "getitimer02";
-int TST_TOTAL = 1;
-
-#if !defined(UCLINUX)
-
-static void cleanup(void);
-static void setup(void);
-
-int main(int ac, char **av)
+static void verify_getitimer(void)
 {
-	int lc;
-
-	tst_parse_opts(ac, av, NULL, NULL);
-
-	setup();
-
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-		tst_count = 0;
-
 		/* call with a bad address */
 		TEST(getitimer(ITIMER_REAL, (struct itimerval *)-1));
 
-		if (TEST_RETURN == 0) {
-			tst_resm(TFAIL, "call failed to produce "
-				 "expected error - errno = %d - %s",
-				 TEST_ERRNO, strerror(TEST_ERRNO));
-			continue;
+		if (TST_RET == 0) {
+			tst_res(TFAIL, "call failed to produce "
+				"expected error - errno = %d - %s",
+				TST_ERR, strerror(TST_ERR));
 		}
 
-		switch (TEST_ERRNO) {
+		switch (TST_ERR) {
 		case EFAULT:
-			tst_resm(TPASS, "expected failure - errno = %d - %s",
-				 TEST_ERRNO, strerror(TEST_ERRNO));
+			tst_res(TPASS, "expected failure - errno = %d - %s",
+				 TST_ERR, strerror(TST_ERR));
 			break;
 		default:
-			tst_resm(TFAIL, "call failed to produce "
-				 "expected error - errno = %d - %s",
-				 TEST_ERRNO, strerror(TEST_ERRNO));
+			tst_res(TFAIL, "call failed to produce "
+					"expected error - errno = %d - %s",
+					TST_ERR, strerror(TST_ERR));
 		}
-	}
-
-	cleanup();
-
-	tst_exit();
-}
-
-static void setup(void)
-{
-	tst_sig(NOFORK, DEF_HANDLER, cleanup);
-
-	TEST_PAUSE;
-}
-
-static void cleanup(void)
-{
-}
-
-#else
-
-int main(void)
-{
-	tst_resm(TINFO, "test is not available on uClinux");
-	tst_exit();
 }
 
-#endif /* if !defined(UCLINUX) */
+static struct tst_test test = {
+			.test_all = verify_getitimer,
+			.needs_root = 1,
+};
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 45+ messages in thread

* [LTP] [PATCH v2 02/10] getitimer02: Skipped EFAULT tests for libc variant.
  2021-06-09 17:35   ` [LTP] [PATCH v2 01/10] getitimer02 : Convert getitimer02 to new API Vinay Kumar
@ 2021-06-09 17:35     ` Vinay Kumar
  2021-06-11 13:43       ` Cyril Hrubis
  2021-06-09 17:35     ` [LTP] [PATCH v2 03/10] getrusage02: Convert getrusage02 to new API Vinay Kumar
                       ` (8 subsequent siblings)
  9 siblings, 1 reply; 45+ messages in thread
From: Vinay Kumar @ 2021-06-09 17:35 UTC (permalink / raw)
  To: ltp

Tested EFAULT cases only for "__NR_getitimer" syscall.

Tests for bad addresses in LTP cases trigger segment
fault in libc on a 32bit system.

Signed-off-by: Vinay Kumar <vinay.m.engg@gmail.com>
---
 .../kernel/syscalls/getitimer/getitimer02.c   | 81 ++++++++++++++-----
 1 file changed, 60 insertions(+), 21 deletions(-)

diff --git a/testcases/kernel/syscalls/getitimer/getitimer02.c b/testcases/kernel/syscalls/getitimer/getitimer02.c
index c2ca8880b..1e5d90a27 100644
--- a/testcases/kernel/syscalls/getitimer/getitimer02.c
+++ b/testcases/kernel/syscalls/getitimer/getitimer02.c
@@ -14,31 +14,70 @@
 #include <errno.h>
 #include <sys/time.h>
 #include "tst_test.h"
+#include "lapi/syscalls.h"
+
+static int libc_getitimer(int which, void *curr_value)
+{
+	return getitimer(which, curr_value);
+}
+
+static int sys_getitimer(int which, void *curr_value)
+{
+	return tst_syscall(__NR_getitimer, which, curr_value);
+}
+
+static struct test_variants
+{
+	int (*getitimer)(int which, void *curr_value);
+	char *desc;
+} variants[] = {
+{ .getitimer = libc_getitimer, .desc = "libc getitimer()"},
+
+#if (__NR_getitimer != __LTP__NR_INVALID_SYSCALL)
+{ .getitimer = sys_getitimer,  .desc = "__NR_getitimer syscall"},
+#endif
+};
 
 static void verify_getitimer(void)
 {
-		/* call with a bad address */
-		TEST(getitimer(ITIMER_REAL, (struct itimerval *)-1));
-
-		if (TST_RET == 0) {
-			tst_res(TFAIL, "call failed to produce "
-				"expected error - errno = %d - %s",
-				TST_ERR, strerror(TST_ERR));
-		}
-
-		switch (TST_ERR) {
-		case EFAULT:
-			tst_res(TPASS, "expected failure - errno = %d - %s",
-				 TST_ERR, strerror(TST_ERR));
-			break;
-		default:
-			tst_res(TFAIL, "call failed to produce "
-					"expected error - errno = %d - %s",
-					TST_ERR, strerror(TST_ERR));
-		}
+	struct test_variants *tv = &variants[tst_variant];
+
+	if (tv->getitimer == libc_getitimer) {
+		tst_res(TCONF, "EFAULT skipped for libc variant");
+		return;
+	}
+
+	/* call with a bad address */
+	TEST(tv->getitimer(ITIMER_REAL, (struct itimerval *)-1));
+
+	if (TST_RET == 0) {
+		tst_res(TFAIL, "call failed to produce "
+			"expected error - errno = %d - %s",
+			TST_ERR, strerror(TST_ERR));
+	}
+
+	switch (TST_ERR) {
+	case EFAULT:
+		tst_res(TPASS, "expected failure - errno = %d - %s",
+			 TST_ERR, strerror(TST_ERR));
+		break;
+	default:
+		tst_res(TFAIL, "call failed to produce "
+			"expected error - errno = %d - %s",
+			TST_ERR, strerror(TST_ERR));
+	}
+}
+
+static void setup(void)
+{
+	struct test_variants *tv = &variants[tst_variant];
+
+	tst_res(TINFO, "Testing variant: %s", tv->desc);
 }
 
 static struct tst_test test = {
-			.test_all = verify_getitimer,
-			.needs_root = 1,
+	.test_all = verify_getitimer,
+	.setup = setup,
+	.test_variants = ARRAY_SIZE(variants),
+	.needs_root = 1,
 };
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 45+ messages in thread

* [LTP] [PATCH v2 03/10] getrusage02: Convert getrusage02 to new API
  2021-06-09 17:35   ` [LTP] [PATCH v2 01/10] getitimer02 : Convert getitimer02 to new API Vinay Kumar
  2021-06-09 17:35     ` [LTP] [PATCH v2 02/10] getitimer02: Skipped EFAULT tests for libc variant Vinay Kumar
@ 2021-06-09 17:35     ` Vinay Kumar
  2021-06-11 13:49       ` Cyril Hrubis
  2021-06-09 17:35     ` [LTP] [PATCH v2 04/10] getrusage02: Skipped EFAULT tests for libc variant Vinay Kumar
                       ` (7 subsequent siblings)
  9 siblings, 1 reply; 45+ messages in thread
From: Vinay Kumar @ 2021-06-09 17:35 UTC (permalink / raw)
  To: ltp

Signed-off-by: Vinay Kumar <vinay.m.engg@gmail.com>
---
 .../kernel/syscalls/getrusage/getrusage02.c   | 142 ++++--------------
 1 file changed, 27 insertions(+), 115 deletions(-)

diff --git a/testcases/kernel/syscalls/getrusage/getrusage02.c b/testcases/kernel/syscalls/getrusage/getrusage02.c
index 8077606a2..c4b3f0f69 100644
--- a/testcases/kernel/syscalls/getrusage/getrusage02.c
+++ b/testcases/kernel/syscalls/getrusage/getrusage02.c
@@ -1,86 +1,29 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
 /*
  * Copyright (c) Wipro Technologies Ltd, 2002.  All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
+ * AUTHOR : Saji Kumar.V.R <saji.kumar@wipro.com>
  */
-/**********************************************************
- *
- *    TEST IDENTIFIER	: getrusage02
- *
- *    EXECUTED BY	: anyone
- *
- *    TEST TITLE	: Tests for error conditions
- *
- *    TEST CASE TOTAL	: 2
- *
- *    AUTHOR		: Saji Kumar.V.R <saji.kumar@wipro.com>
- *
- *    SIGNALS
- * 	Uses SIGUSR1 to pause before test if option set.
- * 	(See the parse_opts(3) man page).
- *
- *    DESCRIPTION
- *	Verify that
- *	1) getrusage() fails with errno EINVAL when an invalid value
- *	   is given for who
- *	2) getrusage() fails with errno EFAULT when an invalid address
- *	   is given for usage
- *
- * 	Setup:
- * 	  Setup signal handling.
- *	  Pause for SIGUSR1 if option specified.
- *
- * 	Test:
- *	 Loop if the proper options are given.
- * 	  Execute system call
- *	  if call failed with expected errno,
- *		Test Passed
- *	  else
- *		Test Failed
- *
- * 	Cleanup:
- * 	  Print errno log and/or timing stats if options given
+
+/*\
+ *[Description]
  *
- * USAGE:  <for command-line>
- *  getrusage02 [-c n] [-e] [-i n] [-I x] [-P x] [-t] [-h] [-f]
- * 			     [-p]
- *			where,  -c n : Run n copies concurrently.
- *				-e   : Turn on errno logging.
- *				-h   : Show help screen
- *				-f   : Turn off functional testing
- *				-i n : Execute test n times.
- *				-I x : Execute test for x seconds.
- *				-p   : Pause for SIGUSR1 before starting
- *				-P x : Pause for x seconds between iterations.
- *				-t   : Turn on syscall timing.
+ * Verify that
+ * 1) getrusage() fails with errno EINVAL when an invalid value
+ *   is given for who
+ * 2) getrusage() fails with errno EFAULT when an invalid address
+ *   is given for usage
  *
- ****************************************************************/
+ */
 
 #include <errno.h>
 #include <sched.h>
 #include <sys/resource.h>
-#include "test.h"
+#include "tst_test.h"
 
 #ifndef RUSAGE_BOTH		/* Removed from user space on RHEL4 */
 #define RUSAGE_BOTH (-2)	/* still works on SuSE      */
 #endif /* so this is a work around */
 
-static void setup();
-static void cleanup();
-
-char *TCID = "getrusage02";
-
 static struct rusage usage;
 
 struct test_cases_t {
@@ -90,56 +33,25 @@ struct test_cases_t {
 } test_cases[] = {
 	{
 	RUSAGE_BOTH, &usage, EINVAL},
-#ifndef UCLINUX
 	{
 	RUSAGE_SELF, (struct rusage *)-1, EFAULT}
-#endif
 };
 
-int TST_TOTAL = ARRAY_SIZE(test_cases);
-
-int main(int ac, char **av)
+static void verify_getrusage(unsigned int i)
 {
-
-	int lc, i;
-
-	tst_parse_opts(ac, av, NULL, NULL);
-
-	setup();
-
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-
-		tst_count = 0;
-
-		for (i = 0; i < TST_TOTAL; i++) {
-			TEST(getrusage(test_cases[i].who, test_cases[i].usage));
-
-			if (TEST_RETURN == -1 &&
-			    TEST_ERRNO == test_cases[i].exp_errno)
-				tst_resm(TPASS | TTERRNO,
-					 "getrusage failed as expected");
-			else
-				tst_resm(TFAIL | TTERRNO,
-					 "getrusage failed unexpectedly");
-		}
-	}
-
-	cleanup();
-
-	tst_exit();
-
+		TEST(getrusage(test_cases[i].who, test_cases[i].usage));
+
+		if (TST_RET == -1 &&
+		    TST_ERR == test_cases[i].exp_errno)
+			tst_res(TPASS | TTERRNO,
+				"getrusage failed as expected");
+		else
+			tst_res(TFAIL | TTERRNO,
+				"getrusage failed unexpectedly");
 }
 
-void setup(void)
-{
-
-	tst_sig(NOFORK, DEF_HANDLER, cleanup);
-
-	TEST_PAUSE;
-
-}
-
-void cleanup(void)
-{
-
-}
+static struct tst_test test = {
+	.test = verify_getrusage,
+	.tcnt = ARRAY_SIZE(test_cases),
+	.needs_root = 1,
+};
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 45+ messages in thread

* [LTP] [PATCH v2 04/10] getrusage02: Skipped EFAULT tests for libc variant.
  2021-06-09 17:35   ` [LTP] [PATCH v2 01/10] getitimer02 : Convert getitimer02 to new API Vinay Kumar
  2021-06-09 17:35     ` [LTP] [PATCH v2 02/10] getitimer02: Skipped EFAULT tests for libc variant Vinay Kumar
  2021-06-09 17:35     ` [LTP] [PATCH v2 03/10] getrusage02: Convert getrusage02 to new API Vinay Kumar
@ 2021-06-09 17:35     ` Vinay Kumar
  2021-06-11 13:50       ` Cyril Hrubis
  2021-06-09 17:35     ` [LTP] [PATCH v2 05/10] setitimer02: Convert setitimer02 to new API Vinay Kumar
                       ` (6 subsequent siblings)
  9 siblings, 1 reply; 45+ messages in thread
From: Vinay Kumar @ 2021-06-09 17:35 UTC (permalink / raw)
  To: ltp

Tested EFAULT cases only for "__NR_getrusage" syscall.

Tests for bad addresses in LTP cases trigger segment
fault in libc on a 32bit system.

Signed-off-by: Vinay Kumar <vinay.m.engg@gmail.com>
---
 .../kernel/syscalls/getrusage/getrusage02.c   | 58 ++++++++++++++++---
 1 file changed, 49 insertions(+), 9 deletions(-)

diff --git a/testcases/kernel/syscalls/getrusage/getrusage02.c b/testcases/kernel/syscalls/getrusage/getrusage02.c
index c4b3f0f69..07ff04dee 100644
--- a/testcases/kernel/syscalls/getrusage/getrusage02.c
+++ b/testcases/kernel/syscalls/getrusage/getrusage02.c
@@ -19,6 +19,7 @@
 #include <sched.h>
 #include <sys/resource.h>
 #include "tst_test.h"
+#include "lapi/syscalls.h"
 
 #ifndef RUSAGE_BOTH		/* Removed from user space on RHEL4 */
 #define RUSAGE_BOTH (-2)	/* still works on SuSE      */
@@ -26,6 +27,16 @@
 
 static struct rusage usage;
 
+static int libc_getrusage(int who, void *usage)
+{
+	return getrusage(who, usage);
+}
+
+static int sys_getrusage(int who, void *usage)
+{
+	return tst_syscall(__NR_getrusage, who, usage);
+}
+
 struct test_cases_t {
 	int who;
 	struct rusage *usage;
@@ -37,21 +48,50 @@ struct test_cases_t {
 	RUSAGE_SELF, (struct rusage *)-1, EFAULT}
 };
 
+static struct test_variants
+{
+	int (*getrusage)(int who, void *usage);
+	char *desc;
+} variants[] = {
+{ .getrusage = libc_getrusage, .desc = "libc getrusage()"},
+
+#if (__NR_getrusage != __LTP__NR_INVALID_SYSCALL)
+{ .getrusage = sys_getrusage,  .desc = "__NR_getrusage syscall"},
+#endif
+};
+
 static void verify_getrusage(unsigned int i)
 {
-		TEST(getrusage(test_cases[i].who, test_cases[i].usage));
-
-		if (TST_RET == -1 &&
-		    TST_ERR == test_cases[i].exp_errno)
-			tst_res(TPASS | TTERRNO,
-				"getrusage failed as expected");
-		else
-			tst_res(TFAIL | TTERRNO,
-				"getrusage failed unexpectedly");
+	struct test_variants *tv = &variants[tst_variant];
+
+	if (test_cases[i].exp_errno == EFAULT &&
+		tv->getrusage == libc_getrusage) {
+		tst_res(TCONF, "EFAULT is skipped for libc variant");
+		return;
+	}
+
+	TEST(tv->getrusage(test_cases[i].who, test_cases[i].usage));
+
+	if (TST_RET == -1 &&
+		TST_ERR == test_cases[i].exp_errno)
+		tst_res(TPASS | TTERRNO,
+			"getrusage failed as expected");
+	else
+		tst_res(TFAIL | TTERRNO,
+			"getrusage failed unexpectedly");
+}
+
+static void setup(void)
+{
+	struct test_variants *tv = &variants[tst_variant];
+
+	tst_res(TINFO, "Testing variant: %s", tv->desc);
 }
 
 static struct tst_test test = {
 	.test = verify_getrusage,
+	.setup = setup,
 	.tcnt = ARRAY_SIZE(test_cases),
+	.test_variants = ARRAY_SIZE(variants),
 	.needs_root = 1,
 };
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 45+ messages in thread

* [LTP] [PATCH v2 05/10] setitimer02: Convert setitimer02 to new API
  2021-06-09 17:35   ` [LTP] [PATCH v2 01/10] getitimer02 : Convert getitimer02 to new API Vinay Kumar
                       ` (2 preceding siblings ...)
  2021-06-09 17:35     ` [LTP] [PATCH v2 04/10] getrusage02: Skipped EFAULT tests for libc variant Vinay Kumar
@ 2021-06-09 17:35     ` Vinay Kumar
  2021-06-11 13:57       ` Cyril Hrubis
  2021-06-09 17:35     ` [LTP] [PATCH v2 06/10] setitimer02: Skipped EFAULT tests for libc variant Vinay Kumar
                       ` (5 subsequent siblings)
  9 siblings, 1 reply; 45+ messages in thread
From: Vinay Kumar @ 2021-06-09 17:35 UTC (permalink / raw)
  To: ltp

Signed-off-by: Vinay Kumar <vinay.m.engg@gmail.com>
---
 .../kernel/syscalls/setitimer/setitimer02.c   | 192 +++++-------------
 1 file changed, 51 insertions(+), 141 deletions(-)

diff --git a/testcases/kernel/syscalls/setitimer/setitimer02.c b/testcases/kernel/syscalls/setitimer/setitimer02.c
index 4d13cd1e0..656cf7d6a 100644
--- a/testcases/kernel/syscalls/setitimer/setitimer02.c
+++ b/testcases/kernel/syscalls/setitimer/setitimer02.c
@@ -1,161 +1,71 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
 /*
+ * Copyright (c) International Business Machines  Corp., 2001
+ * 03/2001 - Written by Wayne Boyer
  *
- *   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
  */
 
-/*
- * NAME
- *	setitimer02.c
- *
- * DESCRIPTION
- *	setitimer02 - check that a setitimer() call fails as expected
- *		      with incorrect values.
+/*\
+ * [Description]
  *
- * ALGORITHM
- *	loop if that option was specified
- *	allocate needed space and set up needed values
- *	issue the system call
- *	check the errno value
- *	  issue a PASS message if we get EFAULT
- *	otherwise, the tests fails
- *	  issue a FAIL message
- *	  break any remaining tests
- *	  call cleanup
- *
- * USAGE:  <for command-line>
- *  setitimer02 [-c n] [-e] [-i n] [-I x] [-P x] [-t]
- *     where,  -c n : Run n copies concurrently.
- *             -e   : Turn on errno logging.
- *	       -i n : Execute test n times.
- *	       -I x : Execute test for x seconds.
- *	       -P x : Pause for x seconds between iterations.
- *	       -t   : Turn on syscall timing.
- *
- * HISTORY
- *	03/2001 - Written by Wayne Boyer
- *
- * RESTRICTIONS
- *	none
+ * setitimer02 - check that a setitimer() call fails as expected
+ *	 with incorrect values.
  */
 
-#include "test.h"
-
 #include <errno.h>
 #include <sys/time.h>
+#include <stdlib.h>
+#include "tst_test.h"
 
-void cleanup(void);
-void setup(void);
-
-char *TCID = "setitimer02";
-int TST_TOTAL = 1;
-
-#if !defined(UCLINUX)
-
-int main(int ac, char **av)
+static void verify_setitimer(void)
 {
-	int lc;
 	struct itimerval *value;
 
-	tst_parse_opts(ac, av, NULL, NULL);
-
-	setup();		/* global setup */
-
-	/* The following loop checks looping state if -i option given */
-
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-		/* reset tst_count in case we are looping */
-		tst_count = 0;
-
-		/* allocate some space for a timer structure */
-		if ((value = malloc((size_t)sizeof(struct itimerval))) ==
-		    NULL) {
-			tst_brkm(TBROK, cleanup, "value malloc failed");
-		}
-
-		/* set up some reasonable values */
-
-		value->it_value.tv_sec = 30;
-		value->it_value.tv_usec = 0;
-		value->it_interval.tv_sec = 0;
-		value->it_interval.tv_usec = 0;
-		/*
-		 * issue the system call with the TEST() macro
-		 * ITIMER_REAL = 0, ITIMER_VIRTUAL = 1 and ITIMER_PROF = 2
-		 */
-
-		/* call with a bad address */
-		TEST(setitimer(ITIMER_REAL, value, (struct itimerval *)-1));
-
-		if (TEST_RETURN == 0) {
-			tst_resm(TFAIL, "call failed to produce EFAULT error "
-				 "- errno = %d - %s", TEST_ERRNO,
-				 strerror(TEST_ERRNO));
-			continue;
-		}
-
-		switch (TEST_ERRNO) {
-		case EFAULT:
-			tst_resm(TPASS, "expected failure - errno = %d - %s",
-				 TEST_ERRNO, strerror(TEST_ERRNO));
-			break;
-		default:
-			tst_resm(TFAIL, "call failed to produce EFAULT error "
-				 "- errno = %d - %s", TEST_ERRNO,
-				 strerror(TEST_ERRNO));
-		}
-
-		/*
-		 * clean up things in case we are looping
-		 */
-		free(value);
-		value = NULL;
+	/* allocate some space for a timer structure */
+	if ((value = malloc((size_t)sizeof(struct itimerval))) ==
+		NULL) {
+		tst_brk(TBROK, "value malloc failed");
 	}
 
-	cleanup();
-	tst_exit();
-
-}
-
-#else
-
-int main(void)
-{
-	tst_resm(TINFO, "test is not available on uClinux");
-	tst_exit();
-}
-
-#endif /* if !defined(UCLINUX) */
-
-/*
- * setup() - performs all the ONE TIME setup for this test.
- */
-void setup(void)
-{
+	/* set up some reasonable values */
+	value->it_value.tv_sec = 30;
+	value->it_value.tv_usec = 0;
+	value->it_interval.tv_sec = 0;
+	value->it_interval.tv_usec = 0;
+	/*
+	 * issue the system call with the TEST() macro
+	 * ITIMER_REAL = 0, ITIMER_VIRTUAL = 1 and ITIMER_PROF = 2
+	 */
+
+	/* call with a bad address */
+	TEST(setitimer(ITIMER_REAL, value, (struct itimerval *)-1));
+
+	if (TST_RET == 0) {
+		tst_res(TFAIL, "call failed to produce EFAULT error "
+			"- errno = %d - %s", TST_ERR,
+			strerror(TST_ERR));
+	}
 
-	tst_sig(NOFORK, DEF_HANDLER, cleanup);
+	switch (TST_ERR) {
+	case EFAULT:
+		tst_res(TPASS, "expected failure - errno = %d - %s",
+			TST_ERR, strerror(TST_ERR));
+		break;
+	default:
+		tst_res(TFAIL, "call failed to produce EFAULT error "
+			"- errno = %d - %s", TST_ERR,
+			strerror(TST_ERR));
+	}
 
-	TEST_PAUSE;
+	/*
+	 * clean up things in case we are looping
+	 */
+	free(value);
+	value = NULL;
 }
 
-/*
- * cleanup() - performs all the ONE TIME cleanup for this test at completion
- * 	       or premature exit.
- */
-void cleanup(void)
-{
+static struct tst_test test = {
+	.test_all = verify_setitimer,
+	.needs_root = 1,
+};
 
-}
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 45+ messages in thread

* [LTP] [PATCH v2 06/10] setitimer02: Skipped EFAULT tests for libc variant.
  2021-06-09 17:35   ` [LTP] [PATCH v2 01/10] getitimer02 : Convert getitimer02 to new API Vinay Kumar
                       ` (3 preceding siblings ...)
  2021-06-09 17:35     ` [LTP] [PATCH v2 05/10] setitimer02: Convert setitimer02 to new API Vinay Kumar
@ 2021-06-09 17:35     ` Vinay Kumar
  2021-06-11 14:00       ` Cyril Hrubis
  2021-06-09 17:35     ` [LTP] [PATCH v2 07/10] msgctl04: " Vinay Kumar
                       ` (4 subsequent siblings)
  9 siblings, 1 reply; 45+ messages in thread
From: Vinay Kumar @ 2021-06-09 17:35 UTC (permalink / raw)
  To: ltp

Tested EFAULT cases only for "__NR_setitimer" syscall.

Tests for bad addresses in LTP cases trigger segment
fault in libc on a 32bit system.

Signed-off-by: Vinay Kumar <vinay.m.engg@gmail.com>
---
 .../kernel/syscalls/setitimer/setitimer02.c   | 41 ++++++++++++++++++-
 1 file changed, 39 insertions(+), 2 deletions(-)

diff --git a/testcases/kernel/syscalls/setitimer/setitimer02.c b/testcases/kernel/syscalls/setitimer/setitimer02.c
index 656cf7d6a..77e01b018 100644
--- a/testcases/kernel/syscalls/setitimer/setitimer02.c
+++ b/testcases/kernel/syscalls/setitimer/setitimer02.c
@@ -16,10 +16,34 @@
 #include <sys/time.h>
 #include <stdlib.h>
 #include "tst_test.h"
+#include "lapi/syscalls.h"
+
+static int libc_setitimer(int which, void *new_value, void *old_value)
+{
+	return setitimer(which, new_value, old_value);
+}
+
+static int sys_setitimer(int which, void *new_value, void *old_value)
+{
+	return tst_syscall(__NR_setitimer, which, new_value, old_value);
+}
+
+static struct test_variants
+{
+	int (*setitimer)(int which, void *new_value, void *old_value);
+	char *desc;
+} variants[] = {
+{ .setitimer = libc_setitimer, .desc = "libc setitimer()"},
+
+#if (__NR_setitimer != __LTP__NR_INVALID_SYSCALL)
+{ .setitimer = sys_setitimer,  .desc = "__NR_setitimer syscall"},
+#endif
+};
 
 static void verify_setitimer(void)
 {
 	struct itimerval *value;
+	struct test_variants *tv = &variants[tst_variant];
 
 	/* allocate some space for a timer structure */
 	if ((value = malloc((size_t)sizeof(struct itimerval))) ==
@@ -37,8 +61,13 @@ static void verify_setitimer(void)
 	 * ITIMER_REAL = 0, ITIMER_VIRTUAL = 1 and ITIMER_PROF = 2
 	 */
 
+	if (tv->setitimer == libc_setitimer) {
+		tst_res(TCONF, "EFAULT is skipped for libc variant");
+		return;
+	}
+
 	/* call with a bad address */
-	TEST(setitimer(ITIMER_REAL, value, (struct itimerval *)-1));
+	TEST(tv->setitimer(ITIMER_REAL, value, (struct itimerval *)-1));
 
 	if (TST_RET == 0) {
 		tst_res(TFAIL, "call failed to produce EFAULT error "
@@ -64,8 +93,16 @@ static void verify_setitimer(void)
 	value = NULL;
 }
 
+static void setup(void)
+{
+	struct test_variants *tv = &variants[tst_variant];
+
+	tst_res(TINFO, "Testing variant: %s", tv->desc);
+}
+
 static struct tst_test test = {
 	.test_all = verify_setitimer,
+	.setup = setup,
+	.test_variants = ARRAY_SIZE(variants),
 	.needs_root = 1,
 };
-
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 45+ messages in thread

* [LTP] [PATCH v2 07/10] msgctl04: Skipped EFAULT tests for libc variant.
  2021-06-09 17:35   ` [LTP] [PATCH v2 01/10] getitimer02 : Convert getitimer02 to new API Vinay Kumar
                       ` (4 preceding siblings ...)
  2021-06-09 17:35     ` [LTP] [PATCH v2 06/10] setitimer02: Skipped EFAULT tests for libc variant Vinay Kumar
@ 2021-06-09 17:35     ` Vinay Kumar
  2021-06-11 14:13       ` Cyril Hrubis
  2021-06-09 17:35     ` [LTP] [PATCH v2 08/10] semctl03 :Skipped " Vinay Kumar
                       ` (3 subsequent siblings)
  9 siblings, 1 reply; 45+ messages in thread
From: Vinay Kumar @ 2021-06-09 17:35 UTC (permalink / raw)
  To: ltp

Tested EFAULT cases only for "__NR_msgctl" syscall.

Tests for bad addresses in LTP cases trigger segment
fault in libc on a 32bit system.

Signed-off-by: Vinay Kumar <vinay.m.engg@gmail.com>
---
 .../kernel/syscalls/ipc/msgctl/msgctl04.c     | 38 ++++++++++++++++++-
 1 file changed, 37 insertions(+), 1 deletion(-)

diff --git a/testcases/kernel/syscalls/ipc/msgctl/msgctl04.c b/testcases/kernel/syscalls/ipc/msgctl/msgctl04.c
index 900b22244..3d0c7f896 100644
--- a/testcases/kernel/syscalls/ipc/msgctl/msgctl04.c
+++ b/testcases/kernel/syscalls/ipc/msgctl/msgctl04.c
@@ -15,6 +15,7 @@
 #include "tst_test.h"
 #include "tst_safe_sysv_ipc.h"
 #include "libnewipc.h"
+#include "lapi/syscalls.h"
 
 static int msg_id1 = -1;
 static int msg_id2 = -1;
@@ -23,6 +24,16 @@ static int bad_q = -1;
 
 struct msqid_ds q_buf;
 
+static int libc_msgctl(int msqid, int cmd, void *buf)
+{
+	return msgctl(msqid, cmd, buf);
+}
+
+static int sys_msgctl(int msqid, int cmd, void *buf)
+{
+	return tst_syscall(__NR_msgctl, msqid, cmd, buf);
+}
+
 struct tcase {
 	int *msg_id;
 	int cmd;
@@ -45,9 +56,29 @@ struct tcase {
 	{&msg_id3, IPC_RMID, NULL, EPERM},
 };
 
+static struct test_variants
+{
+	int (*msgctl)(int msqid, int cmd, void *buf);
+	char *desc;
+} variants[] = {
+	{ .msgctl = libc_msgctl, .desc = "libc msgctl()"},
+
+#if (__NR_msgctl != __LTP__NR_INVALID_SYSCALL)
+	{ .msgctl = sys_msgctl,  .desc = "__NR_msgctl syscall"},
+#endif
+};
+
 static void verify_msgctl(unsigned int i)
 {
-	TEST(msgctl(*(tc[i].msg_id), tc[i].cmd, tc[i].buf));
+	struct test_variants *tv = &variants[tst_variant];
+
+	if (tc[i].error == EFAULT &&
+		tv->msgctl == libc_msgctl) {
+		tst_res(TCONF, "EFAULT is skipped for libc variant");
+		return;
+	}
+
+	TEST(tv->msgctl(*(tc[i].msg_id), tc[i].cmd, tc[i].buf));
 
 	if (TST_RET != -1) {
 		tst_res(TFAIL, "msgctl() returned %li", TST_RET);
@@ -66,6 +97,8 @@ static void verify_msgctl(unsigned int i)
 
 static void setup(void)
 {
+	struct test_variants *tv = &variants[tst_variant];
+
 	key_t msgkey1, msgkey2;
 	struct passwd *ltpuser;
 
@@ -79,6 +112,8 @@ static void setup(void)
 
 	msg_id1 = SAFE_MSGGET(msgkey1, IPC_CREAT | IPC_EXCL);
 	msg_id2 = SAFE_MSGGET(msgkey2, IPC_CREAT | IPC_EXCL | MSG_RD | MSG_WR);
+
+	tst_res(TINFO, "Testing variant: %s", tv->desc);
 }
 
 static void cleanup(void)
@@ -100,6 +135,7 @@ static struct tst_test test = {
 	.cleanup = cleanup,
 	.test = verify_msgctl,
 	.tcnt = ARRAY_SIZE(tc),
+	.test_variants = ARRAY_SIZE(variants),
 	.needs_tmpdir = 1,
 	.needs_root = 1,
 };
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 45+ messages in thread

* [LTP] [PATCH v2 08/10] semctl03 :Skipped EFAULT tests for libc variant.
  2021-06-09 17:35   ` [LTP] [PATCH v2 01/10] getitimer02 : Convert getitimer02 to new API Vinay Kumar
                       ` (5 preceding siblings ...)
  2021-06-09 17:35     ` [LTP] [PATCH v2 07/10] msgctl04: " Vinay Kumar
@ 2021-06-09 17:35     ` Vinay Kumar
  2021-06-17 11:34       ` Cyril Hrubis
  2021-06-09 17:36     ` [LTP] [PATCH v2 09/10] sched_rr_get_interval03: Skipped " Vinay Kumar
                       ` (2 subsequent siblings)
  9 siblings, 1 reply; 45+ messages in thread
From: Vinay Kumar @ 2021-06-09 17:35 UTC (permalink / raw)
  To: ltp

Tested EFAULT cases only for "__NR_semctl" syscall.

Tests for bad addresses in LTP cases trigger segment
fault in libc on a 32bit system.

Signed-off-by: Vinay Kumar <vinay.m.engg@gmail.com>
---
 .../kernel/syscalls/ipc/semctl/semctl03.c     | 39 ++++++++++++++++++-
 1 file changed, 37 insertions(+), 2 deletions(-)

diff --git a/testcases/kernel/syscalls/ipc/semctl/semctl03.c b/testcases/kernel/syscalls/ipc/semctl/semctl03.c
index ed2a46b16..44030ae47 100644
--- a/testcases/kernel/syscalls/ipc/semctl/semctl03.c
+++ b/testcases/kernel/syscalls/ipc/semctl/semctl03.c
@@ -15,6 +15,7 @@
 #include "tst_test.h"
 #include "lapi/sem.h"
 #include "libnewipc.h"
+#include "lapi/syscalls.h"
 
 static int sem_id = -1;
 static int bad_id = -1;
@@ -23,6 +24,17 @@ static struct semid_ds sem_ds;
 static union semun sem_un = {.buf = &sem_ds};
 static void *semds_ptr = &sem_un;
 static void *bad_ptr;
+static union semun arg = {0};
+
+static int libc_semctl(int semid, int semnum, int cmd, ...)
+{
+	return semctl(semid, semnum, cmd, arg);
+}
+
+static int sys_semctl(int semid, int semnum, int cmd, ...)
+{
+	return tst_syscall(__NR_semctl, semid, semnum, cmd, arg);
+}
 
 static struct tcases {
 	int *sem_id;
@@ -37,17 +49,39 @@ static struct tcases {
 	{&sem_id, IPC_SET, &bad_ptr, EFAULT, "invalid union arg"}
 };
 
+static struct test_variants
+{
+	int (*semctl)(int semid, int semnum, int cmd, ...);
+	char *desc;
+} variants[] = {
+	{ .semctl = libc_semctl, .desc = "libc semctl()"},
+
+#if (__NR_sys_semctl != __LTP__NR_INVALID_SYSCALL)
+	{ .semctl = sys_semctl,  .desc = "__NR_semctl syscall"},
+#endif
+};
+
 static void verify_semctl(unsigned int n)
 {
 	struct tcases *tc = &tests[n];
+	struct test_variants *tv = &variants[tst_variant];
+
+	if (tc->error == EFAULT
+		&& tv->semctl == libc_semctl) {
+		tst_res(TCONF, "EFAULT is skipped for libc variant");
+		return;
+	}
 
-	TST_EXP_FAIL(semctl(*(tc->sem_id), 0, tc->ipc_cmd, *(tc->buf)),
-		     tc->error, "semctl() with %s", tc->message);
+	TST_EXP_FAIL(sys_semctl(*(tc->sem_id), 0, tc->ipc_cmd, *(tc->buf)),
+		tc->error, "semctl() with %s", tc->message);
 }
 
 static void setup(void)
 {
 	static key_t semkey;
+	struct test_variants *tv = &variants[tst_variant];
+
+	tst_res(TINFO, "Testing variant: %s", tv->desc);
 
 	semkey = GETIPCKEY();
 
@@ -67,4 +101,5 @@ static struct tst_test test = {
 	.cleanup = cleanup,
 	.test = verify_semctl,
 	.tcnt = ARRAY_SIZE(tests),
+	.test_variants = ARRAY_SIZE(variants),
 };
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 45+ messages in thread

* [LTP] [PATCH v2 09/10] sched_rr_get_interval03: Skipped EFAULT tests for libc variant.
  2021-06-09 17:35   ` [LTP] [PATCH v2 01/10] getitimer02 : Convert getitimer02 to new API Vinay Kumar
                       ` (6 preceding siblings ...)
  2021-06-09 17:35     ` [LTP] [PATCH v2 08/10] semctl03 :Skipped " Vinay Kumar
@ 2021-06-09 17:36     ` Vinay Kumar
  2021-06-11 14:36       ` Cyril Hrubis
  2021-06-09 17:36     ` [LTP] [PATCH v2 10/10] shmctl02 :Skipped " Vinay Kumar
  2021-06-11 13:41     ` [LTP] [PATCH v2 01/10] getitimer02 : Convert getitimer02 to new API Cyril Hrubis
  9 siblings, 1 reply; 45+ messages in thread
From: Vinay Kumar @ 2021-06-09 17:36 UTC (permalink / raw)
  To: ltp

Tested EFAULT cases only for "__NR_sched_rr_get_interval"
and "__NR_sched_rr_get_interval_time64" syscalls.

Tests for bad addresses in LTP cases trigger segment
fault in libc on a 32bit system.

Signed-off-by: Vinay Kumar <vinay.m.engg@gmail.com>
---
 .../sched_rr_get_interval/sched_rr_get_interval03.c         | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/testcases/kernel/syscalls/sched_rr_get_interval/sched_rr_get_interval03.c b/testcases/kernel/syscalls/sched_rr_get_interval/sched_rr_get_interval03.c
index 0c9887f36..cee9245e6 100644
--- a/testcases/kernel/syscalls/sched_rr_get_interval/sched_rr_get_interval03.c
+++ b/testcases/kernel/syscalls/sched_rr_get_interval/sched_rr_get_interval03.c
@@ -67,6 +67,12 @@ static void run(unsigned int i)
 	struct test_cases_t *tc = &test_cases[i];
 	struct timerspec *ts;
 
+	if (tc->exp_errno == EFAULT
+		&& tv->sched_rr_get_interval == libc_sched_rr_get_interval) {
+		tst_res(TCONF, "EFAULT skipped for libc_variant");
+		return;
+	}
+
 	if (tc->exp_errno == EFAULT)
 		ts = bad_addr;
 	else
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 45+ messages in thread

* [LTP] [PATCH v2 10/10] shmctl02 :Skipped EFAULT tests for libc variant.
  2021-06-09 17:35   ` [LTP] [PATCH v2 01/10] getitimer02 : Convert getitimer02 to new API Vinay Kumar
                       ` (7 preceding siblings ...)
  2021-06-09 17:36     ` [LTP] [PATCH v2 09/10] sched_rr_get_interval03: Skipped " Vinay Kumar
@ 2021-06-09 17:36     ` Vinay Kumar
  2021-06-13 17:49       ` [LTP] [PATCH v3] ipc/shmctl02: Make use of TST_EXP_FAIL() Vinay Kumar
  2021-06-17 11:38       ` [LTP] [PATCH v2 10/10] shmctl02 :Skipped EFAULT tests for libc variant Cyril Hrubis
  2021-06-11 13:41     ` [LTP] [PATCH v2 01/10] getitimer02 : Convert getitimer02 to new API Cyril Hrubis
  9 siblings, 2 replies; 45+ messages in thread
From: Vinay Kumar @ 2021-06-09 17:36 UTC (permalink / raw)
  To: ltp

Tested EFAULT cases only for "__NR_shmctl" syscall.

Tests for bad addresses in LTP cases trigger segment
fault in libc on a 32bit system.

Signed-off-by: Vinay Kumar <vinay.m.engg@gmail.com>
---
 .../kernel/syscalls/ipc/shmctl/shmctl02.c     | 40 ++++++++++++++++++-
 1 file changed, 38 insertions(+), 2 deletions(-)

diff --git a/testcases/kernel/syscalls/ipc/shmctl/shmctl02.c b/testcases/kernel/syscalls/ipc/shmctl/shmctl02.c
index 9057b7f54..b9a71722d 100644
--- a/testcases/kernel/syscalls/ipc/shmctl/shmctl02.c
+++ b/testcases/kernel/syscalls/ipc/shmctl/shmctl02.c
@@ -32,6 +32,7 @@
 #include "tst_test.h"
 #include "tst_safe_sysv_ipc.h"
 #include "libnewipc.h"
+#include "lapi/syscalls.h"
 
 #define SHM_SIZE 2048
 
@@ -43,6 +44,16 @@ static int shm_rem;
 
 static struct shmid_ds buf;
 
+static int libc_shmctl(int shmid, int cmd, void *buf)
+{
+	return shmctl(shmid, cmd, buf);
+}
+
+static int sys_shmctl(int shmid, int cmd, void *buf)
+{
+	return tst_syscall(__NR_shmctl, shmid, cmd, buf);
+}
+
 static struct tcase {
 	int *shm_id;
 	int cmd;
@@ -63,9 +74,29 @@ static struct tcase {
 	{&shm_id3, SHM_UNLOCK, &buf, EPERM}
 };
 
+static struct test_variants
+{
+	int (*shmctl)(int shmid, int cmd, void *buf);
+	char *desc;
+} variants[] = {
+	{ .shmctl = libc_shmctl, .desc = "libc shmctl()"},
+
+#if (__NR_shmctl != __LTP__NR_INVALID_SYSCALL)
+	{ .shmctl = sys_shmctl,  .desc = "__NR_shmctl syscall"},
+#endif
+};
+
 static void verify_shmctl(unsigned int i)
 {
-	TEST(shmctl(*(tc[i].shm_id), tc[i].cmd, tc[i].buf));
+	struct test_variants *tv = &variants[tst_variant];
+
+	if (tc[i].error == EFAULT
+		&& tv->shmctl == libc_shmctl) {
+		tst_res(TCONF, "EFAULT is skipped for libc variant");
+		return;
+	}
+
+	TEST(tv->shmctl(*(tc[i].shm_id), tc[i].cmd, tc[i].buf));
 
 	if (TST_RET != -1) {
 		tst_res(TFAIL, "shmctl() returned %li", TST_RET);
@@ -74,7 +105,7 @@ static void verify_shmctl(unsigned int i)
 
 	if (TST_ERR == tc[i].error) {
 		tst_res(TPASS | TTERRNO, "shmctl(%i, %i, %p)",
-		        *tc[i].shm_id, tc[i].cmd, tc[i].buf);
+				*tc[i].shm_id, tc[i].cmd, tc[i].buf);
 		return;
 	}
 
@@ -84,10 +115,14 @@ static void verify_shmctl(unsigned int i)
 
 static void setup(void)
 {
+	struct test_variants *tv = &variants[tst_variant];
+
 	key_t shmkey1, shmkey2;
 	struct passwd *ltpuser;
 	int tmp;
 
+	tst_res(TINFO, "Testing variant: %s", tv->desc);
+
 	shm_id3 = SAFE_SHMGET(IPC_PRIVATE, SHM_SIZE, IPC_CREAT | SHM_RW);
 
 	ltpuser = SAFE_GETPWNAM("nobody");
@@ -121,6 +156,7 @@ static struct tst_test test = {
 	.setup = setup,
 	.cleanup = cleanup,
 	.test = verify_shmctl,
+	.test_variants = ARRAY_SIZE(variants),
 	.tcnt = ARRAY_SIZE(tc),
 	.needs_root = 1,
 };
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 45+ messages in thread

* [LTP] [PATCH 1/7] getitimer02: Skipped EFAULT tests for libc variant.
  2021-06-08 20:43 ` [LTP] [PATCH 1/7] getitimer02: " Petr Vorel
  2021-06-09 17:35   ` [LTP] [PATCH v2 01/10] getitimer02 : Convert getitimer02 to new API Vinay Kumar
@ 2021-06-09 17:38   ` Vinay Kumar
  1 sibling, 0 replies; 45+ messages in thread
From: Vinay Kumar @ 2021-06-09 17:38 UTC (permalink / raw)
  To: ltp

Hi Petr,

Sent v2 patches for review with suggested corrections.

>> In the text after blank line I'd mention EFAULT skipped on raw syscall.
>> It'd would deserve to mention why.

Yes, added the reason in the commit log of each test case.

>> Also, as test it's quite simple, it'd be nice, if you first convert it to new
>> API and in second commit added test variants.

getitimer02.c, getrusage02.c and setitimer02.c are updated to the new API.
Then added test variants. Remaining test cases are already updated
with the new API.

>> During rewrite you should remove #if !defined(UCLINUX) check as getitimer() is
>> supported on uclibc-ng.

Removed the same.

Regards,
Vinay

On Wed, Jun 9, 2021 at 2:13 AM Petr Vorel <pvorel@suse.cz> wrote:
>
> Hi Vinay,
>
> > Tested EFAULT cases only for "__NR_getitimer" syscall.
> Well, you added testing raw syscall via test variant.
> That's IMHO the most important thing to mention.
>
> In the text after blank line I'd mention EFAULT skipped on raw syscall.
> It'd would deserve to mention why.
>
> Also, as test it's quite simple, it'd be nice, if you first convert it to new
> API and in second commit added test variants.
> During rewrite you should remove #if !defined(UCLINUX) check as getitimer() is
> supported on uclibc-ng.
>
> This apply to whole patchset (some tests are already ported to new API).
>
> Kind regards,
> Petr

^ permalink raw reply	[flat|nested] 45+ messages in thread

* [LTP] [PATCH v2 01/10] getitimer02 : Convert getitimer02 to new API
  2021-06-09 17:35   ` [LTP] [PATCH v2 01/10] getitimer02 : Convert getitimer02 to new API Vinay Kumar
                       ` (8 preceding siblings ...)
  2021-06-09 17:36     ` [LTP] [PATCH v2 10/10] shmctl02 :Skipped " Vinay Kumar
@ 2021-06-11 13:41     ` Cyril Hrubis
  2021-06-13 16:43       ` [LTP] [PATCH v3] getitimer02: " Vinay Kumar
  9 siblings, 1 reply; 45+ messages in thread
From: Cyril Hrubis @ 2021-06-11 13:41 UTC (permalink / raw)
  To: ltp

Hi!
>  		/* call with a bad address */
>  		TEST(getitimer(ITIMER_REAL, (struct itimerval *)-1));
>  

Can we please make use of TST_EXP_FAIL() here instead?

> -		if (TEST_RETURN == 0) {
> -			tst_resm(TFAIL, "call failed to produce "
> -				 "expected error - errno = %d - %s",
> -				 TEST_ERRNO, strerror(TEST_ERRNO));
> -			continue;
> +		if (TST_RET == 0) {
> +			tst_res(TFAIL, "call failed to produce "
> +				"expected error - errno = %d - %s",
> +				TST_ERR, strerror(TST_ERR));
>  		}
>  
> -		switch (TEST_ERRNO) {
> +		switch (TST_ERR) {
>  		case EFAULT:
> -			tst_resm(TPASS, "expected failure - errno = %d - %s",
> -				 TEST_ERRNO, strerror(TEST_ERRNO));
> +			tst_res(TPASS, "expected failure - errno = %d - %s",
> +				 TST_ERR, strerror(TST_ERR));
>  			break;
>  		default:
> -			tst_resm(TFAIL, "call failed to produce "
> -				 "expected error - errno = %d - %s",
> -				 TEST_ERRNO, strerror(TEST_ERRNO));
> +			tst_res(TFAIL, "call failed to produce "
> +					"expected error - errno = %d - %s",
> +					TST_ERR, strerror(TST_ERR));

And can we please have a proper indentation here from the start instead
of fixing that in subsequent patches?

> -#endif /* if !defined(UCLINUX) */
> +static struct tst_test test = {
> +			.test_all = verify_getitimer,
> +			.needs_root = 1,

And here as well.

-- 
Cyril Hrubis
chrubis@suse.cz

^ permalink raw reply	[flat|nested] 45+ messages in thread

* [LTP] [PATCH v2 02/10] getitimer02: Skipped EFAULT tests for libc variant.
  2021-06-09 17:35     ` [LTP] [PATCH v2 02/10] getitimer02: Skipped EFAULT tests for libc variant Vinay Kumar
@ 2021-06-11 13:43       ` Cyril Hrubis
  2021-06-13 16:54         ` [LTP] [PATCH v3] " Vinay Kumar
  0 siblings, 1 reply; 45+ messages in thread
From: Cyril Hrubis @ 2021-06-11 13:43 UTC (permalink / raw)
  To: ltp

Hi!
What is the point of adding test variants when the test does only EFAULT
test that ends up being skipped on the libc variant?

Can't we simply just switch to the syscall here instead?

-- 
Cyril Hrubis
chrubis@suse.cz

^ permalink raw reply	[flat|nested] 45+ messages in thread

* [LTP] [PATCH v2 03/10] getrusage02: Convert getrusage02 to new API
  2021-06-09 17:35     ` [LTP] [PATCH v2 03/10] getrusage02: Convert getrusage02 to new API Vinay Kumar
@ 2021-06-11 13:49       ` Cyril Hrubis
  2021-06-13 17:12         ` [LTP] [PATCH v3] " Vinay Kumar
  0 siblings, 1 reply; 45+ messages in thread
From: Cyril Hrubis @ 2021-06-11 13:49 UTC (permalink / raw)
  To: ltp

Hi!
>  #ifndef RUSAGE_BOTH		/* Removed from user space on RHEL4 */
>  #define RUSAGE_BOTH (-2)	/* still works on SuSE      */
>  #endif /* so this is a work around */

This is used as invalid value here, so this whole part looks wrong.

Can we just place -2 in the testcases structure instead?

> -static void setup();
> -static void cleanup();
> -
> -char *TCID = "getrusage02";
> -
>  static struct rusage usage;
>  
>  struct test_cases_t {
> @@ -90,56 +33,25 @@ struct test_cases_t {
>  } test_cases[] = {
>  	{
>  	RUSAGE_BOTH, &usage, EINVAL},
> -#ifndef UCLINUX
>  	{
>  	RUSAGE_SELF, (struct rusage *)-1, EFAULT}
> -#endif
>  };
>  
> -int TST_TOTAL = ARRAY_SIZE(test_cases);
> -
> -int main(int ac, char **av)
> +static void verify_getrusage(unsigned int i)
>  {
> -
> -	int lc, i;
> -
> -	tst_parse_opts(ac, av, NULL, NULL);
> -
> -	setup();
> -
> -	for (lc = 0; TEST_LOOPING(lc); lc++) {
> -
> -		tst_count = 0;
> -
> -		for (i = 0; i < TST_TOTAL; i++) {
> -			TEST(getrusage(test_cases[i].who, test_cases[i].usage));
> -
> -			if (TEST_RETURN == -1 &&
> -			    TEST_ERRNO == test_cases[i].exp_errno)
> -				tst_resm(TPASS | TTERRNO,
> -					 "getrusage failed as expected");
> -			else
> -				tst_resm(TFAIL | TTERRNO,
> -					 "getrusage failed unexpectedly");
> -		}
> -	}
> -
> -	cleanup();
> -
> -	tst_exit();
> -
> +		TEST(getrusage(test_cases[i].who, test_cases[i].usage));
> +
> +		if (TST_RET == -1 &&
> +		    TST_ERR == test_cases[i].exp_errno)
> +			tst_res(TPASS | TTERRNO,
> +				"getrusage failed as expected");
> +		else
> +			tst_res(TFAIL | TTERRNO,
> +				"getrusage failed unexpectedly");

Here as well, can we please switch to TST_EXP_FAIL()?

>  }
>  
> -void setup(void)
> -{
> -
> -	tst_sig(NOFORK, DEF_HANDLER, cleanup);
> -
> -	TEST_PAUSE;
> -
> -}
> -
> -void cleanup(void)
> -{
> -
> -}
> +static struct tst_test test = {
> +	.test = verify_getrusage,
> +	.tcnt = ARRAY_SIZE(test_cases),
> +	.needs_root = 1,

Do we really need root for this test?

The original test works fine when executed as a user.

> +};
> -- 
> 2.17.1
> 
> 
> -- 
> Mailing list info: https://lists.linux.it/listinfo/ltp

-- 
Cyril Hrubis
chrubis@suse.cz

^ permalink raw reply	[flat|nested] 45+ messages in thread

* [LTP] [PATCH v2 04/10] getrusage02: Skipped EFAULT tests for libc variant.
  2021-06-09 17:35     ` [LTP] [PATCH v2 04/10] getrusage02: Skipped EFAULT tests for libc variant Vinay Kumar
@ 2021-06-11 13:50       ` Cyril Hrubis
  2021-06-13 17:16         ` [LTP] [PATCH v3] " Vinay Kumar
  0 siblings, 1 reply; 45+ messages in thread
From: Cyril Hrubis @ 2021-06-11 13:50 UTC (permalink / raw)
  To: ltp

Hi!
This looks good, but the patch it builds on needs changes.

-- 
Cyril Hrubis
chrubis@suse.cz

^ permalink raw reply	[flat|nested] 45+ messages in thread

* [LTP] [PATCH v2 05/10] setitimer02: Convert setitimer02 to new API
  2021-06-09 17:35     ` [LTP] [PATCH v2 05/10] setitimer02: Convert setitimer02 to new API Vinay Kumar
@ 2021-06-11 13:57       ` Cyril Hrubis
  2021-06-13 17:30         ` [LTP] [PATCH v3] " Vinay Kumar
  0 siblings, 1 reply; 45+ messages in thread
From: Cyril Hrubis @ 2021-06-11 13:57 UTC (permalink / raw)
  To: ltp

Hi!
> +static void verify_setitimer(void)
>  {
> -	int lc;
>  	struct itimerval *value;
>  
> -	tst_parse_opts(ac, av, NULL, NULL);
> -
> -	setup();		/* global setup */
> -
> -	/* The following loop checks looping state if -i option given */
> -
> -	for (lc = 0; TEST_LOOPING(lc); lc++) {
> -		/* reset tst_count in case we are looping */
> -		tst_count = 0;
> -
> -		/* allocate some space for a timer structure */
> -		if ((value = malloc((size_t)sizeof(struct itimerval))) ==
> -		    NULL) {
> -			tst_brkm(TBROK, cleanup, "value malloc failed");
> -		}
> -
> -		/* set up some reasonable values */
> -
> -		value->it_value.tv_sec = 30;
> -		value->it_value.tv_usec = 0;
> -		value->it_interval.tv_sec = 0;
> -		value->it_interval.tv_usec = 0;
> -		/*
> -		 * issue the system call with the TEST() macro
> -		 * ITIMER_REAL = 0, ITIMER_VIRTUAL = 1 and ITIMER_PROF = 2
> -		 */
> -
> -		/* call with a bad address */
> -		TEST(setitimer(ITIMER_REAL, value, (struct itimerval *)-1));
> -
> -		if (TEST_RETURN == 0) {
> -			tst_resm(TFAIL, "call failed to produce EFAULT error "
> -				 "- errno = %d - %s", TEST_ERRNO,
> -				 strerror(TEST_ERRNO));
> -			continue;
> -		}
> -
> -		switch (TEST_ERRNO) {
> -		case EFAULT:
> -			tst_resm(TPASS, "expected failure - errno = %d - %s",
> -				 TEST_ERRNO, strerror(TEST_ERRNO));
> -			break;
> -		default:
> -			tst_resm(TFAIL, "call failed to produce EFAULT error "
> -				 "- errno = %d - %s", TEST_ERRNO,
> -				 strerror(TEST_ERRNO));
> -		}
> -
> -		/*
> -		 * clean up things in case we are looping
> -		 */
> -		free(value);
> -		value = NULL;
> +	/* allocate some space for a timer structure */
> +	if ((value = malloc((size_t)sizeof(struct itimerval))) ==
> +		NULL) {
> +		tst_brk(TBROK, "value malloc failed");
>  	}

This should be allocated as a guarded buffer and initialized once in the
test setup, see:

https://github.com/linux-test-project/ltp/wiki/C-Test-API#131-guarded-buffers

> -	cleanup();
> -	tst_exit();
> -
> -}
> -
> -#else
> -
> -int main(void)
> -{
> -	tst_resm(TINFO, "test is not available on uClinux");
> -	tst_exit();
> -}
> -
> -#endif /* if !defined(UCLINUX) */
> -
> -/*
> - * setup() - performs all the ONE TIME setup for this test.
> - */
> -void setup(void)
> -{
> +	/* set up some reasonable values */
> +	value->it_value.tv_sec = 30;
> +	value->it_value.tv_usec = 0;
> +	value->it_interval.tv_sec = 0;
> +	value->it_interval.tv_usec = 0;
> +	/*
> +	 * issue the system call with the TEST() macro
> +	 * ITIMER_REAL = 0, ITIMER_VIRTUAL = 1 and ITIMER_PROF = 2
> +	 */
> +
> +	/* call with a bad address */
> +	TEST(setitimer(ITIMER_REAL, value, (struct itimerval *)-1));
> +
> +	if (TST_RET == 0) {
> +		tst_res(TFAIL, "call failed to produce EFAULT error "
> +			"- errno = %d - %s", TST_ERR,
> +			strerror(TST_ERR));
> +	}
>  
> -	tst_sig(NOFORK, DEF_HANDLER, cleanup);
> +	switch (TST_ERR) {
> +	case EFAULT:
> +		tst_res(TPASS, "expected failure - errno = %d - %s",
> +			TST_ERR, strerror(TST_ERR));
> +		break;
> +	default:
> +		tst_res(TFAIL, "call failed to produce EFAULT error "
> +			"- errno = %d - %s", TST_ERR,
> +			strerror(TST_ERR));
> +	}
>  
> -	TEST_PAUSE;
> +	/*
> +	 * clean up things in case we are looping
> +	 */
> +	free(value);
> +	value = NULL;

Here as well, we should switch to TST_EXP_FAIL()

>  }
>  
> -/*
> - * cleanup() - performs all the ONE TIME cleanup for this test at completion
> - * 	       or premature exit.
> - */
> -void cleanup(void)
> -{
> +static struct tst_test test = {
> +	.test_all = verify_setitimer,
> +	.needs_root = 1,

Here as well, no need for the root.

> +};
>  
> -}
> -- 
> 2.17.1
> 
> 
> -- 
> Mailing list info: https://lists.linux.it/listinfo/ltp

-- 
Cyril Hrubis
chrubis@suse.cz

^ permalink raw reply	[flat|nested] 45+ messages in thread

* [LTP] [PATCH v2 06/10] setitimer02: Skipped EFAULT tests for libc variant.
  2021-06-09 17:35     ` [LTP] [PATCH v2 06/10] setitimer02: Skipped EFAULT tests for libc variant Vinay Kumar
@ 2021-06-11 14:00       ` Cyril Hrubis
  2021-06-13 17:35         ` [LTP] [PATCH v3] " Vinay Kumar
  0 siblings, 1 reply; 45+ messages in thread
From: Cyril Hrubis @ 2021-06-11 14:00 UTC (permalink / raw)
  To: ltp

Hi!
Here as well, no need for the variant if the test checks only the EFAULT
error. We can simply switch to the syscall variant instead.

-- 
Cyril Hrubis
chrubis@suse.cz

^ permalink raw reply	[flat|nested] 45+ messages in thread

* [LTP] [PATCH v2 07/10] msgctl04: Skipped EFAULT tests for libc variant.
  2021-06-09 17:35     ` [LTP] [PATCH v2 07/10] msgctl04: " Vinay Kumar
@ 2021-06-11 14:13       ` Cyril Hrubis
  0 siblings, 0 replies; 45+ messages in thread
From: Cyril Hrubis @ 2021-06-11 14:13 UTC (permalink / raw)
  To: ltp

Hi!
Pushed with a minor whitespace adjustement, thanks.

-- 
Cyril Hrubis
chrubis@suse.cz

^ permalink raw reply	[flat|nested] 45+ messages in thread

* [LTP] [PATCH v2 09/10] sched_rr_get_interval03: Skipped EFAULT tests for libc variant.
  2021-06-09 17:36     ` [LTP] [PATCH v2 09/10] sched_rr_get_interval03: Skipped " Vinay Kumar
@ 2021-06-11 14:36       ` Cyril Hrubis
  0 siblings, 0 replies; 45+ messages in thread
From: Cyril Hrubis @ 2021-06-11 14:36 UTC (permalink / raw)
  To: ltp

Hi!
Applied, thanks.

-- 
Cyril Hrubis
chrubis@suse.cz

^ permalink raw reply	[flat|nested] 45+ messages in thread

* [LTP] [PATCH v3] getitimer02: Convert getitimer02 to new API
  2021-06-11 13:41     ` [LTP] [PATCH v2 01/10] getitimer02 : Convert getitimer02 to new API Cyril Hrubis
@ 2021-06-13 16:43       ` Vinay Kumar
  2021-06-14 14:19         ` Cyril Hrubis
  0 siblings, 1 reply; 45+ messages in thread
From: Vinay Kumar @ 2021-06-13 16:43 UTC (permalink / raw)
  To: ltp

Signed-off-by: Vinay Kumar <vinay.m.engg@gmail.com>
---
 .../kernel/syscalls/getitimer/getitimer02.c   | 104 +++---------------
 1 file changed, 16 insertions(+), 88 deletions(-)

diff --git a/testcases/kernel/syscalls/getitimer/getitimer02.c b/testcases/kernel/syscalls/getitimer/getitimer02.c
index b9c03143a..2eb3f3a94 100644
--- a/testcases/kernel/syscalls/getitimer/getitimer02.c
+++ b/testcases/kernel/syscalls/getitimer/getitimer02.c
@@ -1,99 +1,27 @@
+// 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
+ * 03/2001 - Written by Wayne Boyer
  */
 
-/*
-  HISTORY
-  03/2001 - Written by Wayne Boyer
-
-  TEST ITEMS:
-  Check that a getitimer() call fails as expected
-  with an incorrect second argument.
-*/
-
-
-#include "test.h"
+/*\
+ *[Description]
+ *
+ * Check that a getitimer() call fails as expected
+ * with an incorrect second argument.
+ */
 
 #include <errno.h>
 #include <sys/time.h>
+#include "tst_test.h"
 
-char *TCID = "getitimer02";
-int TST_TOTAL = 1;
-
-#if !defined(UCLINUX)
-
-static void cleanup(void);
-static void setup(void);
-
-int main(int ac, char **av)
-{
-	int lc;
-
-	tst_parse_opts(ac, av, NULL, NULL);
-
-	setup();
-
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-		tst_count = 0;
-
-		/* call with a bad address */
-		TEST(getitimer(ITIMER_REAL, (struct itimerval *)-1));
-
-		if (TEST_RETURN == 0) {
-			tst_resm(TFAIL, "call failed to produce "
-				 "expected error - errno = %d - %s",
-				 TEST_ERRNO, strerror(TEST_ERRNO));
-			continue;
-		}
-
-		switch (TEST_ERRNO) {
-		case EFAULT:
-			tst_resm(TPASS, "expected failure - errno = %d - %s",
-				 TEST_ERRNO, strerror(TEST_ERRNO));
-			break;
-		default:
-			tst_resm(TFAIL, "call failed to produce "
-				 "expected error - errno = %d - %s",
-				 TEST_ERRNO, strerror(TEST_ERRNO));
-		}
-	}
-
-	cleanup();
-
-	tst_exit();
-}
-
-static void setup(void)
-{
-	tst_sig(NOFORK, DEF_HANDLER, cleanup);
-
-	TEST_PAUSE;
-}
-
-static void cleanup(void)
-{
-}
-
-#else
-
-int main(void)
+static void verify_getitimer(void)
 {
-	tst_resm(TINFO, "test is not available on uClinux");
-	tst_exit();
+	/* call with a bad address */
+	TST_EXP_FAIL(getitimer(ITIMER_REAL, (struct itimerval *)-1),
+		EFAULT, "expected failure - errno = %d - %s", TST_ERR, strerror(TST_ERR));
 }
 
-#endif /* if !defined(UCLINUX) */
+static struct tst_test test = {
+	.test_all = verify_getitimer,
+};
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 45+ messages in thread

* [LTP] [PATCH v3] getitimer02: Skipped EFAULT tests for libc variant.
  2021-06-11 13:43       ` Cyril Hrubis
@ 2021-06-13 16:54         ` Vinay Kumar
  2021-06-14 14:22           ` Cyril Hrubis
  0 siblings, 1 reply; 45+ messages in thread
From: Vinay Kumar @ 2021-06-13 16:54 UTC (permalink / raw)
  To: ltp

Tested EFAULT cases only for "__NR_getitimer" syscall.

Tests for bad addresses in LTP cases trigger segment
fault in libc on a 32bit system.

Signed-off-by: Vinay Kumar <vinay.m.engg@gmail.com>
---
 testcases/kernel/syscalls/getitimer/getitimer02.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/testcases/kernel/syscalls/getitimer/getitimer02.c b/testcases/kernel/syscalls/getitimer/getitimer02.c
index 2eb3f3a94..6039be6f9 100644
--- a/testcases/kernel/syscalls/getitimer/getitimer02.c
+++ b/testcases/kernel/syscalls/getitimer/getitimer02.c
@@ -14,12 +14,20 @@
 #include <errno.h>
 #include <sys/time.h>
 #include "tst_test.h"
+#include "lapi/syscalls.h"
+
+static int sys_getitimer(int which, void *curr_value)
+{
+	return tst_syscall(__NR_getitimer, which, curr_value);
+}
 
 static void verify_getitimer(void)
 {
 	/* call with a bad address */
-	TST_EXP_FAIL(getitimer(ITIMER_REAL, (struct itimerval *)-1),
+	TST_EXP_FAIL(sys_getitimer(ITIMER_REAL, (struct itimerval *)-1),
 		EFAULT, "expected failure - errno = %d - %s", TST_ERR, strerror(TST_ERR));
+
+	tst_res(TCONF, "EFAULT is skipped for libc variant");
 }
 
 static struct tst_test test = {
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 45+ messages in thread

* [LTP] [PATCH v3] getrusage02: Convert getrusage02 to new API
  2021-06-11 13:49       ` Cyril Hrubis
@ 2021-06-13 17:12         ` Vinay Kumar
  0 siblings, 0 replies; 45+ messages in thread
From: Vinay Kumar @ 2021-06-13 17:12 UTC (permalink / raw)
  To: ltp

Signed-off-by: Vinay Kumar <vinay.m.engg@gmail.com>
---
 .../kernel/syscalls/getrusage/getrusage02.c   | 140 +++---------------
 1 file changed, 20 insertions(+), 120 deletions(-)

diff --git a/testcases/kernel/syscalls/getrusage/getrusage02.c b/testcases/kernel/syscalls/getrusage/getrusage02.c
index 8077606a2..9fc5d7dbb 100644
--- a/testcases/kernel/syscalls/getrusage/getrusage02.c
+++ b/testcases/kernel/syscalls/getrusage/getrusage02.c
@@ -1,85 +1,24 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
 /*
  * Copyright (c) Wipro Technologies Ltd, 2002.  All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
+ * AUTHOR : Saji Kumar.V.R <saji.kumar@wipro.com>
  */
-/**********************************************************
- *
- *    TEST IDENTIFIER	: getrusage02
- *
- *    EXECUTED BY	: anyone
- *
- *    TEST TITLE	: Tests for error conditions
- *
- *    TEST CASE TOTAL	: 2
- *
- *    AUTHOR		: Saji Kumar.V.R <saji.kumar@wipro.com>
- *
- *    SIGNALS
- * 	Uses SIGUSR1 to pause before test if option set.
- * 	(See the parse_opts(3) man page).
- *
- *    DESCRIPTION
- *	Verify that
- *	1) getrusage() fails with errno EINVAL when an invalid value
- *	   is given for who
- *	2) getrusage() fails with errno EFAULT when an invalid address
- *	   is given for usage
- *
- * 	Setup:
- * 	  Setup signal handling.
- *	  Pause for SIGUSR1 if option specified.
- *
- * 	Test:
- *	 Loop if the proper options are given.
- * 	  Execute system call
- *	  if call failed with expected errno,
- *		Test Passed
- *	  else
- *		Test Failed
- *
- * 	Cleanup:
- * 	  Print errno log and/or timing stats if options given
+
+/*\
+ *[Description]
  *
- * USAGE:  <for command-line>
- *  getrusage02 [-c n] [-e] [-i n] [-I x] [-P x] [-t] [-h] [-f]
- * 			     [-p]
- *			where,  -c n : Run n copies concurrently.
- *				-e   : Turn on errno logging.
- *				-h   : Show help screen
- *				-f   : Turn off functional testing
- *				-i n : Execute test n times.
- *				-I x : Execute test for x seconds.
- *				-p   : Pause for SIGUSR1 before starting
- *				-P x : Pause for x seconds between iterations.
- *				-t   : Turn on syscall timing.
+ * Verify that
+ * 1) getrusage() fails with errno EINVAL when an invalid value
+ *   is given for who
+ * 2) getrusage() fails with errno EFAULT when an invalid address
+ *   is given for usage
  *
- ****************************************************************/
+ */
 
 #include <errno.h>
 #include <sched.h>
 #include <sys/resource.h>
-#include "test.h"
-
-#ifndef RUSAGE_BOTH		/* Removed from user space on RHEL4 */
-#define RUSAGE_BOTH (-2)	/* still works on SuSE      */
-#endif /* so this is a work around */
-
-static void setup();
-static void cleanup();
-
-char *TCID = "getrusage02";
+#include "tst_test.h"
 
 static struct rusage usage;
 
@@ -89,57 +28,18 @@ struct test_cases_t {
 	int exp_errno;
 } test_cases[] = {
 	{
-	RUSAGE_BOTH, &usage, EINVAL},
-#ifndef UCLINUX
+	-2, &usage, EINVAL},
 	{
 	RUSAGE_SELF, (struct rusage *)-1, EFAULT}
-#endif
 };
 
-int TST_TOTAL = ARRAY_SIZE(test_cases);
-
-int main(int ac, char **av)
+static void verify_getrusage(unsigned int i)
 {
-
-	int lc, i;
-
-	tst_parse_opts(ac, av, NULL, NULL);
-
-	setup();
-
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-
-		tst_count = 0;
-
-		for (i = 0; i < TST_TOTAL; i++) {
-			TEST(getrusage(test_cases[i].who, test_cases[i].usage));
-
-			if (TEST_RETURN == -1 &&
-			    TEST_ERRNO == test_cases[i].exp_errno)
-				tst_resm(TPASS | TTERRNO,
-					 "getrusage failed as expected");
-			else
-				tst_resm(TFAIL | TTERRNO,
-					 "getrusage failed unexpectedly");
-		}
-	}
-
-	cleanup();
-
-	tst_exit();
-
+	TST_EXP_FAIL(getrusage(test_cases[i].who, test_cases[i].usage),
+		test_cases[i].exp_errno, "getrusage failed as expected");
 }
 
-void setup(void)
-{
-
-	tst_sig(NOFORK, DEF_HANDLER, cleanup);
-
-	TEST_PAUSE;
-
-}
-
-void cleanup(void)
-{
-
-}
+static struct tst_test test = {
+	.test = verify_getrusage,
+	.tcnt = ARRAY_SIZE(test_cases),
+};
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 45+ messages in thread

* [LTP] [PATCH v3] getrusage02: Skipped EFAULT tests for libc variant.
  2021-06-11 13:50       ` Cyril Hrubis
@ 2021-06-13 17:16         ` Vinay Kumar
  2021-06-14 14:37           ` Cyril Hrubis
  0 siblings, 1 reply; 45+ messages in thread
From: Vinay Kumar @ 2021-06-13 17:16 UTC (permalink / raw)
  To: ltp

Tested EFAULT cases only for "__NR_getrusage" syscall.

Tests for bad addresses in LTP cases trigger segment
fault in libc on a 32bit system.

Signed-off-by: Vinay Kumar <vinay.m.engg@gmail.com>
---
 .../kernel/syscalls/getrusage/getrusage02.c   | 42 ++++++++++++++++++-
 1 file changed, 41 insertions(+), 1 deletion(-)

diff --git a/testcases/kernel/syscalls/getrusage/getrusage02.c b/testcases/kernel/syscalls/getrusage/getrusage02.c
index 9fc5d7dbb..2dff1a444 100644
--- a/testcases/kernel/syscalls/getrusage/getrusage02.c
+++ b/testcases/kernel/syscalls/getrusage/getrusage02.c
@@ -19,9 +19,20 @@
 #include <sched.h>
 #include <sys/resource.h>
 #include "tst_test.h"
+#include "lapi/syscalls.h"
 
 static struct rusage usage;
 
+static int libc_getrusage(int who, void *usage)
+{
+	return getrusage(who, usage);
+}
+
+static int sys_getrusage(int who, void *usage)
+{
+	return tst_syscall(__NR_getrusage, who, usage);
+}
+
 struct test_cases_t {
 	int who;
 	struct rusage *usage;
@@ -33,13 +44,42 @@ struct test_cases_t {
 	RUSAGE_SELF, (struct rusage *)-1, EFAULT}
 };
 
+static struct test_variants
+{
+	int (*getrusage)(int who, void *usage);
+	char *desc;
+} variants[] = {
+{ .getrusage = libc_getrusage, .desc = "libc getrusage()"},
+
+#if (__NR_getrusage != __LTP__NR_INVALID_SYSCALL)
+{ .getrusage = sys_getrusage,  .desc = "__NR_getrusage syscall"},
+#endif
+};
+
 static void verify_getrusage(unsigned int i)
 {
-	TST_EXP_FAIL(getrusage(test_cases[i].who, test_cases[i].usage),
+	struct test_variants *tv = &variants[tst_variant];
+
+	if (test_cases[i].exp_errno == EFAULT &&
+		tv->getrusage == libc_getrusage) {
+		tst_res(TCONF, "EFAULT is skipped for libc variant");
+		return;
+	}
+
+	TST_EXP_FAIL(tv->getrusage(test_cases[i].who, test_cases[i].usage),
 		test_cases[i].exp_errno, "getrusage failed as expected");
 }
 
+static void setup(void)
+{
+	struct test_variants *tv = &variants[tst_variant];
+
+	tst_res(TINFO, "Testing variant: %s", tv->desc);
+}
+
 static struct tst_test test = {
 	.test = verify_getrusage,
+	.setup = setup,
 	.tcnt = ARRAY_SIZE(test_cases),
+	.test_variants = ARRAY_SIZE(variants),
 };
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 45+ messages in thread

* [LTP] [PATCH v3] setitimer02: Convert setitimer02 to new API
  2021-06-11 13:57       ` Cyril Hrubis
@ 2021-06-13 17:30         ` Vinay Kumar
  2021-06-14 14:44           ` Cyril Hrubis
  0 siblings, 1 reply; 45+ messages in thread
From: Vinay Kumar @ 2021-06-13 17:30 UTC (permalink / raw)
  To: ltp

Signed-off-by: Vinay Kumar <vinay.m.engg@gmail.com>
---
 .../kernel/syscalls/setitimer/setitimer02.c   | 167 +++---------------
 1 file changed, 24 insertions(+), 143 deletions(-)

diff --git a/testcases/kernel/syscalls/setitimer/setitimer02.c b/testcases/kernel/syscalls/setitimer/setitimer02.c
index 4d13cd1e0..59da87e8d 100644
--- a/testcases/kernel/syscalls/setitimer/setitimer02.c
+++ b/testcases/kernel/syscalls/setitimer/setitimer02.c
@@ -1,161 +1,42 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
 /*
+ * Copyright (c) International Business Machines  Corp., 2001
+ * 03/2001 - Written by Wayne Boyer
  *
- *   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
  */
 
-/*
- * NAME
- *	setitimer02.c
- *
- * DESCRIPTION
- *	setitimer02 - check that a setitimer() call fails as expected
- *		      with incorrect values.
+/*\
+ * [Description]
  *
- * ALGORITHM
- *	loop if that option was specified
- *	allocate needed space and set up needed values
- *	issue the system call
- *	check the errno value
- *	  issue a PASS message if we get EFAULT
- *	otherwise, the tests fails
- *	  issue a FAIL message
- *	  break any remaining tests
- *	  call cleanup
- *
- * USAGE:  <for command-line>
- *  setitimer02 [-c n] [-e] [-i n] [-I x] [-P x] [-t]
- *     where,  -c n : Run n copies concurrently.
- *             -e   : Turn on errno logging.
- *	       -i n : Execute test n times.
- *	       -I x : Execute test for x seconds.
- *	       -P x : Pause for x seconds between iterations.
- *	       -t   : Turn on syscall timing.
- *
- * HISTORY
- *	03/2001 - Written by Wayne Boyer
- *
- * RESTRICTIONS
- *	none
+ * setitimer02 - check that a setitimer() call fails as expected
+ *	 with incorrect values.
  */
 
-#include "test.h"
-
 #include <errno.h>
 #include <sys/time.h>
+#include <stdlib.h>
+#include "tst_test.h"
 
-void cleanup(void);
-void setup(void);
-
-char *TCID = "setitimer02";
-int TST_TOTAL = 1;
+struct itimerval *value;
 
-#if !defined(UCLINUX)
-
-int main(int ac, char **av)
+static void verify_setitimer(void)
 {
-	int lc;
-	struct itimerval *value;
-
-	tst_parse_opts(ac, av, NULL, NULL);
-
-	setup();		/* global setup */
-
-	/* The following loop checks looping state if -i option given */
-
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-		/* reset tst_count in case we are looping */
-		tst_count = 0;
-
-		/* allocate some space for a timer structure */
-		if ((value = malloc((size_t)sizeof(struct itimerval))) ==
-		    NULL) {
-			tst_brkm(TBROK, cleanup, "value malloc failed");
-		}
-
-		/* set up some reasonable values */
-
-		value->it_value.tv_sec = 30;
-		value->it_value.tv_usec = 0;
-		value->it_interval.tv_sec = 0;
-		value->it_interval.tv_usec = 0;
-		/*
-		 * issue the system call with the TEST() macro
-		 * ITIMER_REAL = 0, ITIMER_VIRTUAL = 1 and ITIMER_PROF = 2
-		 */
-
-		/* call with a bad address */
-		TEST(setitimer(ITIMER_REAL, value, (struct itimerval *)-1));
-
-		if (TEST_RETURN == 0) {
-			tst_resm(TFAIL, "call failed to produce EFAULT error "
-				 "- errno = %d - %s", TEST_ERRNO,
-				 strerror(TEST_ERRNO));
-			continue;
-		}
-
-		switch (TEST_ERRNO) {
-		case EFAULT:
-			tst_resm(TPASS, "expected failure - errno = %d - %s",
-				 TEST_ERRNO, strerror(TEST_ERRNO));
-			break;
-		default:
-			tst_resm(TFAIL, "call failed to produce EFAULT error "
-				 "- errno = %d - %s", TEST_ERRNO,
-				 strerror(TEST_ERRNO));
-		}
-
-		/*
-		 * clean up things in case we are looping
-		 */
-		free(value);
-		value = NULL;
-	}
-
-	cleanup();
-	tst_exit();
-
-}
-
-#else
-
-int main(void)
-{
-	tst_resm(TINFO, "test is not available on uClinux");
-	tst_exit();
+  /* call with a bad address */
+	TST_EXP_FAIL(setitimer(ITIMER_REAL, value, (struct itimerval *)-1),
+		EFAULT, "expected failure - errno = %d - %s", TST_ERR, strerror(TST_ERR));
 }
 
-#endif /* if !defined(UCLINUX) */
-
-/*
- * setup() - performs all the ONE TIME setup for this test.
- */
-void setup(void)
+static void setup(void)
 {
+	value = tst_alloc((size_t)sizeof(struct itimerval));
 
-	tst_sig(NOFORK, DEF_HANDLER, cleanup);
-
-	TEST_PAUSE;
+	value->it_value.tv_sec = 30;
+	value->it_value.tv_usec = 0;
+	value->it_interval.tv_sec = 0;
+	value->it_interval.tv_usec = 0;
 }
 
-/*
- * cleanup() - performs all the ONE TIME cleanup for this test at completion
- * 	       or premature exit.
- */
-void cleanup(void)
-{
-
-}
+static struct tst_test test = {
+	.test_all = verify_setitimer,
+	.setup = setup,
+};
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 45+ messages in thread

* [LTP] [PATCH v3] setitimer02: Skipped EFAULT tests for libc variant.
  2021-06-11 14:00       ` Cyril Hrubis
@ 2021-06-13 17:35         ` Vinay Kumar
  2021-06-14 14:47           ` Cyril Hrubis
  0 siblings, 1 reply; 45+ messages in thread
From: Vinay Kumar @ 2021-06-13 17:35 UTC (permalink / raw)
  To: ltp

Tested EFAULT cases only for "__NR_setitimer" syscall.

Tests for bad addresses in LTP cases trigger segment
fault in libc on a 32bit system.

Signed-off-by: Vinay Kumar <vinay.m.engg@gmail.com>
---
 testcases/kernel/syscalls/setitimer/setitimer02.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/testcases/kernel/syscalls/setitimer/setitimer02.c b/testcases/kernel/syscalls/setitimer/setitimer02.c
index 59da87e8d..2ff051e41 100644
--- a/testcases/kernel/syscalls/setitimer/setitimer02.c
+++ b/testcases/kernel/syscalls/setitimer/setitimer02.c
@@ -16,14 +16,22 @@
 #include <sys/time.h>
 #include <stdlib.h>
 #include "tst_test.h"
+#include "lapi/syscalls.h"
 
 struct itimerval *value;
 
+static int sys_setitimer(int which, void *new_value, void *old_value)
+{
+	return tst_syscall(__NR_setitimer, which, new_value, old_value);
+}
+
 static void verify_setitimer(void)
 {
   /* call with a bad address */
-	TST_EXP_FAIL(setitimer(ITIMER_REAL, value, (struct itimerval *)-1),
+	TST_EXP_FAIL(sys_setitimer(ITIMER_REAL, value, (struct itimerval *)-1),
 		EFAULT, "expected failure - errno = %d - %s", TST_ERR, strerror(TST_ERR));
+
+	tst_res(TCONF, "EFAULT is skipped for libc variant");
 }
 
 static void setup(void)
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 45+ messages in thread

* [LTP] [PATCH v3] ipc/shmctl02: Make use of TST_EXP_FAIL()
  2021-06-09 17:36     ` [LTP] [PATCH v2 10/10] shmctl02 :Skipped " Vinay Kumar
@ 2021-06-13 17:49       ` Vinay Kumar
  2021-06-14 15:55         ` Vinay Kumar
  2021-06-17 11:40         ` Cyril Hrubis
  2021-06-17 11:38       ` [LTP] [PATCH v2 10/10] shmctl02 :Skipped EFAULT tests for libc variant Cyril Hrubis
  1 sibling, 2 replies; 45+ messages in thread
From: Vinay Kumar @ 2021-06-13 17:49 UTC (permalink / raw)
  To: ltp

In order to simplify the code a bit.

Signed-off-by: Vinay Kumar <vinay.m.engg@gmail.com>
---
 testcases/kernel/syscalls/ipc/shmctl/shmctl02.c | 17 ++---------------
 1 file changed, 2 insertions(+), 15 deletions(-)

diff --git a/testcases/kernel/syscalls/ipc/shmctl/shmctl02.c b/testcases/kernel/syscalls/ipc/shmctl/shmctl02.c
index b9a71722d..9841d3a86 100644
--- a/testcases/kernel/syscalls/ipc/shmctl/shmctl02.c
+++ b/testcases/kernel/syscalls/ipc/shmctl/shmctl02.c
@@ -96,21 +96,8 @@ static void verify_shmctl(unsigned int i)
 		return;
 	}
 
-	TEST(tv->shmctl(*(tc[i].shm_id), tc[i].cmd, tc[i].buf));
-
-	if (TST_RET != -1) {
-		tst_res(TFAIL, "shmctl() returned %li", TST_RET);
-		return;
-	}
-
-	if (TST_ERR == tc[i].error) {
-		tst_res(TPASS | TTERRNO, "shmctl(%i, %i, %p)",
-				*tc[i].shm_id, tc[i].cmd, tc[i].buf);
-		return;
-	}
-
-	tst_res(TFAIL | TTERRNO, "shmctl(%i, %i, %p) expected %s",
-		*tc[i].shm_id, tc[i].cmd, tc[i].buf, tst_strerrno(tc[i].error));
+	TST_EXP_FAIL(tv->shmctl(*(tc[i].shm_id), tc[i].cmd, tc[i].buf),
+		tc[i].error, "shmctl(%i, %i, %p)", *(tc[i].shm_id), tc[i].cmd, tc[i].buf);
 }
 
 static void setup(void)
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 45+ messages in thread

* [LTP] [PATCH v3] getitimer02: Convert getitimer02 to new API
  2021-06-13 16:43       ` [LTP] [PATCH v3] getitimer02: " Vinay Kumar
@ 2021-06-14 14:19         ` Cyril Hrubis
  0 siblings, 0 replies; 45+ messages in thread
From: Cyril Hrubis @ 2021-06-14 14:19 UTC (permalink / raw)
  To: ltp

Hi!
Pushed with small changes, thanks.

* Adjusted the docparse comment to be more clear

* I've removed the printf format from TST_EXP_FAIL() since
  in this case the automatic message will be nicer

-- 
Cyril Hrubis
chrubis@suse.cz

^ permalink raw reply	[flat|nested] 45+ messages in thread

* [LTP] [PATCH v3] getitimer02: Skipped EFAULT tests for libc variant.
  2021-06-13 16:54         ` [LTP] [PATCH v3] " Vinay Kumar
@ 2021-06-14 14:22           ` Cyril Hrubis
  0 siblings, 0 replies; 45+ messages in thread
From: Cyril Hrubis @ 2021-06-14 14:22 UTC (permalink / raw)
  To: ltp

Hi!
Adjusted this patch and pushed as well, thanks.

-- 
Cyril Hrubis
chrubis@suse.cz

^ permalink raw reply	[flat|nested] 45+ messages in thread

* [LTP] [PATCH v3] getrusage02: Skipped EFAULT tests for libc variant.
  2021-06-13 17:16         ` [LTP] [PATCH v3] " Vinay Kumar
@ 2021-06-14 14:37           ` Cyril Hrubis
  2021-06-14 15:14             ` Vinay Kumar
  0 siblings, 1 reply; 45+ messages in thread
From: Cyril Hrubis @ 2021-06-14 14:37 UTC (permalink / raw)
  To: ltp

Hi!
Slightly adjusted and pushed, thanks.

-- 
Cyril Hrubis
chrubis@suse.cz

^ permalink raw reply	[flat|nested] 45+ messages in thread

* [LTP] [PATCH v3] setitimer02: Convert setitimer02 to new API
  2021-06-13 17:30         ` [LTP] [PATCH v3] " Vinay Kumar
@ 2021-06-14 14:44           ` Cyril Hrubis
  0 siblings, 0 replies; 45+ messages in thread
From: Cyril Hrubis @ 2021-06-14 14:44 UTC (permalink / raw)
  To: ltp

Hi!
Pushed with small changes, thanks.

* Slightly adjusted the docparse comment

* Switched from malloc to .bufs static declaration in test structure

-- 
Cyril Hrubis
chrubis@suse.cz

^ permalink raw reply	[flat|nested] 45+ messages in thread

* [LTP] [PATCH v3] setitimer02: Skipped EFAULT tests for libc variant.
  2021-06-13 17:35         ` [LTP] [PATCH v3] " Vinay Kumar
@ 2021-06-14 14:47           ` Cyril Hrubis
  0 siblings, 0 replies; 45+ messages in thread
From: Cyril Hrubis @ 2021-06-14 14:47 UTC (permalink / raw)
  To: ltp

Hi!
Slightly adjusted and fixed, thanks.

-- 
Cyril Hrubis
chrubis@suse.cz

^ permalink raw reply	[flat|nested] 45+ messages in thread

* [LTP] [PATCH v3] getrusage02: Skipped EFAULT tests for libc variant.
  2021-06-14 15:14             ` Vinay Kumar
@ 2021-06-14 14:52               ` Cyril Hrubis
  0 siblings, 0 replies; 45+ messages in thread
From: Cyril Hrubis @ 2021-06-14 14:52 UTC (permalink / raw)
  To: ltp

Hi!
> Thanks for your review.
> In your corrections for getrusage02.c need below change.

Sorry for missing that, fix pushed.

-- 
Cyril Hrubis
chrubis@suse.cz

^ permalink raw reply	[flat|nested] 45+ messages in thread

* [LTP] [PATCH v3] getrusage02: Skipped EFAULT tests for libc variant.
  2021-06-14 14:37           ` Cyril Hrubis
@ 2021-06-14 15:14             ` Vinay Kumar
  2021-06-14 14:52               ` Cyril Hrubis
  0 siblings, 1 reply; 45+ messages in thread
From: Vinay Kumar @ 2021-06-14 15:14 UTC (permalink / raw)
  To: ltp

Hi Cyril,

Thanks for your review.
In your corrections for getrusage02.c need below change.

============================
diff --git a/testcases/kernel/syscalls/getrusage/getrusage02.c
b/testcases/kernel/syscalls/getrusage/getrusage02.c
index 24777687c..767663090 100644
--- a/testcases/kernel/syscalls/getrusage/getrusage02.c
+++ b/testcases/kernel/syscalls/getrusage/getrusage02.c
@@ -61,7 +61,7 @@ static void verify_getrusage(unsigned int i)
                return;
        }

-       TST_EXP_FAIL(getrusage(tc[i].who, tc[i].usage), tc[i].exp_errno,
+       TST_EXP_FAIL(tv->getrusage(tc[i].who, tc[i].usage), tc[i].exp_errno,
                     "getrusage(%i, %p)", tc[i].who, tc[i].usage);
 }
============================

Regards,
Vinay

On Mon, Jun 14, 2021 at 8:33 PM Cyril Hrubis <chrubis@suse.cz> wrote:
>
> Hi!
> Slightly adjusted and pushed, thanks.
>
> --
> Cyril Hrubis
> chrubis@suse.cz

^ permalink raw reply related	[flat|nested] 45+ messages in thread

* [LTP] [PATCH v3] ipc/shmctl02: Make use of TST_EXP_FAIL()
  2021-06-13 17:49       ` [LTP] [PATCH v3] ipc/shmctl02: Make use of TST_EXP_FAIL() Vinay Kumar
@ 2021-06-14 15:55         ` Vinay Kumar
  2021-06-17 11:40         ` Cyril Hrubis
  1 sibling, 0 replies; 45+ messages in thread
From: Vinay Kumar @ 2021-06-14 15:55 UTC (permalink / raw)
  To: ltp

Hi Cyril,

Could you please review below test cases changes also,

semctl03.c
https://lists.linux.it/pipermail/ltp/2021-June/023116.html

shmctl02.c
https://lists.linux.it/pipermail/ltp/2021-June/023118.html
https://lists.linux.it/pipermail/ltp/2021-June/023166.html

Regards,
Vinay

On Sun, Jun 13, 2021 at 11:19 PM Vinay Kumar <vinay.m.engg@gmail.com> wrote:
>
> In order to simplify the code a bit.
>
> Signed-off-by: Vinay Kumar <vinay.m.engg@gmail.com>
> ---
>  testcases/kernel/syscalls/ipc/shmctl/shmctl02.c | 17 ++---------------
>  1 file changed, 2 insertions(+), 15 deletions(-)
>
> diff --git a/testcases/kernel/syscalls/ipc/shmctl/shmctl02.c b/testcases/kernel/syscalls/ipc/shmctl/shmctl02.c
> index b9a71722d..9841d3a86 100644
> --- a/testcases/kernel/syscalls/ipc/shmctl/shmctl02.c
> +++ b/testcases/kernel/syscalls/ipc/shmctl/shmctl02.c
> @@ -96,21 +96,8 @@ static void verify_shmctl(unsigned int i)
>                 return;
>         }
>
> -       TEST(tv->shmctl(*(tc[i].shm_id), tc[i].cmd, tc[i].buf));
> -
> -       if (TST_RET != -1) {
> -               tst_res(TFAIL, "shmctl() returned %li", TST_RET);
> -               return;
> -       }
> -
> -       if (TST_ERR == tc[i].error) {
> -               tst_res(TPASS | TTERRNO, "shmctl(%i, %i, %p)",
> -                               *tc[i].shm_id, tc[i].cmd, tc[i].buf);
> -               return;
> -       }
> -
> -       tst_res(TFAIL | TTERRNO, "shmctl(%i, %i, %p) expected %s",
> -               *tc[i].shm_id, tc[i].cmd, tc[i].buf, tst_strerrno(tc[i].error));
> +       TST_EXP_FAIL(tv->shmctl(*(tc[i].shm_id), tc[i].cmd, tc[i].buf),
> +               tc[i].error, "shmctl(%i, %i, %p)", *(tc[i].shm_id), tc[i].cmd, tc[i].buf);
>  }
>
>  static void setup(void)
> --
> 2.17.1
>

^ permalink raw reply	[flat|nested] 45+ messages in thread

* [LTP] [PATCH v2 08/10] semctl03 :Skipped EFAULT tests for libc variant.
  2021-06-09 17:35     ` [LTP] [PATCH v2 08/10] semctl03 :Skipped " Vinay Kumar
@ 2021-06-17 11:34       ` Cyril Hrubis
  0 siblings, 0 replies; 45+ messages in thread
From: Cyril Hrubis @ 2021-06-17 11:34 UTC (permalink / raw)
  To: ltp

Hi!
> +	TST_EXP_FAIL(sys_semctl(*(tc->sem_id), 0, tc->ipc_cmd, *(tc->buf)),
                     ^
		     Fixed this to tv->semctl

And adjusted a few whitespaces and pushed, thanks.

-- 
Cyril Hrubis
chrubis@suse.cz

^ permalink raw reply	[flat|nested] 45+ messages in thread

* [LTP] [PATCH v2 10/10] shmctl02 :Skipped EFAULT tests for libc variant.
  2021-06-09 17:36     ` [LTP] [PATCH v2 10/10] shmctl02 :Skipped " Vinay Kumar
  2021-06-13 17:49       ` [LTP] [PATCH v3] ipc/shmctl02: Make use of TST_EXP_FAIL() Vinay Kumar
@ 2021-06-17 11:38       ` Cyril Hrubis
  1 sibling, 0 replies; 45+ messages in thread
From: Cyril Hrubis @ 2021-06-17 11:38 UTC (permalink / raw)
  To: ltp

Hi!
Adjusted a few whitespaces and pushed, thanks.

-- 
Cyril Hrubis
chrubis@suse.cz

^ permalink raw reply	[flat|nested] 45+ messages in thread

* [LTP] [PATCH v3] ipc/shmctl02: Make use of TST_EXP_FAIL()
  2021-06-13 17:49       ` [LTP] [PATCH v3] ipc/shmctl02: Make use of TST_EXP_FAIL() Vinay Kumar
  2021-06-14 15:55         ` Vinay Kumar
@ 2021-06-17 11:40         ` Cyril Hrubis
  1 sibling, 0 replies; 45+ messages in thread
From: Cyril Hrubis @ 2021-06-17 11:40 UTC (permalink / raw)
  To: ltp

Hi!
Pushed, thanks.

-- 
Cyril Hrubis
chrubis@suse.cz

^ permalink raw reply	[flat|nested] 45+ messages in thread

end of thread, other threads:[~2021-06-17 11:40 UTC | newest]

Thread overview: 45+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-07 10:45 [LTP] [PATCH 1/7] getitimer02: Skipped EFAULT tests for libc variant Vinay Kumar
2021-06-07 10:45 ` [LTP] [PATCH 2/7] getrusage02: " Vinay Kumar
2021-06-07 10:45 ` [LTP] [PATCH 3/7] msgctl04: " Vinay Kumar
2021-06-07 10:45 ` [LTP] [PATCH 4/7] semctl03: " Vinay Kumar
2021-06-07 10:45 ` [LTP] [PATCH 5/7] shmctl02: " Vinay Kumar
2021-06-07 10:45 ` [LTP] [PATCH 6/7] sched_rr_get_interval03: " Vinay Kumar
2021-06-07 10:45 ` [LTP] [PATCH 7/7] setitimer02: " Vinay Kumar
2021-06-08 20:43 ` [LTP] [PATCH 1/7] getitimer02: " Petr Vorel
2021-06-09 17:35   ` [LTP] [PATCH v2 01/10] getitimer02 : Convert getitimer02 to new API Vinay Kumar
2021-06-09 17:35     ` [LTP] [PATCH v2 02/10] getitimer02: Skipped EFAULT tests for libc variant Vinay Kumar
2021-06-11 13:43       ` Cyril Hrubis
2021-06-13 16:54         ` [LTP] [PATCH v3] " Vinay Kumar
2021-06-14 14:22           ` Cyril Hrubis
2021-06-09 17:35     ` [LTP] [PATCH v2 03/10] getrusage02: Convert getrusage02 to new API Vinay Kumar
2021-06-11 13:49       ` Cyril Hrubis
2021-06-13 17:12         ` [LTP] [PATCH v3] " Vinay Kumar
2021-06-09 17:35     ` [LTP] [PATCH v2 04/10] getrusage02: Skipped EFAULT tests for libc variant Vinay Kumar
2021-06-11 13:50       ` Cyril Hrubis
2021-06-13 17:16         ` [LTP] [PATCH v3] " Vinay Kumar
2021-06-14 14:37           ` Cyril Hrubis
2021-06-14 15:14             ` Vinay Kumar
2021-06-14 14:52               ` Cyril Hrubis
2021-06-09 17:35     ` [LTP] [PATCH v2 05/10] setitimer02: Convert setitimer02 to new API Vinay Kumar
2021-06-11 13:57       ` Cyril Hrubis
2021-06-13 17:30         ` [LTP] [PATCH v3] " Vinay Kumar
2021-06-14 14:44           ` Cyril Hrubis
2021-06-09 17:35     ` [LTP] [PATCH v2 06/10] setitimer02: Skipped EFAULT tests for libc variant Vinay Kumar
2021-06-11 14:00       ` Cyril Hrubis
2021-06-13 17:35         ` [LTP] [PATCH v3] " Vinay Kumar
2021-06-14 14:47           ` Cyril Hrubis
2021-06-09 17:35     ` [LTP] [PATCH v2 07/10] msgctl04: " Vinay Kumar
2021-06-11 14:13       ` Cyril Hrubis
2021-06-09 17:35     ` [LTP] [PATCH v2 08/10] semctl03 :Skipped " Vinay Kumar
2021-06-17 11:34       ` Cyril Hrubis
2021-06-09 17:36     ` [LTP] [PATCH v2 09/10] sched_rr_get_interval03: Skipped " Vinay Kumar
2021-06-11 14:36       ` Cyril Hrubis
2021-06-09 17:36     ` [LTP] [PATCH v2 10/10] shmctl02 :Skipped " Vinay Kumar
2021-06-13 17:49       ` [LTP] [PATCH v3] ipc/shmctl02: Make use of TST_EXP_FAIL() Vinay Kumar
2021-06-14 15:55         ` Vinay Kumar
2021-06-17 11:40         ` Cyril Hrubis
2021-06-17 11:38       ` [LTP] [PATCH v2 10/10] shmctl02 :Skipped EFAULT tests for libc variant Cyril Hrubis
2021-06-11 13:41     ` [LTP] [PATCH v2 01/10] getitimer02 : Convert getitimer02 to new API Cyril Hrubis
2021-06-13 16:43       ` [LTP] [PATCH v3] getitimer02: " Vinay Kumar
2021-06-14 14:19         ` Cyril Hrubis
2021-06-09 17:38   ` [LTP] [PATCH 1/7] getitimer02: Skipped EFAULT tests for libc variant Vinay Kumar

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.