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