[prev in list] [next in list] [prev in thread] [next in thread]
List: glibc-cvs
Subject: [glibc/maskray/lld] elf: Fix tests that rely on ld.so.cache for cross-compiling
From: Fangrui Song via Glibc-cvs <glibc-cvs () sourceware ! org>
Date: 2021-01-29 18:29:56
Message-ID: 20210129182956.B1FB03874C1F () sourceware ! org
[Download RAW message or body]
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=a50a080f6b0f958eb30d7520212f25f946ed7f8f
commit a50a080f6b0f958eb30d7520212f25f946ed7f8f
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date: Fri Jan 29 10:30:19 2021 -0300
elf: Fix tests that rely on ld.so.cache for cross-compiling
For configurations with cross-compiling equal to 'maybe' or 'no',
ldconfig will not run and thus the ld.so.cache will not be created
on the container testroot.pristine.
This lead to failures on both tst-glibc-hwcaps-prepend-cache and
tst-ldconfig-ld_so_conf-update on environments where the same
compiler can be used to build different ABIs (powerpc and x86 for
instance).
This patch addas a new test-container hook, ldconfig.run, that
triggers a ldconfig execution prior the test execution.
Checked on x86_64-linux-gnu and i686-linux-gnu.
Diff:
---
.../ldconfig.run | 0
.../ldconfig.run | 0
support/test-container.c | 26 ++++++++++++++++++++++
3 files changed, 26 insertions(+)
diff --git a/elf/tst-glibc-hwcaps-prepend-cache.root/ldconfig.run \
b/elf/tst-glibc-hwcaps-prepend-cache.root/ldconfig.run new file mode 100644
index 0000000000..e69de29bb2
diff --git a/elf/tst-ldconfig-ld_so_conf-update.root/ldconfig.run \
b/elf/tst-ldconfig-ld_so_conf-update.root/ldconfig.run new file mode 100644
index 0000000000..e69de29bb2
diff --git a/support/test-container.c b/support/test-container.c
index 8b6ce86da9..28cc44d9f1 100644
--- a/support/test-container.c
+++ b/support/test-container.c
@@ -45,6 +45,7 @@
#include <support/support.h>
#include <support/xunistd.h>
+#include <support/capture_subprocess.h>
#include "check.h"
#include "test-driver.h"
@@ -83,6 +84,7 @@ int verbose = 0;
* copy support files and test binary
* chroot/unshare
* set up any mounts (like /proc)
+ * run ldconfig
Magic files:
@@ -131,6 +133,9 @@ int verbose = 0;
* mytest.root/postclean.req causes fresh rsync (with delete) after
test if present
+ * mytest.root/ldconfig.run causes ldconfig to be issued prior
+ test execution (to setup the initial ld.so.cache).
+
Note that $srcdir/foo/mytest.script may be used instead of a
$srcdir/foo/mytest.root/mytest.script in the sysroot template, if
there is no other reason for a sysroot.
@@ -684,6 +689,16 @@ check_for_unshare_hints (void)
}
}
+static void
+run_ldconfig (void *x __attribute__((unused)))
+{
+ char *prog = xasprintf ("%s/ldconfig", support_install_rootsbindir);
+ char *args[] = { prog, NULL };
+
+ execv (args[0], args);
+ FAIL_EXIT1 ("execv: %m");
+}
+
int
main (int argc, char **argv)
{
@@ -700,6 +715,7 @@ main (int argc, char **argv)
char *command_basename;
char *so_base;
int do_postclean = 0;
+ bool do_ldconfig = false;
char *change_cwd = NULL;
int pipes[2];
@@ -826,6 +842,9 @@ main (int argc, char **argv)
if (file_exists (concat (command_root, "/postclean.req", NULL)))
do_postclean = 1;
+ if (file_exists (concat (command_root, "/ldconfig.run", NULL)))
+ do_ldconfig = true;
+
rsync (pristine_root_path, new_root_path,
file_exists (concat (command_root, "/preclean.req", NULL)));
@@ -1126,6 +1145,13 @@ main (int argc, char **argv)
/* The rest is the child process, which is now PID 1 and "in" the
new root. */
+ if (do_ldconfig)
+ {
+ struct support_capture_subprocess result =
+ support_capture_subprocess (run_ldconfig, NULL);
+ support_capture_subprocess_check (&result, "execv", 0, sc_allow_none);
+ }
+
/* Get our "outside" pid from our parent. We use this to help with
debugging from outside the container. */
read (pipes[0], &child, sizeof(child));
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic