]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
support: Add envp argument to support_capture_subprogram
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>
Mon, 6 May 2024 16:18:47 +0000 (13:18 -0300)
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>
Tue, 7 May 2024 15:16:36 +0000 (12:16 -0300)
So tests can specify a list of environment variables.
Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
16 files changed:
elf/tst-audit18.c
elf/tst-audit19b.c
elf/tst-audit22.c
elf/tst-audit23.c
elf/tst-audit25a.c
elf/tst-audit25b.c
elf/tst-glibc-hwcaps-2-cache.c
elf/tst-rtld-run-static.c
elf/tst-tunables-enable_secure.c
elf/tst-tunables.c
support/capture_subprocess.h
support/subprocess.h
support/support_capture_subprocess.c
support/support_subprocess.c
support/tst-support_capture_subprocess.c
sysdeps/x86/tst-hwcap-tunables.c

index 841251dd7003aa7d02f7d5f226c0cf4094ba1a91..cec93e269ca0b4ef234c28bd216e983d18946711 100644 (file)
@@ -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
index 70bfe4eadf5ee84509eede67a784acfee3cd0af6..88d99a416bbe93dd77e71ad0081c510b67d02507 100644 (file)
@@ -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;
index 4e97be3be0c6a2e3b3e88c6f61d170ae5ffae7be..6aa18af948afa9c5b4c2d6191f6e9f8f5e2cae91 100644 (file)
@@ -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
index 32e7c8b2a3129c51557fd8a1b0bae6fa39f3b775..d2640fe8b279a4b167bac1c08b0a9ce65cacf0f7 100644 (file)
@@ -82,7 +82,7 @@ do_test (int argc, char *argv[])
 
   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);
 
   /* The expected la_objopen/la_objclose:
index b209ee820f2f2a02464fe698741465cb448e8cd4..cdd4f2ce2b54d62281d8cf96b967729e8b1f249e 100644 (file)
@@ -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);
 
index 9b8665d5171b7c6b6be6389ee5ffc0221d0252d5..939f4d6188368540d52bd0a1b3ac5086d52be866 100644 (file)
@@ -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);
 
index 81ab44ff78ddbb574a9fb3e5f525956f64d42405..af91476ccafeecff51cdbf2477c7b41d5f205852 100644 (file)
@@ -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);
 
index b2650e85ffbcdc20f0233cf5a8fb038feba3ea60..f05c00eb7b76958b448b81360a39ebd43ec09618 100644 (file)
@@ -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);
index e31e1f7faa1c33f779ff1e6e26f48c16a7577924..f5db1c84e9ddc823b033bdb0f98470e054607149 100644 (file)
@@ -113,7 +113,7 @@ do_test (int argc, char *argv[])
       printf ("[%d] Spawned test for %s\n", i, tests[i].env);
       setenv ("GLIBC_TUNABLES", tests[i].env, 1);
       struct support_capture_subprocess result
-       = support_capture_subprogram (spargv[0], spargv);
+       = support_capture_subprogram (spargv[0], spargv, NULL);
       support_capture_subprocess_check (&result, "tst-tunables-enable_secure",
                                        0, sc_allow_stderr);
       support_capture_subprocess_free (&result);
index dff34ed748b4ae83974c188b0a5fdb6dbccb4274..4884dd09f0ddc505319e04855cadd0337fa632a6 100644 (file)
@@ -396,7 +396,7 @@ do_test (int argc, char *argv[])
              tests[i].value);
       setenv (tests[i].name, tests[i].value, 1);
       struct support_capture_subprocess result
-       = support_capture_subprogram (spargv[0], spargv);
+       = support_capture_subprogram (spargv[0], spargv, NULL);
       support_capture_subprocess_check (&result, "tst-tunables", 0,
                                        sc_allow_stderr);
       support_capture_subprocess_free (&result);
index 1ecbdfe4fc4aa123a6df014a4f3a34a6cbba78c0..93b7245d2a005f23566feef5c02926ea8f8bad3f 100644 (file)
@@ -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 execution is successful, return the exit status of the child
index 8fbb895353d61965a49803e1d85620f97b56697b..8274a2b22bb10296ac9672aa7648de5c7d88ce56 100644 (file)
@@ -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.  */
index ffced8a89fca37a5856eb1a7aa75d56877056646..53847194cbc523a3ee58030b443a931b05a7af25 100644 (file)
@@ -93,13 +93,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;
index a2fef394d42ea4f9dc23745428d095e36de32c24..b692a7f8b178502d0de4f1a6fe94dda9312ae8b0 100644 (file)
@@ -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]);
index 8145548982a935cb6d821569136ac958d3bde605..756fb75d195cdf8a1814aee5cb0654c0a5726a68 100644 (file)
@@ -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
index f6a65b88dea6d9dc1c571b1ad8b54da20c80e208..8589a9fd66917c1ee0d987ea596f889be8297be3 100644 (file)
@@ -133,7 +133,7 @@ do_test (int argc, char *argv[])
       setenv ("GLIBC_TUNABLES", tunable, 1);
 
       struct support_capture_subprocess result
-       = support_capture_subprogram (spargv[0], spargv);
+       = support_capture_subprogram (spargv[0], spargv, NULL);
       support_capture_subprocess_check (&result, "tst-tunables", 0,
                                        sc_allow_stderr);
       support_capture_subprocess_free (&result);