244 lines
10 KiB
Diff
244 lines
10 KiB
Diff
commit 1e1ad714ee9a663eda0e2bffad1d9f258b00a4e9
|
|
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
|
|
Date: Mon May 6 13:18:47 2024 -0300
|
|
|
|
support: Add envp argument to support_capture_subprogram
|
|
|
|
So tests can specify a list of environment variables.
|
|
Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
|
|
|
|
Conflicts:
|
|
elf/tst-tunables.c
|
|
elf/tst-tunables-enable_secure.c
|
|
sysdeps/x86/tst-hwcap-tunables.c
|
|
(files do not exist downstream)
|
|
|
|
diff --git a/elf/tst-audit18.c b/elf/tst-audit18.c
|
|
index 841251dd7003aa7d..cec93e269ca0b4ef 100644
|
|
--- a/elf/tst-audit18.c
|
|
+++ b/elf/tst-audit18.c
|
|
@@ -79,7 +79,7 @@ do_test (int argc, char *argv[])
|
|
|
|
setenv ("LD_AUDIT", "tst-auditmod18.so", 0);
|
|
struct support_capture_subprocess result
|
|
- = support_capture_subprogram (spargv[0], spargv);
|
|
+ = support_capture_subprogram (spargv[0], spargv, NULL);
|
|
support_capture_subprocess_check (&result, "tst-audit18", 0, sc_allow_stderr);
|
|
|
|
struct
|
|
diff --git a/elf/tst-audit19b.c b/elf/tst-audit19b.c
|
|
index 70bfe4eadf5ee845..88d99a416bbe93dd 100644
|
|
--- a/elf/tst-audit19b.c
|
|
+++ b/elf/tst-audit19b.c
|
|
@@ -69,7 +69,7 @@ do_test (int argc, char *argv[])
|
|
|
|
setenv ("LD_AUDIT", "tst-auditmod18b.so", 0);
|
|
struct support_capture_subprocess result
|
|
- = support_capture_subprogram (spargv[0], spargv);
|
|
+ = support_capture_subprogram (spargv[0], spargv, NULL);
|
|
support_capture_subprocess_check (&result, "tst-audit18b", 0, sc_allow_stderr);
|
|
|
|
bool find_symbind = false;
|
|
diff --git a/elf/tst-audit22.c b/elf/tst-audit22.c
|
|
index 4e97be3be0c6a2e3..6aa18af948afa9c5 100644
|
|
--- a/elf/tst-audit22.c
|
|
+++ b/elf/tst-audit22.c
|
|
@@ -83,7 +83,7 @@ do_test (int argc, char *argv[])
|
|
|
|
setenv ("LD_AUDIT", "tst-auditmod22.so", 0);
|
|
struct support_capture_subprocess result
|
|
- = support_capture_subprogram (spargv[0], spargv);
|
|
+ = support_capture_subprogram (spargv[0], spargv, NULL);
|
|
support_capture_subprocess_check (&result, "tst-audit22", 0, sc_allow_stderr);
|
|
|
|
/* The respawned process should always print the vDSO address (otherwise it
|
|
diff --git a/elf/tst-audit23.c b/elf/tst-audit23.c
|
|
index 1b76336595fcd301..7786a74e648aeb6f 100644
|
|
--- a/elf/tst-audit23.c
|
|
+++ b/elf/tst-audit23.c
|
|
@@ -87,7 +87,7 @@ do_one_test (int argc, char *argv[], bool pass_dlclose_flag)
|
|
|
|
setenv ("LD_AUDIT", "tst-auditmod23.so", 0);
|
|
struct support_capture_subprocess result
|
|
- = support_capture_subprogram (spargv[0], spargv);
|
|
+ = support_capture_subprogram (spargv[0], spargv, NULL);
|
|
support_capture_subprocess_check (&result, "tst-audit22", 0, sc_allow_stderr);
|
|
|
|
{
|
|
diff --git a/elf/tst-audit25a.c b/elf/tst-audit25a.c
|
|
index b209ee820f2f2a02..cdd4f2ce2b54d622 100644
|
|
--- a/elf/tst-audit25a.c
|
|
+++ b/elf/tst-audit25a.c
|
|
@@ -77,7 +77,7 @@ do_test (int argc, char *argv[])
|
|
|
|
{
|
|
struct support_capture_subprocess result
|
|
- = support_capture_subprogram (spargv[0], spargv);
|
|
+ = support_capture_subprogram (spargv[0], spargv, NULL);
|
|
support_capture_subprocess_check (&result, "tst-audit25a", 0,
|
|
sc_allow_stderr);
|
|
|
|
@@ -102,7 +102,7 @@ do_test (int argc, char *argv[])
|
|
{
|
|
setenv ("LD_BIND_NOW", "1", 0);
|
|
struct support_capture_subprocess result
|
|
- = support_capture_subprogram (spargv[0], spargv);
|
|
+ = support_capture_subprogram (spargv[0], spargv, NULL);
|
|
support_capture_subprocess_check (&result, "tst-audit25a", 0,
|
|
sc_allow_stderr);
|
|
|
|
diff --git a/elf/tst-audit25b.c b/elf/tst-audit25b.c
|
|
index 9b8665d5171b7c6b..939f4d6188368540 100644
|
|
--- a/elf/tst-audit25b.c
|
|
+++ b/elf/tst-audit25b.c
|
|
@@ -76,7 +76,7 @@ do_test (int argc, char *argv[])
|
|
|
|
{
|
|
struct support_capture_subprocess result
|
|
- = support_capture_subprogram (spargv[0], spargv);
|
|
+ = support_capture_subprogram (spargv[0], spargv, NULL);
|
|
support_capture_subprocess_check (&result, "tst-audit25a", 0,
|
|
sc_allow_stderr);
|
|
|
|
@@ -102,7 +102,7 @@ do_test (int argc, char *argv[])
|
|
{
|
|
setenv ("LD_BIND_NOW", "1", 0);
|
|
struct support_capture_subprocess result
|
|
- = support_capture_subprogram (spargv[0], spargv);
|
|
+ = support_capture_subprogram (spargv[0], spargv, NULL);
|
|
support_capture_subprocess_check (&result, "tst-audit25a", 0,
|
|
sc_allow_stderr);
|
|
|
|
diff --git a/elf/tst-glibc-hwcaps-2-cache.c b/elf/tst-glibc-hwcaps-2-cache.c
|
|
index 81ab44ff78ddbb57..af91476ccafeecff 100644
|
|
--- a/elf/tst-glibc-hwcaps-2-cache.c
|
|
+++ b/elf/tst-glibc-hwcaps-2-cache.c
|
|
@@ -32,7 +32,7 @@ main (int argc, char **argv)
|
|
/* Run ldconfig to populate the cache. */
|
|
char *command = xasprintf ("%s/ldconfig", support_install_rootsbindir);
|
|
struct support_capture_subprocess result =
|
|
- support_capture_subprogram (command, &((char *) { NULL }));
|
|
+ support_capture_subprogram (command, &((char *) { NULL }), NULL);
|
|
support_capture_subprocess_check (&result, "ldconfig", 0, sc_allow_none);
|
|
free (command);
|
|
|
|
diff --git a/elf/tst-rtld-run-static.c b/elf/tst-rtld-run-static.c
|
|
index b2650e85ffbcdc20..f05c00eb7b76958b 100644
|
|
--- a/elf/tst-rtld-run-static.c
|
|
+++ b/elf/tst-rtld-run-static.c
|
|
@@ -30,7 +30,7 @@ do_test (void)
|
|
{
|
|
char *argv[] = { (char *) "ld.so", ldconfig_path, (char *) "--help", NULL };
|
|
struct support_capture_subprocess cap
|
|
- = support_capture_subprogram (support_objdir_elf_ldso, argv);
|
|
+ = support_capture_subprogram (support_objdir_elf_ldso, argv, NULL);
|
|
support_capture_subprocess_check (&cap, "no --argv0", 0, sc_allow_stdout);
|
|
puts ("info: output without --argv0:");
|
|
puts (cap.out.buffer);
|
|
@@ -46,7 +46,7 @@ do_test (void)
|
|
ldconfig_path, (char *) "--help", NULL
|
|
};
|
|
struct support_capture_subprocess cap
|
|
- = support_capture_subprogram (support_objdir_elf_ldso, argv);
|
|
+ = support_capture_subprogram (support_objdir_elf_ldso, argv, NULL);
|
|
support_capture_subprocess_check (&cap, "with --argv0", 0, sc_allow_stdout);
|
|
puts ("info: output with --argv0:");
|
|
puts (cap.out.buffer);
|
|
diff --git a/support/capture_subprocess.h b/support/capture_subprocess.h
|
|
index 8cbdca3b9dfb41ba..57bb941e7d1e5c84 100644
|
|
--- a/support/capture_subprocess.h
|
|
+++ b/support/capture_subprocess.h
|
|
@@ -35,11 +35,12 @@ struct support_capture_subprocess
|
|
struct support_capture_subprocess support_capture_subprocess
|
|
(void (*callback) (void *), void *closure);
|
|
|
|
-/* Issue FILE with ARGV arguments by using posix_spawn and capture standard
|
|
- output, standard error, and the exit status. The out.buffer and err.buffer
|
|
- are handle as support_capture_subprocess. */
|
|
+/* Issue FILE with ARGV arguments and ENVP environments by using posix_spawn
|
|
+ and capture standard output, standard error, and the exit status. If
|
|
+ ENVP is NULL the current environment variable is used. The out.buffer and
|
|
+ err.buffer are handle by support_capture_subprocess. */
|
|
struct support_capture_subprocess support_capture_subprogram
|
|
- (const char *file, char *const argv[]);
|
|
+ (const char *file, char *const argv[], char *const envp[]);
|
|
|
|
/* Copy the running program into a setgid binary and run it with
|
|
CHILD_ID argument. If the program exits with a non-zero status,
|
|
diff --git a/support/subprocess.h b/support/subprocess.h
|
|
index 8fbb895353d61965..8274a2b22bb10296 100644
|
|
--- a/support/subprocess.h
|
|
+++ b/support/subprocess.h
|
|
@@ -33,10 +33,11 @@ struct support_subprocess
|
|
struct support_subprocess support_subprocess
|
|
(void (*callback) (void *), void *closure);
|
|
|
|
-/* Issue FILE with ARGV arguments by using posix_spawn and return is PID, a
|
|
- pipe redirected to STDOUT, and a pipe redirected to STDERR. */
|
|
+/* Issue FILE with ARGV arguments and ENVP environments by using posix_spawn
|
|
+ and return is PID, a pipe redirected to STDOUT, and a pipe redirected to
|
|
+ STDERR. If ENVP is NULL the current environment variable is used. */
|
|
struct support_subprocess support_subprogram
|
|
- (const char *file, char *const argv[]);
|
|
+ (const char *file, char *const argv[], char *const envp[]);
|
|
|
|
/* Invoke program FILE with ARGV arguments by using posix_spawn and wait for it
|
|
to complete. Return program exit status. */
|
|
diff --git a/support/support_capture_subprocess.c b/support/support_capture_subprocess.c
|
|
index 8dc95f8aa723b6bc..cbc695106483ab54 100644
|
|
--- a/support/support_capture_subprocess.c
|
|
+++ b/support/support_capture_subprocess.c
|
|
@@ -98,13 +98,14 @@ support_capture_subprocess (void (*callback) (void *), void *closure)
|
|
}
|
|
|
|
struct support_capture_subprocess
|
|
-support_capture_subprogram (const char *file, char *const argv[])
|
|
+support_capture_subprogram (const char *file, char *const argv[],
|
|
+ char *const envp[])
|
|
{
|
|
struct support_capture_subprocess result;
|
|
xopen_memstream (&result.out);
|
|
xopen_memstream (&result.err);
|
|
|
|
- struct support_subprocess proc = support_subprogram (file, argv);
|
|
+ struct support_subprocess proc = support_subprogram (file, argv, envp);
|
|
|
|
support_capture_poll (&result, &proc);
|
|
return result;
|
|
diff --git a/support/support_subprocess.c b/support/support_subprocess.c
|
|
index a2fef394d42ea4f9..b692a7f8b178502d 100644
|
|
--- a/support/support_subprocess.c
|
|
+++ b/support/support_subprocess.c
|
|
@@ -69,7 +69,7 @@ support_subprocess (void (*callback) (void *), void *closure)
|
|
}
|
|
|
|
struct support_subprocess
|
|
-support_subprogram (const char *file, char *const argv[])
|
|
+support_subprogram (const char *file, char *const argv[], char *const envp[])
|
|
{
|
|
struct support_subprocess result = support_subprocess_init ();
|
|
|
|
@@ -84,7 +84,8 @@ support_subprogram (const char *file, char *const argv[])
|
|
xposix_spawn_file_actions_addclose (&fa, result.stdout_pipe[1]);
|
|
xposix_spawn_file_actions_addclose (&fa, result.stderr_pipe[1]);
|
|
|
|
- result.pid = xposix_spawn (file, &fa, NULL, argv, environ);
|
|
+ result.pid = xposix_spawn (file, &fa, NULL, argv,
|
|
+ envp == NULL ? environ : envp);
|
|
|
|
xclose (result.stdout_pipe[1]);
|
|
xclose (result.stderr_pipe[1]);
|
|
diff --git a/support/tst-support_capture_subprocess.c b/support/tst-support_capture_subprocess.c
|
|
index 8145548982a935cb..756fb75d195cdf8a 100644
|
|
--- a/support/tst-support_capture_subprocess.c
|
|
+++ b/support/tst-support_capture_subprocess.c
|
|
@@ -238,7 +238,7 @@ do_subprogram (const struct test *test)
|
|
args[argc] = NULL;
|
|
TEST_VERIFY (argc < argv_size);
|
|
|
|
- return support_capture_subprogram (args[0], args);
|
|
+ return support_capture_subprogram (args[0], args, NULL);
|
|
}
|
|
|
|
enum test_type
|