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