public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Cyril Hrubis <chrubis@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH] waitpid/waitpid10: break test if fork failed
Date: Wed, 13 Apr 2016 14:36:25 +0200	[thread overview]
Message-ID: <20160413123625.GD10941@rei.lan> (raw)
In-Reply-To: <20160413071111.GA26897@localhost.localdomain>

> +static void kill_children();
                           ^
			   missing void
>  static int fail;
> +static int fork_kid_pid[MAXKIDS] = { 0 };
                                        ^
					global variables are
					initialized to 0 automatically,
					no need for explicit
					initialization.

>  #ifdef UCLINUX
>  static char *argv0;
> @@ -92,7 +94,7 @@ int main(int ac, char **av)
>  {
>  	int kid_count, ret_val, status, nkids;
>  	int i, j, k, found;
> -	int fork_kid_pid[MAXKIDS], wait_kid_pid[MAXKIDS];
> +	int wait_kid_pid[MAXKIDS];
>  	int runtime;		/* time(sec) to run this process */
>  
>  	int lc;
> @@ -178,7 +180,8 @@ int main(int ac, char **av)
>  #endif
>  			}
>  			if (ret_val < 0) {
> -				tst_resm(TFAIL, "Fork kid 0 failed. errno = "
> +				tst_brkm(TBROK|TERRNO, cleanup,
> +					 "Fork kid 0 failed. errno = "
>  					 "%d", errno);
>  
>  			}
> @@ -196,8 +199,10 @@ int main(int ac, char **av)
>  #endif
>  			}
>  			if (ret_val < 0) {
> -				tst_resm(TFAIL, "Fork kid 1 failed. errno = "
> -					 "%d", errno);
> +				tst_resm(TBROK|TERRNO, "Fork kid 1 failed");
> +				kill_children();
> +				cleanup();
> +				tst_exit();

This is too ugly. What about killing the children in the test cleanup()
instead and zeroing the array that stores the pids at end of the test
iteration. We have to zero it anyway so that this works correctly when
test is executed with -i or -I. Then we could simply do
tst_brkm(TBROK|TERRNO, cleanup, "fork() failed"); here instead.

-- 
Cyril Hrubis
chrubis@suse.cz

  reply	other threads:[~2016-04-13 12:36 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-13  7:11 [LTP] [PATCH] waitpid/waitpid10: break test if fork failed Han Pingtian
2016-04-13 12:36 ` Cyril Hrubis [this message]
2016-04-14  5:39   ` Han Pingtian
2016-04-19 13:07     ` Cyril Hrubis
2016-04-25  7:41       ` Han Pingtian
2016-05-12  1:30         ` Han Pingtian
2016-05-12 15:07         ` 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=20160413123625.GD10941@rei.lan \
    --to=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