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

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.