public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] elf: Fix tests that rely on ld.so.cache for cross-compiling
@ 2021-01-29 13:36 Adhemerval Zanella
  2021-01-29 13:40 ` Florian Weimer
  2021-01-29 21:23 ` DJ Delorie
  0 siblings, 2 replies; 7+ messages in thread
From: Adhemerval Zanella @ 2021-01-29 13:36 UTC (permalink / raw)
  To: libc-alpha; +Cc: Florian Weimer, Szabolcs Nagy, DJ Delorie

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.
---
 .../ldconfig.run                              |  0
 .../ldconfig.run                              |  0
 support/test-container.c                      | 26 +++++++++++++++++++
 3 files changed, 26 insertions(+)
 create mode 100644 elf/tst-glibc-hwcaps-prepend-cache.root/ldconfig.run
 create mode 100644 elf/tst-ldconfig-ld_so_conf-update.root/ldconfig.run

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));
-- 
2.25.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] elf: Fix tests that rely on ld.so.cache for cross-compiling
  2021-01-29 13:36 [PATCH] elf: Fix tests that rely on ld.so.cache for cross-compiling Adhemerval Zanella
@ 2021-01-29 13:40 ` Florian Weimer
  2021-01-29 13:59   ` Adhemerval Zanella
  2021-01-29 21:23 ` DJ Delorie
  1 sibling, 1 reply; 7+ messages in thread
From: Florian Weimer @ 2021-01-29 13:40 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha, Szabolcs Nagy, DJ Delorie

* Adhemerval Zanella:

> 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.

Commit subject does not match patch: No tests are fixed yet, I think.

Should running ldconfig automatically trigger post-clean activities?

Place of the invocation of ldconfig in the patch looks right to me.

Thanks,
Florian
-- 
Red Hat GmbH, https://de.redhat.com/ , Registered seat: Grasbrunn,
Commercial register: Amtsgericht Muenchen, HRB 153243,
Managing Directors: Charles Cachera, Brian Klemm, Laurie Krebs, Michael O'Neill


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] elf: Fix tests that rely on ld.so.cache for cross-compiling
  2021-01-29 13:40 ` Florian Weimer
@ 2021-01-29 13:59   ` Adhemerval Zanella
  2021-01-29 16:38     ` Florian Weimer
  0 siblings, 1 reply; 7+ messages in thread
From: Adhemerval Zanella @ 2021-01-29 13:59 UTC (permalink / raw)
  To: Florian Weimer; +Cc: libc-alpha, Szabolcs Nagy, DJ Delorie



On 29/01/2021 10:40, Florian Weimer wrote:
> * Adhemerval Zanella:
> 
>> 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.
> 
> Commit subject does not match patch: No tests are fixed yet, I think.

The fix is due the new two files:

  elf/tst-glibc-hwcaps-prepend-cache.root/ldconfig.run
  elf/tst-ldconfig-ld_so_conf-update.root/ldconfig.run

Otherwise in such described scenario ld.so.cache won't exist, the
tests will try to load it and failure will set the process to not
try to reload the cache (and then any ld.so.cache update won't change
dlopen outcome).

> 
> Should running ldconfig automatically trigger post-clean activities?

At least in such scenarios the ld.so.cache is already deleted, since
the sync with the pristine will detect the file existence.  Running
the tests with test-container -v I see:

sync /home/azanella/Projects/glibc/build/i686-linux-gnu/testroot.pristine/etc/ to /home/azanella/Projects/glibc/build/i686-linux-gnu/testroot.root/etc/ and delete
-F /home/azanella/Projects/glibc/build/i686-linux-gnu/testroot.root/etc/ld.so.conf
-F /home/azanella/Projects/glibc/build/i686-linux-gnu/testroot.root/etc/ld.so.cache

> 
> Place of the invocation of ldconfig in the patch looks right to me.
> 
> Thanks,
> Florian
> 

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] elf: Fix tests that rely on ld.so.cache for cross-compiling
  2021-01-29 13:59   ` Adhemerval Zanella
@ 2021-01-29 16:38     ` Florian Weimer
  0 siblings, 0 replies; 7+ messages in thread
