* [PATCH] Properly run tst-spawn5 directly [BZ #28067]
@ 2021-07-09 13:04 H.J. Lu
2021-07-09 13:13 ` Adhemerval Zanella
0 siblings, 1 reply; 3+ messages in thread
From: H.J. Lu @ 2021-07-09 13:04 UTC (permalink / raw)
To: libc-alpha
Change tst-spawn5.c to handle tst-spawn5 without optional path to ld.so,
--library-path nor the library path when glibc is configured with
--enable-hardcoded-path-in-tests. This fixes BZ #28067.
---
posix/tst-spawn5.c | 30 +++++++++++++++++++-----------
1 file changed, 19 insertions(+), 11 deletions(-)
diff --git a/posix/tst-spawn5.c b/posix/tst-spawn5.c
index 277b848794..8649bb5094 100644
--- a/posix/tst-spawn5.c
+++ b/posix/tst-spawn5.c
@@ -40,6 +40,7 @@ static int restart;
/* Hold the four initial argument used to respawn the process, plus
the extra '--direct' and '--restart', and a final NULL. */
static char *initial_argv[7];
+static int initial_argv_count;
#define CMDLINE_OPTIONS \
{ "restart", no_argument, &restart, 1 },
@@ -133,11 +134,16 @@ static void
spawn_closefrom_test (posix_spawn_file_actions_t *fa, int lowfd, int highfd,
int *extrafds, size_t nextrafds)
{
- /* 6 elements from initial_argv (path to ld.so, '--library-path', the
- path', application name', '--direct', and '--restart'), up to
- 2 * maximum_fd arguments (the expected open file descriptors), plus
- NULL. */
- enum { argv_size = array_length (initial_argv) + 2 * NFDS + 1 };
+ /* 3 or 6 elements from initial_argv:
+ + path to ld.so optional
+ + --library-path optional
+ + the library path optional
+ + application name
+ + --direct
+ + --restart
+ up to 2 * maximum_fd arguments (the expected open file descriptors),
+ plus NULL. */
+ int argv_size = initial_argv_count + 2 * NFDS + 1;
char *args[argv_size];
int argc = 0;
@@ -268,12 +274,14 @@ do_test (int argc, char *argv[])
if (restart)
handle_restart (argc, argv);
- initial_argv[0] = argv[1]; /* path for ld.so */
- initial_argv[1] = argv[2]; /* "--library-path" */
- initial_argv[2] = argv[3]; /* the library path */
- initial_argv[3] = argv[4]; /* the application name */
- initial_argv[4] = (char *) "--direct";
- initial_argv[5] = (char *) "--restart";
+ int i;
+
+ for (i = 0; i < (argc == 5 ? 4 : 1); i++)
+ initial_argv[i] = argv[i + 1];
+ initial_argv[i++] = (char *) "--direct";
+ initial_argv[i++] = (char *) "--restart";
+
+ initial_argv_count = i;
do_test_closefrom ();
--
2.31.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Properly run tst-spawn5 directly [BZ #28067]
2021-07-09 13:04 [PATCH] Properly run tst-spawn5 directly [BZ #28067] H.J. Lu
@ 2021-07-09 13:13 ` Adhemerval Zanella
2021-07-09 13:36 ` [PATCH v2] " H.J. Lu
0 siblings, 1 reply; 3+ messages in thread
From: Adhemerval Zanella @ 2021-07-09 13:13 UTC (permalink / raw)
To: H.J. Lu, libc-alpha
On 09/07/2021 10:04, H.J. Lu wrote:
> Change tst-spawn5.c to handle tst-spawn5 without optional path to ld.so,
> --library-path nor the library path when glibc is configured with
> --enable-hardcoded-path-in-tests. This fixes BZ #28067.
I was about to push a fix for this change, but your were faster.
LGTM, one suggestion below.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
> ---
> posix/tst-spawn5.c | 30 +++++++++++++++++++-----------
> 1 file changed, 19 insertions(+), 11 deletions(-)
>
> diff --git a/posix/tst-spawn5.c b/posix/tst-spawn5.c
> index 277b848794..8649bb5094 100644
> --- a/posix/tst-spawn5.c
> +++ b/posix/tst-spawn5.c
> @@ -40,6 +40,7 @@ static int restart;
> /* Hold the four initial argument used to respawn the process, plus
> the extra '--direct' and '--restart', and a final NULL. */
> static char *initial_argv[7];
> +static int initial_argv_count;
>
> #define CMDLINE_OPTIONS \
> { "restart", no_argument, &restart, 1 },
> @@ -133,11 +134,16 @@ static void
> spawn_closefrom_test (posix_spawn_file_actions_t *fa, int lowfd, int highfd,
> int *extrafds, size_t nextrafds)
> {
> - /* 6 elements from initial_argv (path to ld.so, '--library-path', the
> - path', application name', '--direct', and '--restart'), up to
> - 2 * maximum_fd arguments (the expected open file descriptors), plus
> - NULL. */
> - enum { argv_size = array_length (initial_argv) + 2 * NFDS + 1 };
> + /* 3 or 6 elements from initial_argv:
> + + path to ld.so optional
> + + --library-path optional
> + + the library path optional
> + + application name
> + + --direct
> + + --restart
> + up to 2 * maximum_fd arguments (the expected open file descriptors),
> + plus NULL. */
> + int argv_size = initial_argv_count + 2 * NFDS + 1;
> char *args[argv_size];
> int argc = 0;
>
> @@ -268,12 +274,14 @@ do_test (int argc, char *argv[])
> if (restart)
> handle_restart (argc, argv);
>
> - initial_argv[0] = argv[1]; /* path for ld.so */
> - initial_argv[1] = argv[2]; /* "--library-path" */
> - initial_argv[2] = argv[3]; /* the library path */
> - initial_argv[3] = argv[4]; /* the application name */
> - initial_argv[4] = (char *) "--direct";
> - initial_argv[5] = (char *) "--restart";
> + int i;
> +
> + for (i = 0; i < (argc == 5 ? 4 : 1); i++)
> + initial_argv[i] = argv[i + 1];
I used:
TEST_VERIFY_EXIT (argc == 2 || argc == 5);
int i;
for (i = 0; i < argc - 1; i++)
initial_argv[i] = argv[i + 1];
> + initial_argv[i++] = (char *) "--direct";
> + initial_argv[i++] = (char *) "--restart";
> +
> + initial_argv_count = i;
>
> do_test_closefrom ();
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH v2] Properly run tst-spawn5 directly [BZ #28067]
2021-07-09 13:13 ` Adhemerval Zanella
@ 2021-07-09 13:36 ` H.J. Lu
0 siblings, 0 replies; 3+ messages in thread
From: H.J. Lu @ 2021-07-09 13:36 UTC (permalink / raw)
To: Adhemerval Zanella; +Cc: GNU C Library
[-- Attachment #1: Type: text/plain, Size: 3056 bytes --]
On Fri, Jul 9, 2021 at 6:13 AM Adhemerval Zanella
<adhemerval.zanella@linaro.org> wrote:
>
>
>
> On 09/07/2021 10:04, H.J. Lu wrote:
> > Change tst-spawn5.c to handle tst-spawn5 without optional path to ld.so,
> > --library-path nor the library path when glibc is configured with
> > --enable-hardcoded-path-in-tests. This fixes BZ #28067.
>
> I was about to push a fix for this change, but your were faster.
>
> LGTM, one suggestion below.
>
> Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
>
> > ---
> > posix/tst-spawn5.c | 30 +++++++++++++++++++-----------
> > 1 file changed, 19 insertions(+), 11 deletions(-)
> >
> > diff --git a/posix/tst-spawn5.c b/posix/tst-spawn5.c
> > index 277b848794..8649bb5094 100644
> > --- a/posix/tst-spawn5.c
> > +++ b/posix/tst-spawn5.c
> > @@ -40,6 +40,7 @@ static int restart;
> > /* Hold the four initial argument used to respawn the process, plus
> > the extra '--direct' and '--restart', and a final NULL. */
> > static char *initial_argv[7];
> > +static int initial_argv_count;
> >
> > #define CMDLINE_OPTIONS \
> > { "restart", no_argument, &restart, 1 },
> > @@ -133,11 +134,16 @@ static void
> > spawn_closefrom_test (posix_spawn_file_actions_t *fa, int lowfd, int highfd,
> > int *extrafds, size_t nextrafds)
> > {
> > - /* 6 elements from initial_argv (path to ld.so, '--library-path', the
> > - path', application name', '--direct', and '--restart'), up to
> > - 2 * maximum_fd arguments (the expected open file descriptors), plus
> > - NULL. */
> > - enum { argv_size = array_length (initial_argv) + 2 * NFDS + 1 };
> > + /* 3 or 6 elements from initial_argv:
> > + + path to ld.so optional
> > + + --library-path optional
> > + + the library path optional
> > + + application name
> > + + --direct
> > + + --restart
> > + up to 2 * maximum_fd arguments (the expected open file descriptors),
> > + plus NULL. */
> > + int argv_size = initial_argv_count + 2 * NFDS + 1;
> > char *args[argv_size];
> > int argc = 0;
> >
> > @@ -268,12 +274,14 @@ do_test (int argc, char *argv[])
> > if (restart)
> > handle_restart (argc, argv);
> >
> > - initial_argv[0] = argv[1]; /* path for ld.so */
> > - initial_argv[1] = argv[2]; /* "--library-path" */
> > - initial_argv[2] = argv[3]; /* the library path */
> > - initial_argv[3] = argv[4]; /* the application name */
> > - initial_argv[4] = (char *) "--direct";
> > - initial_argv[5] = (char *) "--restart";
> > + int i;
> > +
> > + for (i = 0; i < (argc == 5 ? 4 : 1); i++)
> > + initial_argv[i] = argv[i + 1];
>
> I used:
>
> TEST_VERIFY_EXIT (argc == 2 || argc == 5);
> int i;
> for (i = 0; i < argc - 1; i++)
> initial_argv[i] = argv[i + 1];
Done.
> > + initial_argv[i++] = (char *) "--direct";
> > + initial_argv[i++] = (char *) "--restart";
> > +
> > + initial_argv_count = i;
> >
> > do_test_closefrom ();
> >
> >
Here is the v3 patch I am checking in.
Thanks.
--
H.J.
[-- Attachment #2: v2-0001-Properly-run-tst-spawn5-directly-BZ-28067.patch --]
[-- Type: text/x-patch, Size: 2617 bytes --]
From b00d8fd645679b3899104f2b7f002a9258559c28 Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Fri, 9 Jul 2021 05:57:51 -0700
Subject: [PATCH v2] Properly run tst-spawn5 directly [BZ #28067]
Change tst-spawn5.c to handle tst-spawn5 without optional path to ld.so,
--library-path nor the library path when glibc is configured with
--enable-hardcoded-path-in-tests. This fixes BZ #28067.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
---
posix/tst-spawn5.c | 32 +++++++++++++++++++++-----------
1 file changed, 21 insertions(+), 11 deletions(-)
diff --git a/posix/tst-spawn5.c b/posix/tst-spawn5.c
index 277b848794..88d8c94c78 100644
--- a/posix/tst-spawn5.c
+++ b/posix/tst-spawn5.c
@@ -40,6 +40,7 @@ static int restart;
/* Hold the four initial argument used to respawn the process, plus
the extra '--direct' and '--restart', and a final NULL. */
static char *initial_argv[7];
+static int initial_argv_count;
#define CMDLINE_OPTIONS \
{ "restart", no_argument, &restart, 1 },
@@ -133,11 +134,16 @@ static void
spawn_closefrom_test (posix_spawn_file_actions_t *fa, int lowfd, int highfd,
int *extrafds, size_t nextrafds)
{
- /* 6 elements from initial_argv (path to ld.so, '--library-path', the
- path', application name', '--direct', and '--restart'), up to
- 2 * maximum_fd arguments (the expected open file descriptors), plus
- NULL. */
- enum { argv_size = array_length (initial_argv) + 2 * NFDS + 1 };
+ /* 3 or 6 elements from initial_argv:
+ + path to ld.so optional
+ + --library-path optional
+ + the library path optional
+ + application name
+ + --direct
+ + --restart
+ up to 2 * maximum_fd arguments (the expected open file descriptors),
+ plus NULL. */
+ int argv_size = initial_argv_count + 2 * NFDS + 1;
char *args[argv_size];
int argc = 0;
@@ -268,12 +274,16 @@ do_test (int argc, char *argv[])
if (restart)
handle_restart (argc, argv);
- initial_argv[0] = argv[1]; /* path for ld.so */
- initial_argv[1] = argv[2]; /* "--library-path" */
- initial_argv[2] = argv[3]; /* the library path */
- initial_argv[3] = argv[4]; /* the application name */
- initial_argv[4] = (char *) "--direct";
- initial_argv[5] = (char *) "--restart";
+ TEST_VERIFY_EXIT (argc == 2 || argc == 5);
+
+ int i;
+
+ for (i = 0; i < argc - 1; i++)
+ initial_argv[i] = argv[i + 1];
+ initial_argv[i++] = (char *) "--direct";
+ initial_argv[i++] = (char *) "--restart";
+
+ initial_argv_count = i;
do_test_closefrom ();
--
2.31.1
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-07-09 13:37 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-09 13:04 [PATCH] Properly run tst-spawn5 directly [BZ #28067] H.J. Lu
2021-07-09 13:13 ` Adhemerval Zanella
2021-07-09 13:36 ` [PATCH v2] " H.J. Lu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).