diff options
author | Waldemar Brodkorb <wbx@uclibc-ng.org> | 2016-10-28 20:29:21 +0200 |
---|---|---|
committer | Waldemar Brodkorb <wbx@uclibc-ng.org> | 2016-10-28 20:31:55 +0200 |
commit | 99ef2719fb3d703fe38c4113cd7f5adec516dd3a (patch) | |
tree | 2c1f77cb41b60ccbf8faa77a3640491a3546b546 /test/string | |
parent | 543308f6c46cf2edf8a524bc9c631e472570fe72 (diff) |
test: remove test suite
The test suite is now a developed in a separate git repository.
See here:
http://cgit.uclibc-ng.org/cgi/cgit/uclibc-ng-test.git
The test suite should be just like every other software compiled
with the cross-toolchain. In the past strange problems where found
when the test suite got build in the toolchain creation step.
Diffstat (limited to 'test/string')
-rw-r--r-- | test/string/Makefile | 8 | ||||
-rw-r--r-- | test/string/Makefile.in | 8 | ||||
-rw-r--r-- | test/string/bug-strcoll1.c | 24 | ||||
-rw-r--r-- | test/string/bug-strncat1.c | 31 | ||||
-rw-r--r-- | test/string/bug-strpbrk1.c | 19 | ||||
-rw-r--r-- | test/string/bug-strspn1.c | 19 | ||||
-rw-r--r-- | test/string/stratcliff.c | 348 | ||||
-rw-r--r-- | test/string/test-ffs.c | 65 | ||||
-rw-r--r-- | test/string/testcopy.c | 107 | ||||
-rw-r--r-- | test/string/tester.c | 1646 | ||||
-rw-r--r-- | test/string/tst-bswap.c | 73 | ||||
-rw-r--r-- | test/string/tst-inlcall.c | 82 | ||||
-rw-r--r-- | test/string/tst-memmove.c | 46 | ||||
-rw-r--r-- | test/string/tst-strlen.c | 45 | ||||
-rw-r--r-- | test/string/tst-strtok.c | 23 | ||||
-rw-r--r-- | test/string/tst-strxfrm.c | 80 |
16 files changed, 0 insertions, 2624 deletions
diff --git a/test/string/Makefile b/test/string/Makefile deleted file mode 100644 index 8948a50e3..000000000 --- a/test/string/Makefile +++ /dev/null @@ -1,8 +0,0 @@ -# uClibc string tests -# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. - -top_builddir=../../ -top_srcdir=../../ -include ../Rules.mak --include Makefile.in -include ../Test.mak diff --git a/test/string/Makefile.in b/test/string/Makefile.in deleted file mode 100644 index 39fb91210..000000000 --- a/test/string/Makefile.in +++ /dev/null @@ -1,8 +0,0 @@ -# uClibc string tests -# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. - -EXTRA_CFLAGS := -fno-builtin - -ifeq ($(TARGET_ARCH),h8300) -TESTS_DISABLED += stratcliff -endif diff --git a/test/string/bug-strcoll1.c b/test/string/bug-strcoll1.c deleted file mode 100644 index b6510d926..000000000 --- a/test/string/bug-strcoll1.c +++ /dev/null @@ -1,24 +0,0 @@ -#include <stdio.h> -#include <string.h> -#include <locale.h> - -int -main (void) -{ - const char t1[] = "0-0-0-0-0-0-0-0-0-0.COM"; - const char t2[] = "00000-00000.COM"; - int res1; - int res2; - - setlocale (LC_ALL, "en_US.ISO-8859-1"); - - res1 = strcoll (t1, t2); - printf ("strcoll (\"%s\", \"%s\") = %d\n", t1, t2, res1); - res2 = strcoll (t2, t1); - printf ("strcoll (\"%s\", \"%s\") = %d\n", t2, t1, res2); - - return ((res1 == 0 && res2 != 0) - || (res1 != 0 && res2 == 0) - || (res1 < 0 && res2 < 0) - || (res1 > 0 && res2 > 0)); -} diff --git a/test/string/bug-strncat1.c b/test/string/bug-strncat1.c deleted file mode 100644 index f1b5c37c5..000000000 --- a/test/string/bug-strncat1.c +++ /dev/null @@ -1,31 +0,0 @@ -/* Test case by Joseph S. Myers <jsm28@cam.ac.uk>. */ -#undef __USE_STRING_INLINES -#define __USE_STRING_INLINES -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -char d[3] = "\0\1\2"; - -int -main (void) -{ - strncat (d, "\5\6", 1); - if (d[0] != '\5') - { - puts ("d[0] != '\\5'"); - exit (1); - } - if (d[1] != '\0') - { - puts ("d[1] != '\\0'"); - exit (1); - } - if (d[2] != '\2') - { - puts ("d[2] != '\\2'"); - exit (1); - } - - return 0; -} diff --git a/test/string/bug-strpbrk1.c b/test/string/bug-strpbrk1.c deleted file mode 100644 index 28238b0f5..000000000 --- a/test/string/bug-strpbrk1.c +++ /dev/null @@ -1,19 +0,0 @@ -/* Test case by Joseph S. Myers <jsm28@cam.ac.uk>. */ -#undef __USE_STRING_INLINES -#define __USE_STRING_INLINES -#include <string.h> -#include <stdlib.h> -#include <stdio.h> - -int -main (void) -{ - const char *a = "abc"; - const char *b = a; - - strpbrk (b++, ""); - if (b != a + 1) - return 1; - - return 0; -} diff --git a/test/string/bug-strspn1.c b/test/string/bug-strspn1.c deleted file mode 100644 index a657bafc4..000000000 --- a/test/string/bug-strspn1.c +++ /dev/null @@ -1,19 +0,0 @@ -/* Test case by Joseph S. Myers <jsm28@cam.ac.uk>. */ -#undef __USE_STRING_INLINES -#define __USE_STRING_INLINES -#include <string.h> -#include <stdlib.h> -#include <stdio.h> - -int -main (void) -{ - const char *a = "abc"; - const char *b = a; - - strspn (b++, ""); - if (b != a + 1) - return 1; - - return 0; -} diff --git a/test/string/stratcliff.c b/test/string/stratcliff.c deleted file mode 100644 index b45be4bde..000000000 --- a/test/string/stratcliff.c +++ /dev/null @@ -1,348 +0,0 @@ -/* Test for string function add boundaries of usable memory. - Copyright (C) 1996,1997,1999-2002,2003 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ - -#define _GNU_SOURCE 1 - -/* Make sure we don't test the optimized inline functions if we want to - test the real implementation. */ -#undef __USE_STRING_INLINES - -#include <errno.h> -#include <stdio.h> -#include <string.h> -#include <unistd.h> -#include <sys/mman.h> -#include <sys/param.h> - -#ifndef MAX -#define MAX(a, b) ((a) > (b) ? (a) : (b)) -#endif - -int -main (int argc, char *argv[]) -{ - int size = sysconf (_SC_PAGESIZE); - char *adr, *dest; - int result = 0; - - adr = (char *) mmap (NULL, 3 * size, PROT_READ | PROT_WRITE, - MAP_PRIVATE | MAP_ANON, -1, 0); - dest = (char *) mmap (NULL, 3 * size, PROT_READ | PROT_WRITE, - MAP_PRIVATE | MAP_ANON, -1, 0); - if (adr == MAP_FAILED || dest == MAP_FAILED) - { - if (errno == ENOSYS) - puts ("No test, mmap not available."); - else - { - printf ("mmap failed: %s", strerror(errno)); - result = 1; - } - } - else - { - int inner, middle, outer; - - mprotect(adr, size, PROT_NONE); - mprotect(adr + 2 * size, size, PROT_NONE); - adr += size; - - mprotect(dest, size, PROT_NONE); - mprotect(dest + 2 * size, size, PROT_NONE); - dest += size; - - memset (adr, 'T', size); - - /* strlen test */ - for (outer = size - 1; outer >= MAX (0, size - 128); --outer) - { - for (inner = MAX (outer, size - 64); inner < size; ++inner) - { - adr[inner] = '\0'; - - if (strlen (&adr[outer]) != (size_t) (inner - outer)) - { - printf ("strlen flunked for outer = %d, inner = %d\n", - outer, inner); - result = 1; - } - - adr[inner] = 'T'; - } - } - - /* strchr test */ - for (outer = size - 1; outer >= MAX (0, size - 128); --outer) - { - for (middle = MAX (outer, size - 64); middle < size; ++middle) - { - for (inner = middle; inner < size; ++inner) - { - char *cp; - adr[middle] = 'V'; - adr[inner] = '\0'; - - cp = strchr (&adr[outer], 'V'); - - if ((inner == middle && cp != NULL) - || (inner != middle - && (cp - &adr[outer]) != middle - outer)) - { - printf ("strchr flunked for outer = %d, middle = %d, " - "inner = %d\n", outer, middle, inner); - result = 1; - } - - adr[inner] = 'T'; - adr[middle] = 'T'; - } - } - } - - /* Special test. */ - adr[size - 1] = '\0'; - if (strchr (&adr[size - 1], '\n') != NULL) - { - puts ("strchr flunked for test of empty string at end of page"); - result = 1; - } - - /* strrchr test */ - for (outer = size - 1; outer >= MAX (0, size - 128); --outer) - { - for (middle = MAX (outer, size - 64); middle < size; ++middle) - { - for (inner = middle; inner < size; ++inner) - { - char *cp; - adr[middle] = 'V'; - adr[inner] = '\0'; - - cp = strrchr (&adr[outer], 'V'); - - if ((inner == middle && cp != NULL) - || (inner != middle - && (cp - &adr[outer]) != middle - outer)) - { - printf ("strrchr flunked for outer = %d, middle = %d, " - "inner = %d\n", outer, middle, inner); - result = 1; - } - - adr[inner] = 'T'; - adr[middle] = 'T'; - } - } - } - - /* rawmemchr test */ - for (outer = size - 1; outer >= MAX (0, size - 128); --outer) - { - for (middle = MAX (outer, size - 64); middle < size; ++middle) - { - char *cp; - adr[middle] = 'V'; - - cp = rawmemchr (&adr[outer], 'V'); - - if (cp - &adr[outer] != middle - outer) - { - printf ("rawmemchr flunked for outer = %d, middle = %d\n", - outer, middle); - result = 1; - } - - adr[middle] = 'T'; - } - } - - /* strcpy test */ - for (outer = size - 1; outer >= MAX (0, size - 128); --outer) - { - for (inner = MAX (outer, size - 64); inner < size; ++inner) - { - adr[inner] = '\0'; - - if (strcpy (dest, &adr[outer]) != dest - || strlen (dest) != (size_t) (inner - outer)) - { - printf ("strcpy flunked for outer = %d, inner = %d\n", - outer, inner); - result = 1; - } - - adr[inner] = 'T'; - } - } - - /* strncpy tests */ - adr[size-1] = 'T'; - for (outer = size - 1; outer >= MAX (0, size - 128); --outer) - { - size_t len; - - for (len = 0; len < size - outer; ++len) - { - if (strncpy (dest, &adr[outer], len) != dest - || memcmp (dest, &adr[outer], len) != 0) - { - printf ("outer strncpy flunked for outer = %d, len = %Zd\n", - outer, len); - result = 1; - } - } - } - adr[size-1] = '\0'; - - for (outer = size - 1; outer >= MAX (0, size - 128); --outer) - { - for (inner = MAX (outer, size - 64); inner < size; ++inner) - { - size_t len; - - adr[inner] = '\0'; - - for (len = 0; len < size - outer + 64; ++len) - { - if (strncpy (dest, &adr[outer], len) != dest - || memcmp (dest, &adr[outer], - MIN (inner - outer, len)) != 0 - || (inner - outer < len - && strlen (dest) != (inner - outer))) - { - printf ("strncpy flunked for outer = %d, inner = %d, len = %Zd\n", - outer, inner, len); - result = 1; - } - if (strncpy (dest + 1, &adr[outer], len) != dest + 1 - || memcmp (dest + 1, &adr[outer], - MIN (inner - outer, len)) != 0 - || (inner - outer < len - && strlen (dest + 1) != (inner - outer))) - { - printf ("strncpy+1 flunked for outer = %d, inner = %d, len = %Zd\n", - outer, inner, len); - result = 1; - } - } - - adr[inner] = 'T'; - } - } - - /* stpcpy test */ - for (outer = size - 1; outer >= MAX (0, size - 128); --outer) - { - for (inner = MAX (outer, size - 64); inner < size; ++inner) - { - adr[inner] = '\0'; - - if ((stpcpy (dest, &adr[outer]) - dest) != inner - outer) - { - printf ("stpcpy flunked for outer = %d, inner = %d\n", - outer, inner); - result = 1; - } - - adr[inner] = 'T'; - } - } - - /* stpncpy test */ - for (outer = size - 1; outer >= MAX (0, size - 128); --outer) - { - for (middle = MAX (outer, size - 64); middle < size; ++middle) - { - adr[middle] = '\0'; - - for (inner = 0; inner < size - outer; ++ inner) - { - if ((stpncpy (dest, &adr[outer], inner) - dest) - != MIN (inner, middle - outer)) - { - printf ("stpncpy flunked for outer = %d, middle = %d, " - "inner = %d\n", outer, middle, inner); - result = 1; - } - } - - adr[middle] = 'T'; - } - } - - /* memcpy test */ - for (outer = size - 1; outer >= MAX (0, size - 128); --outer) - for (inner = 0; inner < size - outer; ++inner) - if (memcpy (dest, &adr[outer], inner) != dest) - { - printf ("memcpy flunked for outer = %d, inner = %d\n", - outer, inner); - result = 1; - } - - /* mempcpy test */ - for (outer = size - 1; outer >= MAX (0, size - 128); --outer) - for (inner = 0; inner < size - outer; ++inner) - if (mempcpy (dest, &adr[outer], inner) != dest + inner) - { - printf ("mempcpy flunked for outer = %d, inner = %d\n", - outer, inner); - result = 1; - } - - /* memccpy test */ - memset (adr, '\0', size); - for (outer = size - 1; outer >= MAX (0, size - 128); --outer) - for (inner = 0; inner < size - outer; ++inner) - if (memccpy (dest, &adr[outer], '\1', inner) != NULL) - { - printf ("memccpy flunked full copy for outer = %d, inner = %d\n", - outer, inner); - result = 1; - } - for (outer = size - 1; outer >= MAX (0, size - 128); --outer) - for (middle = 0; middle < size - outer; ++middle) - { - memset (dest, '\2', middle + 1); - for (inner = 0; inner < middle; ++inner) - { - adr[outer + inner] = '\1'; - - if (memccpy (dest, &adr[outer], '\1', middle + 128) - != dest + inner + 1) - { - printf ("\ -memccpy flunked partial copy for outer = %d, middle = %d, inner = %d\n", - outer, middle, inner); - result = 1; - } - else if (dest[inner + 1] != '\2') - { - printf ("\ -memccpy copied too much for outer = %d, middle = %d, inner = %d\n", - outer, middle, inner); - result = 1; - } - adr[outer + inner] = '\0'; - } - } - } - - return result; -} diff --git a/test/string/test-ffs.c b/test/string/test-ffs.c deleted file mode 100644 index e43f12360..000000000 --- a/test/string/test-ffs.c +++ /dev/null @@ -1,65 +0,0 @@ -/* Copyright (C) 1994, 1997, 2000, 2004 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Joel Sherrill (jsherril@redstone-emh2.army.mil), - On-Line Applications Research Corporation. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ - -#include <stdlib.h> -#include <stdio.h> -#include <string.h> - -int -main (void) -{ - int failures = 0; - int i; - - auto void try (const char *name, long long int param, int value, - int expected); - - void try (const char *name, long long int param, int value, int expected) - { - if (value != expected) - { - printf ("%s(%#llx) expected %d got %d\n", - name, param, expected, value); - ++failures; - } - else - printf ("%s(%#llx) as expected %d\n", name, param, value); - } - -#define TEST(fct, type) \ - try (#fct, 0, fct ((type) 0), 0); \ - for (i=0 ; i < 8 * sizeof (type); i++) \ - try (#fct, 1ll << i, fct (((type) 1) << i), i + 1); \ - for (i=0 ; i < 8 * sizeof (type) ; i++) \ - try (#fct, (~((type) 0) >> i) << i, fct ((~((type) 0) >> i) << i), i + 1);\ - try (#fct, 0x80008000, fct ((type) 0x80008000), 16) - - TEST (ffs, int); -/* Not implemented in uClibc (yet?) - TEST (ffsl, long int); - TEST (ffsll, long long int); -*/ - - if (failures) - printf ("Test FAILED! %d failure%s.\n", failures, &"s"[failures == 1]); - else - puts ("Test succeeded."); - - return failures; -} diff --git a/test/string/testcopy.c b/test/string/testcopy.c deleted file mode 100644 index 51c47a174..000000000 --- a/test/string/testcopy.c +++ /dev/null @@ -1,107 +0,0 @@ -/* Copyright (C) 1990, 1991, 1992, 1997 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Torbjorn Granlund (tege@sics.se). - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ - -#include <stdlib.h> -#include <stdio.h> -#include <string.h> -#include <malloc.h> - -int -main (void) -{ - char *mem, *memp; - char *rand_mem; - char *lo_around, *hi_around; - int size, max_size; - int src_off, dst_off; - int i; - int space_around = 10; - - max_size = 256; - - mem = malloc (max_size + 2 * max_size + 2 * space_around); - rand_mem = malloc (max_size); - lo_around = malloc (space_around); - hi_around = malloc (space_around); - memp = mem + space_around; - - /* Fill RAND_MEM with random bytes, each non-zero. */ - for (i = 0; i < max_size; i++) - { - int x; - do - x = random (); - while (x == 0); - rand_mem[i] = x; - } - - for (size = 0; size < max_size; size++) - { - printf("phase %d\n", size); - for (src_off = 0; src_off <= 16; src_off++) - { - for (dst_off = 0; dst_off <= 16; dst_off++) - { - /* Put zero around the intended destination, to check - that it's not clobbered. */ - for (i = 1; i < space_around; i++) - { - memp[dst_off - i] = 0; - memp[dst_off + size - 1 + i] = 0; - } - - /* Fill the source area with known contents. */ - for (i = 0; i < size; i++) - memp[src_off + i] = rand_mem[i]; - - /* Remember the contents around the destination area. - (It might not be what we wrote some lines above, since - the src area and the dst area overlap.) */ - for (i = 1; i < space_around; i++) - { - lo_around[i] = memp[dst_off - i]; - hi_around[i] = memp[dst_off + size - 1 + i]; - } - - memmove (memp + dst_off, memp + src_off, size); - - /* Check that the destination area has the same - contents we wrote to the source area. */ - for (i = 0; i < size; i++) - { - if (memp[dst_off + i] != rand_mem[i]) - abort (); - } - - /* Check that the area around the destination is not - clobbered. */ - for (i = 1; i < space_around; i++) - { - if (memp[dst_off - i] != lo_around[i]) - abort (); - if (memp[dst_off + size - 1 + i] != hi_around[i]) - abort (); - } - } - } - } - - puts ("Test succeeded."); - - return 0; -} diff --git a/test/string/tester.c b/test/string/tester.c deleted file mode 100644 index 7f3ff2865..000000000 --- a/test/string/tester.c +++ /dev/null @@ -1,1646 +0,0 @@ -/* Tester for string functions. - Copyright (C) 1995-2001, 2003, 2005 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ - -#ifndef _GNU_SOURCE -#define _GNU_SOURCE -#endif - -/* Make sure we don't test the optimized inline functions if we want to - test the real implementation. */ -#if !defined DO_STRING_INLINES -#undef __USE_STRING_INLINES -#endif - -#include <errno.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <strings.h> -#include <fcntl.h> - -#ifdef __UCLIBC__ -# define __TEST_BSD_FUNCS__ -#else -# undef __TEST_BSD_FUNCS__ -#endif - -#if defined(__UCLIBC_SUSV3_LEGACY__) || defined(__UCLIBC_SUSV3_LEGACY_MACROS__) -# define __TEST_SUSV3_LEGACY__ -#else -# undef __TEST_SUSV3_LEGACY__ -#endif - -#define STREQ(a, b) (strcmp((a), (b)) == 0) - -const char *it = "<UNSET>"; /* Routine name for message routines. */ -size_t errors = 0; - -/* Complain if condition is not true. */ -static void -check (int thing, int number) -{ - if (!thing) - { - printf("%s flunked test %d\n", it, number); - ++errors; - } -} - -/* Complain if first two args don't strcmp as equal. */ -static void -equal (const char *a, const char *b, int number) -{ - check(a != NULL && b != NULL && STREQ (a, b), number); -} - -char one[50]; -char two[50]; -char *cp; - -static void -test_strcmp (void) -{ - it = "strcmp"; - check (strcmp ("", "") == 0, 1); /* Trivial case. */ - check (strcmp ("a", "a") == 0, 2); /* Identity. */ - check (strcmp ("abc", "abc") == 0, 3); /* Multicharacter. */ - check (strcmp ("abc", "abcd") < 0, 4); /* Length mismatches. */ - check (strcmp ("abcd", "abc") > 0, 5); - check (strcmp ("abcd", "abce") < 0, 6); /* Honest miscompares. */ - check (strcmp ("abce", "abcd") > 0, 7); - check (strcmp ("a\203", "a") > 0, 8); /* Tricky if char signed. */ - check (strcmp ("a\203", "a\003") > 0, 9); - - { - char buf1[0x40], buf2[0x40]; - int i, j; - for (i=0; i < 0x10; i++) - for (j = 0; j < 0x10; j++) - { - int k; - for (k = 0; k < 0x3f; k++) - { - buf1[k] = '0' ^ (k & 4); - buf2[k] = '4' ^ (k & 4); - } - buf1[i] = buf1[0x3f] = 0; - buf2[j] = buf2[0x3f] = 0; - for (k = 0; k < 0xf; k++) - { - int cnum = 0x10+0x10*k+0x100*j+0x1000*i; - check (strcmp (buf1+i,buf2+j) == 0, cnum); - buf1[i+k] = 'A' + i + k; - buf1[i+k+1] = 0; - check (strcmp (buf1+i,buf2+j) > 0, cnum+1); - check (strcmp (buf2+j,buf1+i) < 0, cnum+2); - buf2[j+k] = 'B' + i + k; - buf2[j+k+1] = 0; - check (strcmp (buf1+i,buf2+j) < 0, cnum+3); - check (strcmp (buf2+j,buf1+i) > 0, cnum+4); - buf2[j+k] = 'A' + i + k; - buf1[i] = 'A' + i + 0x80; - check (strcmp (buf1+i,buf2+j) > 0, cnum+5); - check (strcmp (buf2+j,buf1+i) < 0, cnum+6); - buf1[i] = 'A' + i; - } - } - } -} - -#define SIMPLE_COPY(fn, n, str, ntest) \ - do { \ - int __n; \ - char *cp; \ - for (__n = 0; __n < (int) sizeof (one); ++__n) \ - one[__n] = 'Z'; \ - fn (one, str); \ - for (cp = one, __n = 0; __n < n; ++__n, ++cp) \ - check (*cp == '0' + (n % 10), ntest); \ - check (*cp == '\0', ntest); \ - } while (0) - -static void -test_strcpy (void) -{ - int i; - it = "strcpy"; - check (strcpy (one, "abcd") == one, 1); /* Returned value. */ - equal (one, "abcd", 2); /* Basic test. */ - - (void) strcpy (one, "x"); - equal (one, "x", 3); /* Writeover. */ - equal (one+2, "cd", 4); /* Wrote too much? */ - - (void) strcpy (two, "hi there"); - (void) strcpy (one, two); - equal (one, "hi there", 5); /* Basic test encore. */ - equal (two, "hi there", 6); /* Stomped on source? */ - - (void) strcpy (one, ""); - equal (one, "", 7); /* Boundary condition. */ - - for (i = 0; i < 16; i++) - { - (void) strcpy (one + i, "hi there"); /* Unaligned destination. */ - equal (one + i, "hi there", 8 + (i * 2)); - (void) strcpy (two, one + i); /* Unaligned source. */ - equal (two, "hi there", 9 + (i * 2)); - } - - SIMPLE_COPY(strcpy, 0, "", 41); - SIMPLE_COPY(strcpy, 1, "1", 42); - SIMPLE_COPY(strcpy, 2, "22", 43); - SIMPLE_COPY(strcpy, 3, "333", 44); - SIMPLE_COPY(strcpy, 4, "4444", 45); - SIMPLE_COPY(strcpy, 5, "55555", 46); - SIMPLE_COPY(strcpy, 6, "666666", 47); - SIMPLE_COPY(strcpy, 7, "7777777", 48); - SIMPLE_COPY(strcpy, 8, "88888888", 49); - SIMPLE_COPY(strcpy, 9, "999999999", 50); - SIMPLE_COPY(strcpy, 10, "0000000000", 51); - SIMPLE_COPY(strcpy, 11, "11111111111", 52); - SIMPLE_COPY(strcpy, 12, "222222222222", 53); - SIMPLE_COPY(strcpy, 13, "3333333333333", 54); - SIMPLE_COPY(strcpy, 14, "44444444444444", 55); - SIMPLE_COPY(strcpy, 15, "555555555555555", 56); - SIMPLE_COPY(strcpy, 16, "6666666666666666", 57); - - /* Simple test using implicitly coerced `void *' arguments. */ - const void *src = "frobozz"; - void *dst = one; - check (strcpy (dst, src) == dst, 1); - equal (dst, "frobozz", 2); -} - -static void -test_stpcpy (void) -{ - it = "stpcpy"; - check ((stpcpy (one, "a") - one) == 1, 1); - equal (one, "a", 2); - - check ((stpcpy (one, "ab") - one) == 2, 3); - equal (one, "ab", 4); - - check ((stpcpy (one, "abc") - one) == 3, 5); - equal (one, "abc", 6); - - check ((stpcpy (one, "abcd") - one) == 4, 7); - equal (one, "abcd", 8); - - check ((stpcpy (one, "abcde") - one) == 5, 9); - equal (one, "abcde", 10); - - check ((stpcpy (one, "abcdef") - one) == 6, 11); - equal (one, "abcdef", 12); - - check ((stpcpy (one, "abcdefg") - one) == 7, 13); - equal (one, "abcdefg", 14); - - check ((stpcpy (one, "abcdefgh") - one) == 8, 15); - equal (one, "abcdefgh", 16); - - check ((stpcpy (one, "abcdefghi") - one) == 9, 17); - equal (one, "abcdefghi", 18); - - check ((stpcpy (one, "x") - one) == 1, 19); - equal (one, "x", 20); /* Writeover. */ - equal (one+2, "cdefghi", 21); /* Wrote too much? */ - - check ((stpcpy (one, "xx") - one) == 2, 22); - equal (one, "xx", 23); /* Writeover. */ - equal (one+3, "defghi", 24); /* Wrote too much? */ - - check ((stpcpy (one, "xxx") - one) == 3, 25); - equal (one, "xxx", 26); /* Writeover. */ - equal (one+4, "efghi", 27); /* Wrote too much? */ - - check ((stpcpy (one, "xxxx") - one) == 4, 28); - equal (one, "xxxx", 29); /* Writeover. */ - equal (one+5, "fghi", 30); /* Wrote too much? */ - - check ((stpcpy (one, "xxxxx") - one) == 5, 31); - equal (one, "xxxxx", 32); /* Writeover. */ - equal (one+6, "ghi", 33); /* Wrote too much? */ - - check ((stpcpy (one, "xxxxxx") - one) == 6, 34); - equal (one, "xxxxxx", 35); /* Writeover. */ - equal (one+7, "hi", 36); /* Wrote too much? */ - - check ((stpcpy (one, "xxxxxxx") - one) == 7, 37); - equal (one, "xxxxxxx", 38); /* Writeover. */ - equal (one+8, "i", 39); /* Wrote too much? */ - - check ((stpcpy (stpcpy (stpcpy (one, "a"), "b"), "c") - one) == 3, 40); - equal (one, "abc", 41); - equal (one + 4, "xxx", 42); - - SIMPLE_COPY(stpcpy, 0, "", 43); - SIMPLE_COPY(stpcpy, 1, "1", 44); - SIMPLE_COPY(stpcpy, 2, "22", 45); - SIMPLE_COPY(stpcpy, 3, "333", 46); - SIMPLE_COPY(stpcpy, 4, "4444", 47); - SIMPLE_COPY(stpcpy, 5, "55555", 48); - SIMPLE_COPY(stpcpy, 6, "666666", 49); - SIMPLE_COPY(stpcpy, 7, "7777777", 50); - SIMPLE_COPY(stpcpy, 8, "88888888", 51); - SIMPLE_COPY(stpcpy, 9, "999999999", 52); - SIMPLE_COPY(stpcpy, 10, "0000000000", 53); - SIMPLE_COPY(stpcpy, 11, "11111111111", 54); - SIMPLE_COPY(stpcpy, 12, "222222222222", 55); - SIMPLE_COPY(stpcpy, 13, "3333333333333", 56); - SIMPLE_COPY(stpcpy, 14, "44444444444444", 57); - SIMPLE_COPY(stpcpy, 15, "555555555555555", 58); - SIMPLE_COPY(stpcpy, 16, "6666666666666666", 59); -} - -static void -test_stpncpy (void) -{ - it = "stpncpy"; - memset (one, 'x', sizeof (one)); - check (stpncpy (one, "abc", 2) == one + 2, 1); - check (stpncpy (one, "abc", 3) == one + 3, 2); - check (stpncpy (one, "abc", 4) == one + 3, 3); - check (one[3] == '\0' && one[4] == 'x', 4); - check (stpncpy (one, "abcd", 5) == one + 4, 5); - check (one[4] == '\0' && one[5] == 'x', 6); - check (stpncpy (one, "abcd", 6) == one + 4, 7); - check (one[4] == '\0' && one[5] == '\0' && one[6] == 'x', 8); -} - -static void -test_strcat (void) -{ - it = "strcat"; - (void) strcpy (one, "ijk"); - check (strcat (one, "lmn") == one, 1); /* Returned value. */ - equal (one, "ijklmn", 2); /* Basic test. */ - - (void) strcpy (one, "x"); - (void) strcat (one, "yz"); - equal (one, "xyz", 3); /* Writeover. */ - equal (one+4, "mn", 4); /* Wrote too much? */ - - (void) strcpy (one, "gh"); - (void) strcpy (two, "ef"); - (void) strcat (one, two); - equal (one, "ghef", 5); /* Basic test encore. */ - equal (two, "ef", 6); /* Stomped on source? */ - - (void) strcpy (one, ""); - (void) strcat (one, ""); - equal (one, "", 7); /* Boundary conditions. */ - (void) strcpy (one, "ab"); - (void) strcat (one, ""); - equal (one, "ab", 8); - (void) strcpy (one, ""); - (void) strcat (one, "cd"); - equal (one, "cd", 9); -} - -static void -test_strncat (void) -{ - /* First test it as strcat, with big counts, then test the count - mechanism. */ - it = "strncat"; - (void) strcpy (one, "ijk"); - check (strncat (one, "lmn", 99) == one, 1); /* Returned value. */ - equal (one, "ijklmn", 2); /* Basic test. */ - - (void) strcpy (one, "x"); - (void) strncat (one, "yz", 99); - equal (one, "xyz", 3); /* Writeover. */ - equal (one+4, "mn", 4); /* Wrote too much? */ - - (void) strcpy (one, "gh"); - (void) strcpy (two, "ef"); - (void) strncat (one, two, 99); - equal (one, "ghef", 5); /* Basic test encore. */ |