Blame SOURCES/glibc-rh1647490-3.patch

147e83
commit f5e7e95921847bd83186bfe621fc2b48c4de5477
147e83
Author: Florian Weimer <fweimer@redhat.com>
147e83
Date:   Tue Oct 30 13:11:47 2018 +0100
147e83
147e83
    stdlib/test-bz22786: Avoid spurious test failures using alias mappings
147e83
    
147e83
    On systems without enough random-access memory, stdlib/test-bz22786
147e83
    will go deeply into swap and time out, even with a substantial
147e83
    TIMEOUTFACTOR.  This commit adds a facility to construct repeating
147e83
    strings with alias mappings, so that the requirement for physical
147e83
    memory, and uses it in stdlib/test-bz22786.
147e83
147e83
Adjusted here for the support/ backport in glibc-rh1418978-1.patch.
147e83
147e83
diff --git a/stdlib/test-bz22786.c b/stdlib/test-bz22786.c
147e83
index 777bf9180f4b5022..bb1e04f2debe9042 100644
147e83
--- a/stdlib/test-bz22786.c
147e83
+++ b/stdlib/test-bz22786.c
147e83
@@ -26,6 +26,7 @@
147e83
 #include <unistd.h>
147e83
 #include <sys/stat.h>
147e83
 #include <sys/types.h>
147e83
+#include <support/blob_repeat.h>
147e83
 #include <support/check.h>
147e83
 #include <support/support.h>
147e83
 #include <support/temp_file.h>
147e83
@@ -39,17 +40,12 @@ do_test (void)
147e83
   const char *lnk = xasprintf ("%s/symlink", dir);
147e83
   const size_t path_len = (size_t) INT_MAX + strlen (lnk) + 1;
147e83
 
147e83
-  DIAG_PUSH_NEEDS_COMMENT;
147e83
-#if __GNUC_PREREQ (7, 0)
147e83
-  /* GCC 7 warns about too-large allocations; here we need such
147e83
-     allocation to succeed for the test to work.  */
147e83
-  DIAG_IGNORE_NEEDS_COMMENT (7, "-Walloc-size-larger-than=");
147e83
-#endif
147e83
-  char *path = malloc (path_len);
147e83
-  DIAG_POP_NEEDS_COMMENT;
147e83
+  struct support_blob_repeat repeat
147e83
+    = support_blob_repeat_allocate ("a", 1, path_len);
147e83
+  char *path = repeat.start;
147e83
   if (path == NULL)
147e83
     {
147e83
-      printf ("malloc (%zu): %m\n", path_len);
147e83
+      printf ("Repeated allocation (%zu bytes): %m\n", path_len);
147e83
       /* On 31-bit s390 the malloc will always fail as we do not have
147e83
 	 so much memory, and we want to mark the test unsupported.
147e83
 	 Likewise on systems with little physical memory the test will
147e83
@@ -62,7 +58,6 @@ do_test (void)
147e83
   /* Construct very long path = "/tmp/bz22786.XXXX/symlink/aaaa....."  */
147e83
   char *p = mempcpy (path, lnk, strlen (lnk));
147e83
   *(p++) = '/';
147e83
-  memset (p, 'a', path_len - (p - path) - 2);
147e83
   p[path_len - (p - path) - 1] = '\0';
147e83
 
147e83
   /* This call crashes before the fix for bz22786 on 32-bit platforms.  */
147e83
@@ -76,6 +71,7 @@ do_test (void)
147e83
 
147e83
   /* Cleanup.  */
147e83
   unlink (lnk);
147e83
+  support_blob_repeat_free (&repeat);
147e83
 
147e83
   return 0;
147e83
 }