|
|
d8307d |
commit 3bad2358d67d371497079bba4f8eca9c0096f4e2
|
|
|
d8307d |
Author: Stefan Liebler <stli@linux.ibm.com>
|
|
|
d8307d |
Date: Thu Aug 30 08:44:32 2018 +0200
|
|
|
d8307d |
|
|
|
d8307d |
Test stdlib/test-bz22786 exits now with unsupported if malloc fails.
|
|
|
d8307d |
|
|
|
d8307d |
The test tries to allocate more than 2^31 bytes which will always fail on s390
|
|
|
d8307d |
as it has maximum 2^31bit of memory.
|
|
|
d8307d |
Before commit 6c3a8a9d868a8deddf0d6dcc785b6d120de90523, this test returned
|
|
|
d8307d |
unsupported if malloc fails. This patch re enables this behaviour.
|
|
|
d8307d |
|
|
|
d8307d |
Furthermore support_delete_temp_files() failed to remove the temp directory
|
|
|
d8307d |
in this case as it is not empty due to the created symlink.
|
|
|
d8307d |
Thus the creation of the symlink is moved behind malloc.
|
|
|
d8307d |
|
|
|
d8307d |
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
|
|
|
d8307d |
|
|
|
d8307d |
ChangeLog:
|
|
|
d8307d |
|
|
|
d8307d |
* stdlib/test-bz22786.c (do_test): Return EXIT_UNSUPPORTED
|
|
|
d8307d |
if malloc fails.
|
|
|
d8307d |
|
|
|
d8307d |
diff --git a/stdlib/test-bz22786.c b/stdlib/test-bz22786.c
|
|
|
d8307d |
index d1aa69106ccf6ac5..777bf9180f4b5022 100644
|
|
|
d8307d |
--- a/stdlib/test-bz22786.c
|
|
|
d8307d |
+++ b/stdlib/test-bz22786.c
|
|
|
d8307d |
@@ -39,16 +39,25 @@ do_test (void)
|
|
|
d8307d |
const char *lnk = xasprintf ("%s/symlink", dir);
|
|
|
d8307d |
const size_t path_len = (size_t) INT_MAX + strlen (lnk) + 1;
|
|
|
d8307d |
|
|
|
d8307d |
- TEST_VERIFY_EXIT (symlink (".", lnk) == 0);
|
|
|
d8307d |
-
|
|
|
d8307d |
DIAG_PUSH_NEEDS_COMMENT;
|
|
|
d8307d |
#if __GNUC_PREREQ (7, 0)
|
|
|
d8307d |
/* GCC 7 warns about too-large allocations; here we need such
|
|
|
d8307d |
allocation to succeed for the test to work. */
|
|
|
d8307d |
DIAG_IGNORE_NEEDS_COMMENT (7, "-Walloc-size-larger-than=");
|
|
|
d8307d |
#endif
|
|
|
d8307d |
- char *path = xmalloc (path_len);
|
|
|
d8307d |
+ char *path = malloc (path_len);
|
|
|
d8307d |
DIAG_POP_NEEDS_COMMENT;
|
|
|
d8307d |
+ if (path == NULL)
|
|
|
d8307d |
+ {
|
|
|
d8307d |
+ printf ("malloc (%zu): %m\n", path_len);
|
|
|
d8307d |
+ /* On 31-bit s390 the malloc will always fail as we do not have
|
|
|
d8307d |
+ so much memory, and we want to mark the test unsupported.
|
|
|
d8307d |
+ Likewise on systems with little physical memory the test will
|
|
|
d8307d |
+ fail and should be unsupported. */
|
|
|
d8307d |
+ return EXIT_UNSUPPORTED;
|
|
|
d8307d |
+ }
|
|
|
d8307d |
+
|
|
|
d8307d |
+ TEST_VERIFY_EXIT (symlink (".", lnk) == 0);
|
|
|
d8307d |
|
|
|
d8307d |
/* Construct very long path = "/tmp/bz22786.XXXX/symlink/aaaa....." */
|
|
|
d8307d |
char *p = mempcpy (path, lnk, strlen (lnk));
|