[PATCH] Fix tst-ldconfig-ld_so_conf-update and tst-glibc-hwcaps-prepend-cache with custom configure prefix value

Romain GEISSLER romain.geissler@amadeus.com
Mon Aug 9 21:26:34 GMT 2021


Hi,

I have build a recent glibc 2.34 with some non default --prefix value at
configure time, and I have two new tests failing:
tst-ldconfig-ld_so_conf-update and tst-glibc-hwcaps-prepend-cache. Both
hardcodes the patch /etc/ld.so.conf which should take ${prefix} into
account. Fixed thusly.

I tested this successfully on x86-64.

Cheers,
Romain

>From 8005e062750421f44ab9f5c22243f70185a2b682 Mon Sep 17 00:00:00 2001
From: Romain Geissler <romain.geissler@amadeus.com>
Date: Mon, 9 Aug 2021 20:11:47 +0000
Subject: [PATCH] Fix tst-ldconfig-ld_so_conf-update and
 tst-glibc-hwcaps-prepend-cache with custom configure prefix value.

---
 elf/tst-glibc-hwcaps-prepend-cache.c | 10 +++++++---
 elf/tst-ldconfig-ld_so_conf-update.c | 13 ++++++++-----
 support/Makefile                     |  3 ++-
 support/support.h                    |  2 ++
 support/support_paths.c              |  7 +++++++
 5 files changed, 26 insertions(+), 9 deletions(-)

diff --git a/elf/tst-glibc-hwcaps-prepend-cache.c b/elf/tst-glibc-hwcaps-prepend-cache.c
index 153408e14d3..1f0872b918a 100644
--- a/elf/tst-glibc-hwcaps-prepend-cache.c
+++ b/elf/tst-glibc-hwcaps-prepend-cache.c
@@ -44,9 +44,13 @@ do_test (void)
   if (dlopen (SONAME, RTLD_NOW) != NULL)
     FAIL_EXIT1 (SONAME " is already on the search path");
 
-  /* Install the default implementation of libmarkermod1.so.  */
-  xmkdirp ("/etc", 0777);
-  support_write_file_string ("/etc/ld.so.conf", "/glibc-test/lib\n");
+  {
+    /* Install the default implementation of libmarkermod1.so.  */
+    char *conf_path = xasprintf ("%s/ld.so.conf", support_sysconfdir_prefix);
+    xmkdirp (support_sysconfdir_prefix, 0777);
+    support_write_file_string (conf_path, "/glibc-test/lib\n");
+    free (conf_path);
+  }
   xmkdirp ("/glibc-test/lib/glibc-hwcaps/prepend2", 0777);
   xmkdirp ("/glibc-test/lib/glibc-hwcaps/prepend3", 0777);
   {
diff --git a/elf/tst-ldconfig-ld_so_conf-update.c b/elf/tst-ldconfig-ld_so_conf-update.c
index e8bd4c35986..842ab8e25b0 100644
--- a/elf/tst-ldconfig-ld_so_conf-update.c
+++ b/elf/tst-ldconfig-ld_so_conf-update.c
@@ -33,7 +33,6 @@
 
 #define DSO "libldconfig-ld-mod.so"
 #define DSO_DIR "/tmp/tst-ldconfig"
-#define CONF "/etc/ld.so.conf"
 
 
 static void
@@ -64,6 +63,8 @@ do_test (void)
 {
   struct support_capture_subprocess result;
 
+  char *conf_path = xasprintf ("%s/ld.so.conf", support_sysconfdir_prefix);
+
   /* Create the needed directories.  */
   xmkdirp ("/var/cache/ldconfig", 0777);
   xmkdirp (DSO_DIR, 0777);
@@ -82,9 +83,9 @@ do_test (void)
      is not searched.  */
   TEST_VERIFY_EXIT (dlopen (DSO, RTLD_NOW | RTLD_GLOBAL) == NULL);
 
-  FILE *fp = xfopen (CONF, "a+");
+  FILE *fp = xfopen (conf_path, "a+");
   if (!fp)
-    FAIL_EXIT1 ("creating /etc/ld.so.conf failed: %m");
+    FAIL_EXIT1 ("creating %s failed: %m", conf_path);
   xfclose (fp);
 
   /* Run ldconfig.  */
@@ -95,9 +96,9 @@ do_test (void)
   TEST_VERIFY_EXIT (dlopen (DSO, RTLD_NOW | RTLD_GLOBAL) == NULL);
 
   /* Add tst-ldconfig directory to /etc/ld.so.conf.  */
-  fp = xfopen (CONF, "w");
+  fp = xfopen (conf_path, "w");
   if (!(fwrite (DSO_DIR, 1, sizeof (DSO_DIR), fp)))
-    FAIL_EXIT1 ("updating /etc/ld.so.conf failed: %m");
+    FAIL_EXIT1 ("updating %s failed: %m", conf_path);
   xfclose (fp);
 
   /* Try to dlopen the same DSO again, we expect this to still fail.  */
@@ -111,6 +112,8 @@ do_test (void)
   /* Finally, we expect dlopen to pass now.  */
   TEST_VERIFY_EXIT (dlopen (DSO, RTLD_NOW | RTLD_GLOBAL) != NULL);
 
+  free (conf_path);
+
   return 0;
 }
 
diff --git a/support/Makefile b/support/Makefile
index a4627817184..af086788527 100644
--- a/support/Makefile
+++ b/support/Makefile
@@ -219,7 +219,8 @@ CFLAGS-support_paths.c = \
 		-DSBINDIR_PATH=\"$(sbindir)\" \
 		-DSLIBDIR_PATH=\"$(slibdir)\" \
 		-DROOTSBINDIR_PATH=\"$(rootsbindir)\" \
-		-DCOMPLOCALEDIR_PATH=\"$(complocaledir)\"
+		-DCOMPLOCALEDIR_PATH=\"$(complocaledir)\" \
+		-DSYSCONFDIR_PATH=\"$(sysconfdir)\"
 
 # In support_timespec_check_in_range we may be passed a very tight
 # range for which we should produce a correct result for expected
diff --git a/support/support.h b/support/support.h
index 834dba90977..2be56f20e64 100644
--- a/support/support.h
+++ b/support/support.h
@@ -132,6 +132,8 @@ extern const char support_slibdir_prefix[];
 extern const char support_install_rootsbindir[];
 /* Corresponds to the install's compiled locale directory.  */
 extern const char support_complocaledir_prefix[];
+/* Corresponds to the install's etc/ directory.  */
+extern const char support_sysconfdir_prefix[];
 
 /* Copies the file at the path FROM to TO.  If TO does not exist, it
    is created.  If TO is a regular file, it is truncated before
diff --git a/support/support_paths.c b/support/support_paths.c
index d18e71e38bb..a0921ce7e90 100644
--- a/support/support_paths.c
+++ b/support/support_paths.c
@@ -92,3 +92,10 @@ const char support_complocaledir_prefix[] = COMPLOCALEDIR_PATH;
 #else
 # error please -DCOMPLOCALEDIR_PATH=something in the Makefile
 #endif
+
+#ifdef SYSCONFDIR_PATH
+/* Corresponds to the install's etc/ directory.  */
+const char support_sysconfdir_prefix[] = SYSCONFDIR_PATH;
+#else
+# error please -DSYSCONFDIR_PATH=something in the Makefile
+#endif
-- 
2.25.1


More information about the Libc-alpha mailing list