[v2,2/2] clock_getres01: add test variants
diff mbox series

Message ID e4c5428276c9a85efc6bddaa2d82e2aed5806108.1565361031.git.jstancek@redhat.com
State Changes Requested
Headers show
Series
  • [v2,1/2] clock_getres01: drop case which is passing NULL res parameter
Related show

Commit Message

Jan Stancek Aug. 9, 2019, 2:31 p.m. UTC
0 - default, could be either VDSO or syscall
1 - syscall with valid res parameter
2 - syscall with NULL res parameter

Signed-off-by: Jan Stancek <jstancek@redhat.com>
---
 testcases/kernel/syscalls/clock_getres/clock_getres01.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

Comments

Li Wang Aug. 12, 2019, 4:52 a.m. UTC | #1
On Fri, Aug 9, 2019 at 10:32 PM Jan Stancek <jstancek@redhat.com> wrote:
>
> 0 - default, could be either VDSO or syscall
> 1 - syscall with valid res parameter
> 2 - syscall with NULL res parameter
>
> Signed-off-by: Jan Stancek <jstancek@redhat.com>
Acked-by: Li Wang <liwang@redhat.com>
Cyril Hrubis Aug. 13, 2019, 12:13 p.m. UTC | #2
Hi!
> 0 - default, could be either VDSO or syscall
> 1 - syscall with valid res parameter
> 2 - syscall with NULL res parameter
> 
> Signed-off-by: Jan Stancek <jstancek@redhat.com>
> ---
>  testcases/kernel/syscalls/clock_getres/clock_getres01.c | 15 ++++++++++++++-
>  1 file changed, 14 insertions(+), 1 deletion(-)
> 
> diff --git a/testcases/kernel/syscalls/clock_getres/clock_getres01.c b/testcases/kernel/syscalls/clock_getres/clock_getres01.c
> index df3e84271ad9..a4134bc1d3c2 100644
> --- a/testcases/kernel/syscalls/clock_getres/clock_getres01.c
> +++ b/testcases/kernel/syscalls/clock_getres/clock_getres01.c
> @@ -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,
>  };

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

Patch
diff mbox series

diff --git a/testcases/kernel/syscalls/clock_getres/clock_getres01.c b/testcases/kernel/syscalls/clock_getres/clock_getres01.c
index df3e84271ad9..a4134bc1d3c2 100644
--- a/testcases/kernel/syscalls/clock_getres/clock_getres01.c
+++ b/testcases/kernel/syscalls/clock_getres/clock_getres01.c
@@ -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,
 };