Skip to contentSkip to conversation

clock_getres01: drop case which is passing NULL res parameter

PATCH New Jan Stancek 3 participants 9 messages Aug 9, 2019 – Aug 13, 2019

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/2 clock_getres01: drop case which is passing NULL res parameter

Since commit a9446a906f52 ("lib/vdso/32: Remove inconsistent NULL pointer checks") VDSO treats NULL parameter differently than in syscall.

Drop NULL parameter, subsequent patch will add test variants that test NULL res parameter using syscall.

---
 testcases/kernel/syscalls/clock_getres/clock_getres01.c | 1 -
 1 file changed, 1 deletion(-)
testcases/kernel/syscalls/clock_getres/clock_getres01.c +0 -1
index 15f32310839a..df3e84271ad9 100644
@@ -28,7 +28,6 @@ static struct test_case {
 	{"MONOTONIC", CLOCK_MONOTONIC, &res, 0, 0},
 	{"PROCESS_CPUTIME_ID", CLOCK_PROCESS_CPUTIME_ID, &res, 0, 0},
 	{"THREAD_CPUTIME_ID", CLOCK_THREAD_CPUTIME_ID, &res, 0, 0},
-	{"REALTIME", CLOCK_REALTIME, NULL, 0, 0},
 	{"CLOCK_MONOTONIC_RAW", CLOCK_MONOTONIC_RAW, &res, 0, 0,},
 	{"CLOCK_REALTIME_COARSE", CLOCK_REALTIME_COARSE, &res, 0, 0,},
 	{"CLOCK_MONOTONIC_COARSE", CLOCK_MONOTONIC_COARSE, &res, 0, 0,},
Signature · 1 line
1.8.3.1
#1 lore raw

PATCH v2 2/2 clock_getres01: add test variants

0 - default, could be either VDSO or syscall
1 - syscall with valid res parameter
2 - syscall with NULL res parameter

---
 testcases/kernel/syscalls/clock_getres/clock_getres01.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)
testcases/kernel/syscalls/clock_getres/clock_getres01.c +14 -1
index df3e84271ad9..a4134bc1d3c2 100644
@@ -13,6 +13,7 @@
 #include <errno.h>
 
 #include "tst_test.h"
+#include "lapi/syscalls.h"
 #include "lapi/posix_clocks.h"
 
 static struct timespec res;
