]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Fix WAIT_FOR_DEBUGGER for container tests.
authorStefan Liebler <stli@linux.ibm.com>
Thu, 28 Sep 2023 10:50:40 +0000 (12:50 +0200)
committerStefan Liebler <stli@linux.ibm.com>
Mon, 16 Oct 2023 07:51:00 +0000 (09:51 +0200)
For container tests, gdb needs to set the sysroot to the corresponding
testroot.root directory.  The assumption was that PIDs < 3 means that
we are running within a container.

Starting with commit 2fe64148a81f0d78050c302f34a6853d21f7cae4
"Allow for unpriviledged nested containers", the default is to use
the PID namespace of the parent.  Thus support_test_main.c does not
recognize our container anymore.

This patch now assumes that we are running inside a container if
test-container.c has set PID_OUTSIDE_CONTAINER and always uses this
PID independent of having a new PID namespace or not.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
support/support_test_main.c

index c20c19e77408b2789fe044bf284d3f24583bc916..f19fce564400b12b9f31d40f7412852666e932a3 100644 (file)
@@ -195,16 +195,14 @@ run_test_function (int argc, char **argv, const struct test_config *config)
       char *gdb_script_name;
       int inside_container = 0;
 
-      mypid = getpid();
-      if (mypid < 3)
+      const char *outside_pid = getenv("PID_OUTSIDE_CONTAINER");
+      if (outside_pid)
        {
-         const char *outside_pid = getenv("PID_OUTSIDE_CONTAINER");
-         if (outside_pid)
-           {
-             mypid = atoi (outside_pid);
-             inside_container = 1;
-           }
+         mypid = atoi (outside_pid);
+         inside_container = 1;
        }
+      else
+       mypid = getpid();
 
       gdb_script_name = (char *) xmalloc (strlen (argv[0]) + strlen (".gdb") + 1);
       sprintf (gdb_script_name, "%s.gdb", argv[0]);