Skip to contentSkip to conversation

syscalls/pidfd_open: Continue with rest of the tests on failure

PATCH Superseded Viresh Kumar 3 participants 6 messages Feb 25, 2020 – Feb 26, 2020

lore
Share & tools
lore
#0 lore raw

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
index d73b5326b3b1..533270da3dbd 100644
@@ -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
#1 lore raw

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
---
 .../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
index d73b5326b3b1..533270da3dbd 100644
@@ -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]
#2 lore raw

PATCH v2 1/1 syscalls/pidfd_open: Continue with rest of the tests on failure

In reply to Viresh Kumar

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.

---
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
index d73b5326b3b1..9cdded13525a 100644
@@ -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
#3 lore raw

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. 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 +2 -1
index d73b5326b3b1..9cdded13525a 100644
@@ -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 -2
  	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);
#4 lore raw

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);

Sorry, missed that one.

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

PATCH v2 1/1 syscalls/pidfd_open: Continue with rest of the tests on failure

In reply to Viresh Kumar

Hi!

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]