@@ -39,7 +40,18 @@ static struct test_case {
 
 static void do_test(unsigned int i)
 {
-	TEST(clock_getres(tcase[i].clk_id, tcase[i].res));
+	switch (tst_variant) {
+	case 0:
+		TEST(clock_getres(tcase[i].clk_id, tcase[i].res));
+		break;
+	case 1:
+		TEST(tst_syscall(__NR_clock_getres, tcase[i].clk_id,
+			tcase[i].res));
+		break;
+	case 2:
+		TEST(tst_syscall(__NR_clock_getres, tcase[i].clk_id, NULL));
+		break;
+	}
 
 	if (TST_RET != tcase[i].ret) {
 		if (TST_ERR == EINVAL) {
@@ -64,4 +76,5 @@ static void do_test(unsigned int i)
 static struct tst_test test = {
 	.test = do_test,
 	.tcnt = ARRAY_SIZE(tcase),
+	.test_variants = 3,
 };
Signature · 1 line
1.8.3.1
#3 lore raw

PATCH v2 2/2 clock_getres01: add test variants

In reply to Jan Stancek

Hi!

Quoted 42 lines

0 - default, could be either VDSO or syscall
1 - syscall with valid res parameter
2 - syscall with NULL res parameter

---
 testcases/kernel/syscalls/clock_getres/clock_getres01.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)
testcases/kernel/syscalls/clock_getres/clock_getres01.c +13 -1
index df3e84271ad9..a4134bc1d3c2 100644
@@ -13,6 +13,7 @@
 #include <errno.h>
 
 #include "tst_test.h"
+#include "lapi/syscalls.h"
 #include "lapi/posix_clocks.h"
 
 static struct timespec res;
@@ -39,7 +40,18 @@ static struct test_case {
 
 static void do_test(unsigned int i)
 {
-	TEST(clock_getres(tcase[i].clk_id, tcase[i].res));
+	switch (tst_variant) {
+	case 0:
+		TEST(clock_getres(tcase[i].clk_id, tcase[i].res));
+		break;
+	case 1:
+		TEST(tst_syscall(__NR_clock_getres, tcase[i].clk_id,
+			tcase[i].res));
+		break;
+	case 2:
+		TEST(tst_syscall(__NR_clock_getres, tcase[i].clk_id, NULL));
+		break;
+	}
 
 	if (TST_RET != tcase[i].ret) {
 		if (TST_ERR == EINVAL) {

testcases/kernel/syscalls/clock_getres/clock_getres01.c static void do_test(unsigned int i) · line 80

Quoted 5 lines
testcases/kernel/syscalls/clock_getres/clock_getres01.c +1 -0
@@ -64,4 +76,5 @@ static void do_test(unsigned int i)
 static struct tst_test test = {
 	.test = do_test,
 	.tcnt = ARRAY_SIZE(tcase),
+	.test_variants = 3,
 };

Can we please print which variant we are about to test from the test setup() as well?

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

PATCH v2 1/2 clock_getres01: drop case which is passing NULL res parameter

In reply to Jan Stancek
Quoted 8 lines · Jan Stancek

Since commit a9446a906f52 ("lib/vdso/32: Remove inconsistent NULL pointer checks") VDSO treats NULL parameter differently than in syscall.

Drop NULL parameter, subsequent patch will add test variants that test NULL res parameter using syscall.

Signature · 2 lines
Regards,
Li Wang
#5 lore raw

PATCH v2 1/2 clock_getres01: drop case which is passing NULL res parameter

In reply to Jan Stancek

Hi!

Quoted 16 lines

Since commit a9446a906f52 ("lib/vdso/32: Remove inconsistent NULL pointer checks") VDSO treats NULL parameter differently than in syscall.

Drop NULL parameter, subsequent patch will add test variants that test NULL res parameter using syscall.

---
 testcases/kernel/syscalls/clock_getres/clock_getres01.c | 1 -
 1 file changed, 1 deletion(-)
testcases/kernel/syscalls/clock_getres/clock_getres01.c +0 -0
index 15f32310839a..df3e84271ad9 100644

testcases/kernel/syscalls/clock_getres/clock_getres01.c static struct test_case { · line 31

Quoted 4 lines
testcases/kernel/syscalls/clock_getres/clock_getres01.c +0 -1
@@ -28,7 +28,6 @@ static struct test_case {
 	{"MONOTONIC", CLOCK_MONOTONIC, &res, 0, 0},
 	{"PROCESS_CPUTIME_ID", CLOCK_PROCESS_CPUTIME_ID, &res, 0, 0},
 	{"THREAD_CPUTIME_ID", CLOCK_THREAD_CPUTIME_ID, &res, 0, 0},
-	{"REALTIME", CLOCK_REALTIME, NULL, 0, 0},

Shouldn't we keep the REALTIME clock here and pass the &res here instead?

Quoted 9 lines
testcases/kernel/syscalls/clock_getres/clock_getres01.c +0 -0
 	{"CLOCK_MONOTONIC_RAW", CLOCK_MONOTONIC_RAW, &res, 0, 0,},
 	{"CLOCK_REALTIME_COARSE", CLOCK_REALTIME_COARSE, &res, 0, 0,},
 	{"CLOCK_MONOTONIC_COARSE", CLOCK_MONOTONIC_COARSE, &res, 0, 0,},
Signature · 5 lines
1.8.3.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
Signature · 2 lines
Cyril Hrubis
[email protected]
#6 lore raw

PATCH v2 1/2 clock_getres01: drop case which is passing NULL res parameter

----- Original Message -----

Quoted 13 lines

Hi!

Quoted 12 lines

Since commit a9446a906f52 ("lib/vdso/32: Remove inconsistent NULL pointer checks")
VDSO treats NULL parameter differently than in syscall.

Drop NULL parameter, subsequent patch will add test variants that test NULL res parameter using syscall.

---
 testcases/kernel/syscalls/clock_getres/clock_getres01.c | 1 -
 1 file changed, 1 deletion(-)
Quoted 13 lines

testcases/kernel/syscalls/clock_getres/clock_getres01.c static struct test_case { · line 31

Quoted 10 lines
testcases/kernel/syscalls/clock_getres/clock_getres01.c +0 -1
index 15f32310839a..df3e84271ad9 100644
@@ -28,7 +28,6 @@ static struct test_case {
 	{"MONOTONIC", CLOCK_MONOTONIC, &res, 0, 0},
 	{"PROCESS_CPUTIME_ID", CLOCK_PROCESS_CPUTIME_ID, &res, 0, 0},
 	{"THREAD_CPUTIME_ID", CLOCK_THREAD_CPUTIME_ID, &res, 0, 0},
-	{"REALTIME", CLOCK_REALTIME, NULL, 0, 0},

Shouldn't we keep the REALTIME clock here and pass the &res here instead?

Test already has that as 1st entry in tcase array:
{"REALTIME", CLOCK_REALTIME, &res, 0, 0},

Quoted 2 lines

Can we please print which variant we are about to test from the test setup() as well?

Sure, I'll add that.

#7 lore raw

PATCH v2 1/2 clock_getres01: drop case which is passing NULL res parameter

Hi!

Quoted 5 lines
Quoted 2 lines

Shouldn't we keep the REALTIME clock here and pass the &res here instead?

Test already has that as 1st entry in tcase array:

   {"REALTIME", CLOCK_REALTIME, &res, 0, 0},

Missed that, sorry.

Quoted 4 lines
Quoted 2 lines

Can we please print which variant we are about to test from the test setup() as well?

Sure, I'll add that.

Consider the patch acked then.

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

PATCH v2 1/2 clock_getres01: drop case which is passing NULL res parameter

----- Original Message -----

Quoted 8 lines

Hi!

Quoted 5 lines
Quoted 2 lines

Shouldn't we keep the REALTIME clock here and pass the &res here instead?

Test already has that as 1st entry in tcase array:

   {"REALTIME", CLOCK_REALTIME, &res, 0, 0},

Missed that, sorry.

Me as well in v1 :-)

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines

Can we please print which variant we are about to test from the test setup() as well?

Sure, I'll add that.

Consider the patch acked then.

Both pushed.

Quoted 5 lines

--
Cyril Hrubis
[email protected]