diff mbox series

[3/4] syscalls/getpgid01: Replace TINFO with TPASS or TFAIL

Message ID 20210429125237.31461-1-zhaogongyi@huawei.com
State Accepted
Headers show
Series [1/4] syscalls/writev: Replace TINFO with TPASS or TFAIL | expand

Commit Message

Zhao Gongyi April 29, 2021, 12:52 p.m. UTC
1)remove fail flag
2)remove redundant log
3)replace TINFO with TPASS or TFAIL

Signed-off-by: Zhao Gongyi <zhaogongyi@huawei.com>
---
 testcases/kernel/syscalls/getpgid/getpgid01.c | 74 ++++---------------
 1 file changed, 13 insertions(+), 61 deletions(-)

--
2.17.1

Comments

Cyril Hrubis April 30, 2021, 1:12 p.m. UTC | #1
Hi!
I've applied the patch since ti makes the code better but the test is
still completely broken.

The problem is that the whole test is being executed in a child process
while the parent does wait() on it but it does not propagate the
failures at all as it just does exit(0) at the end of the parent
process. And there are other subtle bugs in the code.

All in all the easiest way how to fix this would be simply rewriting the
test to the new library where no result propagation has to be done.
diff mbox series

Patch

diff --git a/testcases/kernel/syscalls/getpgid/getpgid01.c b/testcases/kernel/syscalls/getpgid/getpgid01.c
index 9af523d88..060486e7e 100644
--- a/testcases/kernel/syscalls/getpgid/getpgid01.c
+++ b/testcases/kernel/syscalls/getpgid/getpgid01.c
@@ -62,7 +62,7 @@  int main(int ac, char **av)

 	register int pgid_0, pgid_1;
 	register int my_pid, my_ppid;
-	int ex_stat, fail = 0;
+	int ex_stat;

 	tst_parse_opts(ac, av, NULL, NULL);

@@ -77,30 +77,19 @@  int main(int ac, char **av)
 			while ((pgid_0 = wait(&ex_stat)) != -1) ;

 			if (WEXITSTATUS(ex_stat) == 0)
-				tst_resm(TINFO, "%s PASSED", TCID);
+				tst_resm(TPASS, "%s PASSED", TCID);
 			else
-				tst_resm(TINFO, "%s FAILED", TCID);
+				tst_resm(TFAIL, "%s FAILED", TCID);

 			exit(0);
 		}

-		tst_resm(TINFO, "Enter block 1");
-		fail = 0;
-		if ((pgid_0 = getpgid(0)) == -1) {
+		if ((pgid_0 = getpgid(0)) == -1)
 			tst_resm(TFAIL | TERRNO, "getpgid(0) failed");
-			fail = 1;
-		}
-
-		if (fail)
-			tst_resm(TINFO, "Test block 1: getpgid(0) FAILED");
 		else
-			tst_resm(TPASS, "Test block 1: getpgid(0) PASSED");
-		tst_resm(TINFO, "Exit block 1");
+			tst_resm(TPASS, "getpgid(0) PASSED");

 //block2:
-		tst_resm(TINFO, "Enter block 2");
-		fail = 0;
-
 		my_pid = getpid();
 		if ((pgid_1 = getpgid(my_pid)) == -1)
 			tst_resm(TFAIL | TERRNO, "getpgid(%d) failed", my_pid);
@@ -108,20 +97,10 @@  int main(int ac, char **av)
 		if (pgid_0 != pgid_1) {
 			tst_resm(TFAIL, "getpgid(my_pid=%d) != getpgid(0) "
 				 "[%d != %d]", my_pid, pgid_1, pgid_0);
-			fail = 1;
-		}
-		if (fail)
-			tst_resm(TINFO, "Test block 2: getpgid(getpid()) "
-				 "FAILED");
-		else
-			tst_resm(TPASS, "Test block 2: getpgid(getpid()) "
-				 "PASSED");
-		tst_resm(TINFO, "Exit block 2");
+		} else
+			tst_resm(TPASS, "getpgid(getpid()) PASSED");

 //block3:
-		tst_resm(TINFO, "Enter block 3");
-		fail = 0;
-
 		my_ppid = getppid();
 		if ((pgid_1 = getpgid(my_ppid)) == -1)
 			tst_resm(TFAIL | TERRNO, "getpgid(%d) failed", my_ppid);
@@ -129,51 +108,24 @@  int main(int ac, char **av)
 		if (pgid_0 != pgid_1) {
 			tst_resm(TFAIL, "getpgid(%d) != getpgid(0) [%d != %d]",
 				 my_ppid, pgid_1, pgid_0);
-			fail = 1;
-		}
-
-		if (fail) {
-			tst_resm(TINFO, "Test block 3: getpgid(getppid()) "
-				 "FAILED");
-		} else {
-			tst_resm(TPASS, "Test block 3: getpgid(getppid()) "
-				 "PASSED");
-		}
-		tst_resm(TINFO, "Exit block 3");
+		} else
+			tst_resm(TPASS, "getpgid(getppid()) PASSED");

 //block4:
-		tst_resm(TINFO, "Enter block 4");
-		fail = 0;
-
 		if ((pgid_1 = getpgid(pgid_0)) < 0)
 			tst_resm(TFAIL | TERRNO, "getpgid(%d) failed", pgid_0);

 		if (pgid_0 != pgid_1) {
 			tst_resm(TFAIL, "getpgid(%d) != getpgid(0) [%d != %d]",
 				 pgid_0, pgid_1, pgid_0);
-			fail = 1;
-		}
-
-		if (fail)
-			tst_resm(TINFO, "Test block 4: getpgid(1) FAILED");
-		else
-			tst_resm(TPASS, "Test block 4: getpgid(1) PASSED");
-		tst_resm(TINFO, "Exit block 4");
+		} else
+			tst_resm(TPASS, "getpgid(%d) PASSED", pgid_0);

 //block5:
-		tst_resm(TINFO, "Enter block 5");
-		fail = 0;
-
-		if (getpgid(1) < 0) {
+		if (getpgid(1) < 0)
 			tst_resm(TFAIL | TERRNO, "getpgid(1) failed");
-			fail = 1;
-		}
-
-		if (fail)
-			tst_resm(TINFO, "Test block 5: getpgid(1) FAILED");
 		else
-			tst_resm(TPASS, "Test block 5: getpgid(1) PASSED");
-		tst_resm(TINFO, "Exit block 5");
+			tst_resm(TPASS, "getpgid(1) PASSED");
 	}
 	cleanup();
 	tst_exit();