From: Florian Weimer @ 2021-01-29 16:38 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha, Szabolcs Nagy, DJ Delorie

* Adhemerval Zanella:

>> Commit subject does not match patch: No tests are fixed yet, I think.
>
> The fix is due the new two files:
>
>   elf/tst-glibc-hwcaps-prepend-cache.root/ldconfig.run
>   elf/tst-ldconfig-ld_so_conf-update.root/ldconfig.run

I did look for them but really didn't see them due the way my mail
client marks up diffs. 8-(  Patch looks okay to me then.

Thanks,
Florian
-- 
Red Hat GmbH, https://de.redhat.com/ , Registered seat: Grasbrunn,
Commercial register: Amtsgericht Muenchen, HRB 153243,
Managing Directors: Charles Cachera, Brian Klemm, Laurie Krebs, Michael O'Neill


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] elf: Fix tests that rely on ld.so.cache for cross-compiling
  2021-01-29 13:36 [PATCH] elf: Fix tests that rely on ld.so.cache for cross-compiling Adhemerval Zanella
  2021-01-29 13:40 ` Florian Weimer
@ 2021-01-29 21:23 ` DJ Delorie
  2021-01-31 19:11   ` Florian Weimer
  1 sibling, 1 reply; 7+ messages in thread
From: DJ Delorie @ 2021-01-29 21:23 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha, fweimer, szabolcs.nagy


Patch looks good to me as-is but I'll note a few other options in case
we like those better :-)

* could put "ldconfig" in the scriptlet instead of a file, esp if it
  needs to be run in a specific order wrt installing other dso's, like
  if it needs to be run *before* corrupting a dso.

* the test case could just run ldconfig itself if it knows it's testing
  it.

* test-container could look for a zero-length etc/ld.so.cache in the
  test.root as a trigger to run ldconfig


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] elf: Fix tests that rely on ld.so.cache for cross-compiling
  2021-01-29 21:23 ` DJ Delorie
@ 2021-01-31 19:11   ` Florian Weimer
  2021-01-31 19:29     ` DJ Delorie
  0 siblings, 1 reply; 7+ messages in thread
From: Florian Weimer @ 2021-01-31 19:11 UTC (permalink / raw)
  To: DJ Delorie via Libc-alpha

* DJ Delorie via Libc-alpha:

> * the test case could just run ldconfig itself if it knows it's testing
>   it.

The test does this.  However, ld.so caches the non-existence of the
cache (but not the cache contents), prompting this change.

I think we should change the behavior for a missing cache, but please
not this close to a release.

Thanks,
Florian
-- 
Red Hat GmbH, https://de.redhat.com/ , Registered seat: Grasbrunn,
Commercial register: Amtsgericht Muenchen, HRB 153243,
Managing Directors: Charles Cachera, Brian Klemm, Laurie Krebs, Michael O'Neill


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] elf: Fix tests that rely on ld.so.cache for cross-compiling
  2021-01-31 19:11   ` Florian Weimer
@ 2021-01-31 19:29     ` DJ Delorie
  0 siblings, 0 replies; 7+ messages in thread
From: DJ Delorie @ 2021-01-31 19:29 UTC (permalink / raw)
  To: Florian Weimer; +Cc: libc-alpha, adhemerval.zanella

Florian Weimer <fweimer@redhat.com> writes:
> The test does this.  However, ld.so caches the non-existence of the
> cache (but not the cache contents), prompting this change.

Ah.

> I think we should change the behavior for a missing cache, but please
> not this close to a release.

No, of course not.  I just wanted to bring it up while people had the
issue in mind.


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2021-01-31 19:29 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-29 13:36 [PATCH] elf: Fix tests that rely on ld.so.cache for cross-compiling Adhemerval Zanella
2021-01-29 13:40 ` Florian Weimer
2021-01-29 13:59   ` Adhemerval Zanella
2021-01-29 16:38     ` Florian Weimer
2021-01-29 21:23 ` DJ Delorie
2021-01-31 19:11   ` Florian Weimer
2021-01-31 19:29     ` DJ Delorie

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).