syscalls/pidfd_open: Continue with rest of the tests on failure
PATCH 1/1 syscalls/pidfd_open: Continue with rest of the tests on failure
With tst_brk(), the tests end immediately while what we want to do here is to test rest of the failure tests. Use tst_res() to report result and continue with rest of the failure tests.
--- .../kernel/syscalls/pidfd_open/pidfd_open02.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-)
testcases/kernel/syscalls/pidfd_open/pidfd_open02.c +7 -9
@@ -35,17 +35,15 @@ static void run(unsigned int n)if (TST_RET !=-1 ) {SAFE_CLOSE (TST_RET ); -tst_brk (TFAIL ,"%s: pidfd_open succeeded unexpectedly (index: %d)" , +tst_res (TFAIL ,"%s: pidfd_open succeeded unexpectedly (index: %d)" , tc->name, n); - } - -if (tc->exp_errno !=TST_ERR ) { -tst_brk (TFAIL |TTERRNO ,"%s: pidfd_open() should fail with %s" , + }else if (tc->exp_errno !=TST_ERR ) { +tst_res (TFAIL |TTERRNO ,"%s: pidfd_open() should fail with %s" , tc->name,tst_strerrno (tc->exp_errno)); - } - -tst_res (TPASS |TTERRNO ,"%s: pidfd_open() failed as expected" , - tc->name); + }else { +tst_res (TPASS |TTERRNO ,"%s: pidfd_open() failed as expected" , + tc->name); + } }static struct tst_test test = {
Signature · 1 line
2.21.0.rc0.269.g1a574e7a288b
PATCH 1/1 syscalls/pidfd_open: Continue with rest of the tests on failure
Hi!
Agree here, also tst_brk(TFAIL, ...) is not working well at this point, see:
https://github.com/linux-test-project/ltp/issues/462
Quoted 14 lines
Signed-off-by Viresh Kumar <[email protected]>--- .../kernel/syscalls/pidfd_open/pidfd_open02.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-)testcases/kernel/syscalls/pidfd_open/pidfd_open02.c +0
-1@@ -35,17 +35,15 @@ static void run(unsigned int n)if (TST_RET !=-1 ) {SAFE_CLOSE (TST_RET ); - tst_brk(TFAIL, "%s: pidfd_open succeeded unexpectedly (index: %d)",
testcases/kernel/syscalls/pidfd_open/pidfd_open02.c static void run(unsigned int n) · line 45
Quoted 10 lines
testcases/kernel/syscalls/pidfd_open/pidfd_open02.c +3
-5+tst_res (TFAIL ,"%s: pidfd_open succeeded unexpectedly (index: %d)" , tc->name, n); - } - -if (tc->exp_errno !=TST_ERR ) { -tst_brk (TFAIL |TTERRNO ,"%s: pidfd_open() should fail with %s" , + }else if (tc->exp_errno !=TST_ERR ) { +tst_res (TFAIL |TTERRNO ,"%s: pidfd_open() should fail with %s" , tc->name,tst_strerrno (tc->exp_errno)); - }
Can we please use return instead of the else if branches?
i.e.
if (...) {
tst_res(TFAIL, ...);
return;
}Quoted 7 lines
testcases/kernel/syscalls/pidfd_open/pidfd_open02.c +4
-2-tst_res (TPASS |TTERRNO ,"%s: pidfd_open() failed as expected" , - tc->name); + }else { +tst_res (TPASS |TTERRNO ,"%s: pidfd_open() failed as expected" , + tc->name); + } }
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH v2 1/1 syscalls/pidfd_open: Continue with rest of the tests on failure
In reply to Viresh KumarWith tst_brk(), the tests end immediately while what we want to do here is to test rest of the failure tests. Use tst_res() to report result and continue with rest of the failure tests.
---
V2: Use return, instead of if/else blocks.
testcases/kernel/syscalls/pidfd_open/pidfd_open02.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
testcases/kernel/syscalls/pidfd_open/pidfd_open02.c +5 -3
@@ -35,14 +35,16 @@ static void run(unsigned int n)if (TST_RET !=-1 ) {SAFE_CLOSE (TST_RET ); -tst_brk (TFAIL ,"%s: pidfd_open succeeded unexpectedly (index: %d)" , +tst_res (TFAIL ,"%s: pidfd_open succeeded unexpectedly (index: %d)" , tc->name, n); +return ; }if (tc->exp_errno !=TST_ERR ) { -tst_brk (TFAIL |TTERRNO ,"%s: pidfd_open() should fail with %s" , +tst_res (TFAIL |TTERRNO ,"%s: pidfd_open() should fail with %s" , tc->name,tst_strerrno (tc->exp_errno)); - } +return ; + }tst_res (TPASS |TTERRNO ,"%s: pidfd_open() failed as expected" , tc->name);
Signature · 1 line
2.21.0.rc0.269.g1a574e7a288b
PATCH v2 1/1 syscalls/pidfd_open: Continue with rest of the tests on failure
Quoted 25 lines · Viresh Kumar
With
tst_brk(), the tests end immediately while what we want to do here is to test rest of the failure tests. Usetst_res()to report result and continue with rest of the failure tests.Signed-off-by Viresh Kumar<[email protected]>---
V2: Use return, instead of if/else blocks.testcases/kernel/syscalls/pidfd_open/pidfd_open02.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)testcases/kernel/syscalls/pidfd_open/pidfd_open02.c +2
-1@@ -35,14 +35,16 @@ static void run(unsigned int n)if (TST_RET !=-1 ) {SAFE_CLOSE (TST_RET ); -tst_brk (TFAIL ,"%s: pidfd_open succeeded unexpectedly (index: %d)" , +tst_res (TFAIL ,"%s: pidfd_open succeeded unexpectedly (index: %d)" , tc->name, n); +return ; }
testcases/kernel/syscalls/pidfd_open/pidfd_open02.c static void run(unsigned int n) · line 50
Quoted 10 lines
testcases/kernel/syscalls/pidfd_open/pidfd_open02.c +3
-2if (tc->exp_errno !=TST_ERR ) { -tst_brk (TFAIL |TTERRNO ,"%s: pidfd_open() should fail with %s" , +tst_res (TFAIL |TTERRNO ,"%s: pidfd_open() should fail with %s" , tc->name,tst_strerrno (tc->exp_errno)); - } +return ; + }tst_res (TPASS |TTERRNO ,"%s: pidfd_open() failed as expected" , tc->name);
PATCH v2 1/1 syscalls/pidfd_open: Continue with rest of the tests on failure
Hi!
Quoted 3 lines
Quoted 2 lines
tst_res(TPASS | TTERRNO, "%s:
pidfd_open()failed as expected",
tc->name);Acked-by Xiao Yang <[email protected]>
Sorry, missed that one.
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH v2 1/1 syscalls/pidfd_open: Continue with rest of the tests on failure
In reply to Viresh KumarHi!
Review
Quoted 2 lines
(quoted diff) +2
-0+ return; + }
^
I've removed this space that I suppose was added accidentally and pushed, thanks.
Signature · 2 lines
Cyril Hrubis [email protected]