diff mbox series

[rt-tests,v3,26/33] pip_stress: Move test result output to main

Message ID 20210320183829.1318-27-dwagner@suse.de
State New
Headers show
Series JSON cleanups and more tests updated | expand

Commit Message

Daniel Wagner March 20, 2021, 6:38 p.m. UTC
Instead printing the result high() close directly move it to main()
function to simplify the return code if the test fails.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
---
 src/pi_tests/pip_stress.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

Comments

John Kacur May 7, 2021, 4:55 p.m. UTC | #1
On Sat, 20 Mar 2021, Daniel Wagner wrote:

> Instead printing the result high() close directly move it to main()

> function to simplify the return code if the test fails.

> 

> Signed-off-by: Daniel Wagner <dwagner@suse.de>

> ---

>  src/pi_tests/pip_stress.c | 15 +++++++--------

>  1 file changed, 7 insertions(+), 8 deletions(-)

> 

> diff --git a/src/pi_tests/pip_stress.c b/src/pi_tests/pip_stress.c

> index 8b91578f9ab8..2c3288984202 100644

> --- a/src/pi_tests/pip_stress.c

> +++ b/src/pi_tests/pip_stress.c

> @@ -146,6 +146,7 @@ int main(int argc, char *argv[])

>  		exit(1);

>  	} else if (pid1 != 0) {		/* parent code */

>  		low(pid1);

> +		exit(0);

>  	} else {			/* child code */

>  		pid2 = fork();		/* parent code */

>  		if (pid2 == -1) {

> @@ -155,9 +156,15 @@ int main(int argc, char *argv[])

>  			high(pid2);

>  		} else {			/* child code */

>  			medium();

> +			exit(0);

>  		}

>  	}

>  

> +	if (statep->inversion)

> +		printf("Successfully used priority inheritance to handle an inversion\n");

> +	else

> +		printf("No inversion incurred\n");

> +

>  	exit(0);

>  }

>  

> @@ -222,14 +229,6 @@ void high(pid_t pid)

>  	Pthread_mutex_unlock(resource);

>  	kill(pid, SIGKILL);	/* kill the medium thread */

>  	waitpid(pid, &status, 0);

> -

> -	Pthread_mutex_lock(statep->mutex);

> -

> -	if (statep->inversion)

> -		printf("Successfully used priority inheritance to handle an inversion\n");

> -	else

> -		printf("No inversion incurred\n");

> -	Pthread_mutex_unlock(statep->mutex);

>  }

>  

>  /* mmap a page of anonymous shared memory */

> -- 

> 2.30.2

> 

> 

NAK, see comments in the next patch
diff mbox series

Patch

diff --git a/src/pi_tests/pip_stress.c b/src/pi_tests/pip_stress.c
index 8b91578f9ab8..2c3288984202 100644
--- a/src/pi_tests/pip_stress.c
+++ b/src/pi_tests/pip_stress.c
@@ -146,6 +146,7 @@  int main(int argc, char *argv[])
 		exit(1);
 	} else if (pid1 != 0) {		/* parent code */
 		low(pid1);
+		exit(0);
 	} else {			/* child code */
 		pid2 = fork();		/* parent code */
 		if (pid2 == -1) {
@@ -155,9 +156,15 @@  int main(int argc, char *argv[])
 			high(pid2);
 		} else {			/* child code */
 			medium();
+			exit(0);
 		}
 	}
 
+	if (statep->inversion)
+		printf("Successfully used priority inheritance to handle an inversion\n");
+	else
+		printf("No inversion incurred\n");
+
 	exit(0);
 }
 
@@ -222,14 +229,6 @@  void high(pid_t pid)
 	Pthread_mutex_unlock(resource);
 	kill(pid, SIGKILL);	/* kill the medium thread */
 	waitpid(pid, &status, 0);
-
-	Pthread_mutex_lock(statep->mutex);
-
-	if (statep->inversion)
-		printf("Successfully used priority inheritance to handle an inversion\n");
-	else
-		printf("No inversion incurred\n");
-	Pthread_mutex_unlock(statep->mutex);
 }
 
 /* mmap a page of anonymous shared memory */