X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=tests%2Funistr%2Ftest-strchr.h;h=b877bcd37ec891508d4ea121c62fcce8fbfb6bd4;hb=492fd301bd2018288330c0a20a086b1a8cc611ce;hp=f280406eb183e93799af4e42e45141c8be5c2df5;hpb=ad9a24a121ab3154f30d9d38d8243f41566d151e;p=gnulib.git diff --git a/tests/unistr/test-strchr.h b/tests/unistr/test-strchr.h index f280406eb..b877bcd37 100644 --- a/tests/unistr/test-strchr.h +++ b/tests/unistr/test-strchr.h @@ -1,5 +1,5 @@ -/* Test of uN_chr() functions. - Copyright (C) 2008-2010 Free Software Foundation, Inc. +/* Test of uN_strchr() functions. + Copyright (C) 2008-2011 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -17,8 +17,8 @@ /* Written by Paolo Bonzini , 2010. Based on test-chr.h, by Eric Blake and Bruno Haible. */ -int -main (void) +static void +test_strchr (void) { size_t size = 0x100000; size_t length; @@ -101,8 +101,7 @@ main (void) } } - /* Check that uN_chr() does not read past the first occurrence of the - byte being searched. */ + /* Check that uN_strchr() does not read past the end of the string. */ { char *page_boundary = (char *) zerosize_ptr (); size_t n; @@ -122,7 +121,41 @@ main (void) } } - free (input); +#if 0 + /* This check is disabled, because uN_strchr() is allowed to read past the + first occurrence of the byte being searched. In fact, u8_strchr() does + so, on i586 glibc systems: u8_strchr calls strchr, which in + glibc/sysdeps/i386/i586/strchr.S loads the second word before the + handling of the first word has been completed. */ + /* Check that uN_strchr() does not read past the first occurrence of the + byte being searched. */ + { + char *page_boundary = (char *) zerosize_ptr (); + size_t n; + + if (page_boundary != NULL) + { + for (n = 2; n <= 500 / sizeof (UNIT); n++) + { + UNIT *mem = (UNIT *) (page_boundary - n * sizeof (UNIT)); + U_SET (mem, 'X', n - 1); + mem[n - 1] = 0; + ASSERT (U_STRCHR (mem, 'U') == NULL); + + { + size_t i; - return 0; + for (i = 0; i < n; i++) + { + mem[i] = 'U'; + ASSERT (U_STRCHR (mem, 'U') == mem + i); + mem[i] = 'X'; + } + } + } + } + } +#endif + + free (input); }