Re: [PATCH] posix: Use unique PID file in tst-spawn3 and tst-spawn3-pidfd
Sam James <[email protected]>
| Newsgroups | gmane.comp.lib.glibc.alpha |
|---|---|
| Organization | Gentoo |
| Message-ID | <[email protected]> |
Florian Weimer <[email protected]> writes: > The test sources are built twice and the two tests may run in parallel. > They cannot use the same PID file. Thanks. Reviewed-by: Sam James <[email protected]> > > --- > posix/tst-spawn3.c | 11 ++++++++--- > 1 file changed, 8 insertions(+), 3 deletions(-) > > diff --git a/posix/tst-spawn3.c b/posix/tst-spawn3.c > index 70a5a8ba49..8b946cbb4d 100644 > --- a/posix/tst-spawn3.c > +++ b/posix/tst-spawn3.c > @@ -30,6 +30,7 @@ > #include <intprops.h> > > #include <support/check.h> > +#include <support/support.h> > #include <support/temp_file.h> > #include <support/xunistd.h> > #include <tst-spawn.h> > @@ -84,8 +85,12 @@ do_test (void) > posix_spawn_file_actions_t a; > TEST_COMPARE (posix_spawn_file_actions_init (&a), 0); > > - /* Executes a /bin/sh echo $$ 2>&1 > ${objpfx}tst-spawn3.pid . */ > - const char pidfile[] = OBJPFX "tst-spawn3.pid"; > + /* Executes a /bin/sh echo $$ 2>&1 > ${objpfx}tst-spawn3-$$.pid . > + Embed this PID into the path because the test is built multiple > + times and can run in parallel. */ > + char *pidfile = xasprintf ("%s/tst-spawn3-%d.pid", > + OBJPFX, (int) getpid ()); > + add_temp_file (pidfile); > TEST_COMPARE (posix_spawn_file_actions_addopen (&a, STDOUT_FILENO, pidfile, > O_WRONLY| O_CREAT | O_TRUNC, > 0644), > @@ -145,7 +150,7 @@ do_test (void) > ssize_t n = read (pidfd, buf, sizeof (buf)); > TEST_VERIFY (n < sizeof buf && n >= 0); > > - xunlink (pidfile); > + free (pidfile); > > /* We only expect to read the PID. */ > char *endp; > > base-commit: 20b13fa08b2831ee67fcc92edf2d89288bcc2c93
signature.asc
(application/pgp-signature, 418 B)
-----BEGIN PGP SIGNATURE----- iQEBBAEWCgCpFiEEJaa7iN2bdkxrVUHCc4QJ9SDfkZAFAmpPu/gbFIAAAAAABAAO bWFudTIsMi41KzEuMTIsMiwyXxSAAAAAAC4AKGlzc3Vlci1mcHJAbm90YXRpb25z Lm9wZW5wZ3AuZmlmdGhob3JzZW1hbi5uZXQyNUE2QkI4OEREOUI3NjRDNkI1NTQx QzI3Mzg0MDlGNTIwREY5MTkwDxxzYW1AZ2VudG9vLm9yZwAKCRBzhAn1IN+RkIE6 AP4p2nq8Hq9ZFJIIP/aicy9vQqR/J0m+EuQ5Z51eZ1JjpgD+LVky1AUZ25AATpVT 5Ac6BHGtOnm/qFxumJXNkB1DJA8= =x/Ip -----END PGP SIGNATURE-----