Linux Test Project
 help / color / mirror / Atom feed
From: Richard Palethorpe <rpalethorpe@suse.de>
To: Cyril Hrubis <chrubis@suse.cz>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH 2/7] openposix: pthread_spin_init/{2-1,2-2}: Fix
Date: Tue, 05 Jul 2022 06:20:17 +0100	[thread overview]
Message-ID: <8735fgt9t4.fsf@suse.de> (raw)
In-Reply-To: <20220620092146.7604-3-chrubis@suse.cz>


Hello,

Reviewed-by: Richard Palethorpe <rpalethorpe@suse.com>

Cyril Hrubis <chrubis@suse.cz> writes:

> Propagate a failure in child to the parent properly.
>
> Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
> ---
>  .../interfaces/pthread_spin_init/2-1.c        | 20 +++++++++++++++++--
>  .../interfaces/pthread_spin_init/2-2.c        | 20 +++++++++++++++++--
>  2 files changed, 36 insertions(+), 4 deletions(-)
>
> diff --git a/testcases/open_posix_testsuite/conformance/interfaces/pthread_spin_init/2-1.c b/testcases/open_posix_testsuite/conformance/interfaces/pthread_spin_init/2-1.c
> index b7dd9e05e..f20822c50 100644
> --- a/testcases/open_posix_testsuite/conformance/interfaces/pthread_spin_init/2-1.c
> +++ b/testcases/open_posix_testsuite/conformance/interfaces/pthread_spin_init/2-1.c
> @@ -100,7 +100,11 @@ int main(void)
>  	if (pid == -1) {
>  		perror("Error at fork()");
>  		return PTS_UNRESOLVED;
> -	} else if (pid > 0) {
> +	}
> +
> +	if (pid > 0) {
> +		int status;
> +
>  		/* Parent */
>  		/* wait until child writes to spinlock data */
>  		while (spinlock_data->data != 1)
> @@ -116,13 +120,23 @@ int main(void)
>  		spinlock_data->data = 2;
>  
>  		/* Wait until child ends */
> -		wait(NULL);
> +		wait(&status);
>  
>  		if ((shm_unlink(shm_name)) != 0) {
>  			perror("Error at shm_unlink()");
>  			return PTS_UNRESOLVED;
>  		}
>  
> +		if (!WIFEXITED(status)) {
> +			printf("Parent: did not exit properly!\n");
> +			return PTS_FAIL;
> +		}
> +
> +		if (WEXITSTATUS(status)) {
> +			printf("Parent: failure in child\n");
> +			return WEXITSTATUS(status);
> +		}
> +
>  		printf("Test PASSED\n");
>  		return PTS_PASS;
>  	} else {
> @@ -170,5 +184,7 @@ int main(void)
>  			printf("Child: error at pthread_spin_destroy()\n");
>  			return PTS_UNRESOLVED;
>  		}
> +
> +		return PTS_PASS;
>  	}
>  }
> diff --git a/testcases/open_posix_testsuite/conformance/interfaces/pthread_spin_init/2-2.c b/testcases/open_posix_testsuite/conformance/interfaces/pthread_spin_init/2-2.c
> index f3cb9b2a3..df0d4df87 100644
> --- a/testcases/open_posix_testsuite/conformance/interfaces/pthread_spin_init/2-2.c
> +++ b/testcases/open_posix_testsuite/conformance/interfaces/pthread_spin_init/2-2.c
> @@ -106,7 +106,11 @@ int main(void)
>  	if (pid == -1) {
>  		perror("Error at fork()");
>  		return PTS_UNRESOLVED;
> -	} else if (pid > 0) {
> +	}
> +
> +	if (pid > 0) {
> +		int status;
> +
>  		/* Parent */
>  		/* wait until child writes to spinlock data */
>  		while (spinlock_data->data != 1)
> @@ -122,13 +126,23 @@ int main(void)
>  		spinlock_data->data = 2;
>  
>  		/* Wait until child ends */
> -		wait(NULL);
> +		wait(&status);
>  
>  		if ((shm_unlink(shm_name)) != 0) {
>  			perror("Error at shm_unlink()");
>  			return PTS_UNRESOLVED;
>  		}
>  
> +		if (!WIFEXITED(status)) {
> +			printf("Parent: did not exit properly!\n");
> +			return PTS_FAIL;
> +		}
> +
> +		if (WEXITSTATUS(status)) {
> +			printf("Parent: failure in child\n");
> +			return WEXITSTATUS(status);
> +		}
> +
>  		printf("Test PASSED\n");
>  		return PTS_PASS;
>  	} else {
> @@ -175,5 +189,7 @@ int main(void)
>  			printf("Child: error at pthread_spin_destroy()\n");
>  			return PTS_UNRESOLVED;
>  		}
> +
> +		return PTS_PASS;
>  	}
>  }
> -- 
> 2.35.1


-- 
Thank you,
Richard.

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

  reply	other threads:[~2022-07-05  5:20 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-20  9:21 [LTP] [PATCH 0/7] openposix: Fix 'no return in nonvoid function' warnings Cyril Hrubis
2022-06-20  9:21 ` [LTP] [PATCH 1/7] openposix: pthread_rwlockattr_getpshared/2-1: Fix Cyril Hrubis
2022-07-05  5:16   ` Richard Palethorpe
2022-06-20  9:21 ` [LTP] [PATCH 2/7] openposix: pthread_spin_init/{2-1,2-2}: Fix Cyril Hrubis
2022-07-05  5:20   ` Richard Palethorpe [this message]
2022-06-20  9:21 ` [LTP] [PATCH 3/7] openposix: sem_destroy/3-1: Fix Cyril Hrubis
2022-07-05  5:23   ` Richard Palethorpe
2022-06-20  9:21 ` [LTP] [PATCH 4/7] openposix: sem_timedwait/11-1: Fix Cyril Hrubis
2022-06-23  9:57   ` Martin Doucha
2022-07-05  5:34     ` Richard Palethorpe
2022-06-20  9:21 ` [LTP] [PATCH 5/7] openposix: aio_h/2-1: Add return at the end of main() Cyril Hrubis
2022-07-05  5:24   ` Richard Palethorpe
2022-06-20  9:21 ` [LTP] [PATCH 6/7] openposix: mq_timedreceive: Silence warning Cyril Hrubis
2022-07-05  5:25   ` Richard Palethorpe
2022-06-20  9:21 ` [LTP] [PATCH 7/7] opeposix: pthread_barrierattr_getpshared/2-1: Simplify codeflow Cyril Hrubis
2022-06-23 12:38   ` Martin Doucha
2022-07-05  5:35     ` Richard Palethorpe
2022-07-14 13:03     ` Cyril Hrubis
2022-06-23  8:49 ` [LTP] [PATCH 0/7] openposix: Fix 'no return in nonvoid function' warnings Li Wang
2022-07-14 13:05   ` Cyril Hrubis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8735fgt9t4.fsf@suse.de \
    --to=rpalethorpe@suse.de \
    --cc=chrubis@suse.cz \
    --cc=ltp@lists.linux.it \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox