diff options
author | Florian Weimer <fweimer@redhat.com> | 2017-01-25 16:27:03 +0100 |
---|---|---|
committer | Florian Weimer <fweimer@redhat.com> | 2017-01-25 16:27:03 +0100 |
commit | 5653ab12b4ae15b32d41de7c56b2a4626cd0437a (patch) | |
tree | 350790c67fb99f948ae69aa1af6bfd0bd8420059 /string/tst-strcoll-overflow.c | |
parent | af1a265da09829f9042619c885c64eb8567a59ce (diff) | |
download | glibc-5653ab12b4ae15b32d41de7c56b2a4626cd0437a.zip glibc-5653ab12b4ae15b32d41de7c56b2a4626cd0437a.tar.gz glibc-5653ab12b4ae15b32d41de7c56b2a4626cd0437a.tar.bz2 |
string/tst-strcoll-overflow: Do not accept timeout as test result
The test completes within 300 seconds if enough memory is available.
Diffstat (limited to 'string/tst-strcoll-overflow.c')
-rw-r--r-- | string/tst-strcoll-overflow.c | 38 |
1 files changed, 15 insertions, 23 deletions
diff --git a/string/tst-strcoll-overflow.c b/string/tst-strcoll-overflow.c index ab76736..ee694b6 100644 --- a/string/tst-strcoll-overflow.c +++ b/string/tst-strcoll-overflow.c @@ -21,42 +21,34 @@ #include <stdlib.h> #include <string.h> -/* Verify that strcoll does not crash for large strings for which it cannot - cache weight lookup results. The size is large enough to cause integer - overflows on 32-bit as well as buffer overflows on 64-bit. The test should - work reasonably reliably when overcommit is disabled, but it obviously - depends on how much memory the system has. There's a limitation to this - test in that it does not run to completion. Actually collating such a - large string can take days and we can't have xcheck running that long. For - that reason, we run the test for about 5 minutes and then assume that - everything is fine if there are no crashes. */ +#include <support/check.h> +#include <support/test-driver.h> + +/* Verify that strcoll does not crash for large strings for which it + cannot cache weight lookup results. The size is large enough to + cause integer overflows on 32-bit as well as buffer overflows on + 64-bit. */ #define SIZE 0x40000000ul -int +static int do_test (void) { - if (setlocale (LC_COLLATE, "en_GB.UTF-8") == NULL) - { - puts ("setlocale failed, cannot test for overflow"); - return 0; - } + TEST_VERIFY_EXIT (setlocale (LC_COLLATE, "en_GB.UTF-8") != NULL); char *p = malloc (SIZE); - if (p == NULL) { - puts ("could not allocate memory"); - return 1; + puts ("info: could not allocate memory, cannot run test"); + return EXIT_UNSUPPORTED; } memset (p, 'x', SIZE - 1); p[SIZE - 1] = 0; - printf ("%d\n", strcoll (p, p)); + printf ("info: strcoll result: %d\n", strcoll (p, p)); return 0; } +/* This test can rung for a long time, but it should complete within + this time on reasonably current hardware. */ #define TIMEOUT 300 -#define EXPECTED_SIGNAL SIGALRM -#define EXPECTED_STATUS 0 -#define TEST_FUNCTION do_test () -#include "../test-skeleton.c" +#include <support/test-driver.c> |