mirror of
https://sourceware.org/git/glibc.git
synced 2025-08-07 06:43:00 +03:00
string/tst-strcoll-overflow: Do not accept timeout as test result
The test completes within 300 seconds if enough memory is available.
This commit is contained in:
14
ChangeLog
14
ChangeLog
@@ -1,3 +1,17 @@
|
|||||||
|
2017-01-25 Florian Weimer <fweimer@redhat.com>
|
||||||
|
|
||||||
|
* string/Makefile (xtests): Add comment.
|
||||||
|
(LOCALES): Add en_GB.UTF-8.
|
||||||
|
(tst-strcoll-overflow.out): Depend on generated locales.
|
||||||
|
* string/tst-strcoll-overflow.c: Convert to support/test-driver.c.
|
||||||
|
(SIZE, TIMEOUT): Update comments.
|
||||||
|
(do_test): Define as static. Fail test if setlocale fails.
|
||||||
|
Return EXIT_UNSUPPORTED if insufficient memory. Enhance output
|
||||||
|
messages.
|
||||||
|
(EXPECTED_SIGNAL, EXPECTED_STATUS, TEST_FUNCTION): Remove.
|
||||||
|
TIMEOUT at 300 seconds should be enough to run this test
|
||||||
|
successfully.
|
||||||
|
|
||||||
2017-01-24 Jakub Jelinek <jakub@redhat.com>
|
2017-01-24 Jakub Jelinek <jakub@redhat.com>
|
||||||
|
|
||||||
* soft-fp/op-common.h (_FP_MUL, _FP_FMA, _FP_DIV): Add
|
* soft-fp/op-common.h (_FP_MUL, _FP_FMA, _FP_DIV): Add
|
||||||
|
@@ -59,6 +59,7 @@ tests := tester inl-tester noinl-tester testcopy test-ffs \
|
|||||||
tst-strtok_r bug-strcoll2 tst-cmp tst-xbzero-opt \
|
tst-strtok_r bug-strcoll2 tst-cmp tst-xbzero-opt \
|
||||||
test-endian-types
|
test-endian-types
|
||||||
|
|
||||||
|
# This test allocates a lot of memory and can run for a long time.
|
||||||
xtests = tst-strcoll-overflow
|
xtests = tst-strcoll-overflow
|
||||||
|
|
||||||
ifeq ($(run-built-tests),yes)
|
ifeq ($(run-built-tests),yes)
|
||||||
@@ -94,7 +95,7 @@ $(objpfx)tst-svc-cmp.out: tst-svc.expect $(objpfx)tst-svc.out
|
|||||||
|
|
||||||
LOCALES := de_DE.UTF-8 en_US.ISO-8859-1 en_US.UTF-8 \
|
LOCALES := de_DE.UTF-8 en_US.ISO-8859-1 en_US.UTF-8 \
|
||||||
tr_TR.ISO-8859-9 tr_TR.UTF-8 cs_CZ.UTF-8 \
|
tr_TR.ISO-8859-9 tr_TR.UTF-8 cs_CZ.UTF-8 \
|
||||||
da_DK.ISO-8859-1
|
da_DK.ISO-8859-1 en_GB.UTF-8
|
||||||
include ../gen-locales.mk
|
include ../gen-locales.mk
|
||||||
|
|
||||||
$(objpfx)test-strcasecmp.out: $(gen-locales)
|
$(objpfx)test-strcasecmp.out: $(gen-locales)
|
||||||
@@ -103,5 +104,6 @@ $(objpfx)tst-strxfrm.out: $(gen-locales)
|
|||||||
$(objpfx)tst-strxfrm2.out: $(gen-locales)
|
$(objpfx)tst-strxfrm2.out: $(gen-locales)
|
||||||
# bug-strcoll2 needs cs_CZ.UTF-8 and da_DK.ISO-8859-1.
|
# bug-strcoll2 needs cs_CZ.UTF-8 and da_DK.ISO-8859-1.
|
||||||
$(objpfx)bug-strcoll2.out: $(gen-locales)
|
$(objpfx)bug-strcoll2.out: $(gen-locales)
|
||||||
|
$(objpfx)tst-strcoll-overflow.out: $(gen-locales)
|
||||||
|
|
||||||
endif
|
endif
|
||||||
|
@@ -21,42 +21,34 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
/* Verify that strcoll does not crash for large strings for which it cannot
|
#include <support/check.h>
|
||||||
cache weight lookup results. The size is large enough to cause integer
|
#include <support/test-driver.h>
|
||||||
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
|
/* Verify that strcoll does not crash for large strings for which it
|
||||||
depends on how much memory the system has. There's a limitation to this
|
cannot cache weight lookup results. The size is large enough to
|
||||||
test in that it does not run to completion. Actually collating such a
|
cause integer overflows on 32-bit as well as buffer overflows on
|
||||||
large string can take days and we can't have xcheck running that long. For
|
64-bit. */
|
||||||
that reason, we run the test for about 5 minutes and then assume that
|
|
||||||
everything is fine if there are no crashes. */
|
|
||||||
#define SIZE 0x40000000ul
|
#define SIZE 0x40000000ul
|
||||||
|
|
||||||
int
|
static int
|
||||||
do_test (void)
|
do_test (void)
|
||||||
{
|
{
|
||||||
if (setlocale (LC_COLLATE, "en_GB.UTF-8") == NULL)
|
TEST_VERIFY_EXIT (setlocale (LC_COLLATE, "en_GB.UTF-8") != NULL);
|
||||||
{
|
|
||||||
puts ("setlocale failed, cannot test for overflow");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
char *p = malloc (SIZE);
|
char *p = malloc (SIZE);
|
||||||
|
|
||||||
if (p == NULL)
|
if (p == NULL)
|
||||||
{
|
{
|
||||||
puts ("could not allocate memory");
|
puts ("info: could not allocate memory, cannot run test");
|
||||||
return 1;
|
return EXIT_UNSUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
memset (p, 'x', SIZE - 1);
|
memset (p, 'x', SIZE - 1);
|
||||||
p[SIZE - 1] = 0;
|
p[SIZE - 1] = 0;
|
||||||
printf ("%d\n", strcoll (p, p));
|
printf ("info: strcoll result: %d\n", strcoll (p, p));
|
||||||
return 0;
|
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 TIMEOUT 300
|
||||||
#define EXPECTED_SIGNAL SIGALRM
|
#include <support/test-driver.c>
|
||||||
#define EXPECTED_STATUS 0
|
|
||||||
#define TEST_FUNCTION do_test ()
|
|
||||||
#include "../test-skeleton.c"
|
|
||||||
|
Reference in New Issue
Block a user