[PATCH] fix posix/tst-spawn test

Florian Weimer fweimer@redhat.com
Thu Oct 12 13:32:00 GMT 2017


On 09/27/2017 04:53 PM, Szabolcs Nagy wrote:
>> Sorry, one more thing: I think you should not interleave the spawns and waits.  I think you can do a -1 wait
>> after the PID wait, and the test will still pass.  This should be closer to the original test.
>>
> why does that matter?

It checks that you can actually launch multiple child processes.

> diff --git a/posix/tst-spawn.c b/posix/tst-spawn.c
> index 08d92bd7a7..4e5e76351c 100644
> --- a/posix/tst-spawn.c
> +++ b/posix/tst-spawn.c
> @@ -23,9 +23,10 @@
>   #include <spawn.h>
>   #include <stdlib.h>
>   #include <string.h>
> -#include <unistd.h>
>   #include <wait.h>
>   #include <sys/param.h>
> +#include <support/check.h>
> +#include <support/xunistd.h>
>   
>   
>   /* Nonzero if the program gets called via `exec'.  */
> @@ -249,13 +250,16 @@ do_test (int argc, char *argv[])
>        error (EXIT_FAILURE, errno, "posix_spawn_file_actions_destroy");
>      free (name3_copy);
>   
> -  /* Wait for the child.  */
> -  if (waitpid (pid, &status, 0) != pid)
> -    error (EXIT_FAILURE, errno, "wrong child");
> +  /* Wait for the children.  */
> +  TEST_VERIFY (xwaitpid (pid, &status, 0) == pid);
> +  TEST_VERIFY (WIFEXITED (status));
> +  TEST_VERIFY (!WIFSIGNALED (status));
> +  TEST_VERIFY (WEXITSTATUS (status) == 0);
>   
> -  if (WTERMSIG (status) != 0)
> -    error (EXIT_FAILURE, 0, "Child terminated incorrectly");
> -  status = WEXITSTATUS (status);
> +  xwaitpid (-1, &status, 0);
> +  TEST_VERIFY (WIFEXITED (status));
> +  TEST_VERIFY (!WIFSIGNALED (status));
> +  TEST_VERIFY (WEXITSTATUS (status) == 0);
>   
> -  return status;
> +  return 0;
>   }

Looks good to me, thanks.

Florian



More information about the Libc-alpha mailing list