Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/regress/lib/libc/string Remove regress versions of str* test...



details:   https://anonhg.NetBSD.org/src/rev/f54dfd7d603b
branches:  trunk
changeset: 760078:f54dfd7d603b
user:      pgoyette <pgoyette%NetBSD.org@localhost>
date:      Sat Dec 25 21:13:37 2010 +0000

description:
Remove regress versions of str* tests - they have been atf-ified

diffstat:

 regress/lib/libc/string/Makefile               |    5 +-
 regress/lib/libc/string/memchr/Makefile        |   11 -
 regress/lib/libc/string/memchr/memchr_test.c   |  135 -----------
 regress/lib/libc/string/strcat/Makefile        |   11 -
 regress/lib/libc/string/strcat/strcat_test.c   |  130 ----------
 regress/lib/libc/string/strchr/Makefile        |   11 -
 regress/lib/libc/string/strchr/strchr_test.c   |  300 -------------------------
 regress/lib/libc/string/strcmp/Makefile        |   11 -
 regress/lib/libc/string/strcmp/strcmp_test.c   |  114 ---------
 regress/lib/libc/string/strcpy/Makefile        |   11 -
 regress/lib/libc/string/strcpy/strcpy_test.c   |  124 ----------
 regress/lib/libc/string/strlen/Makefile        |   11 -
 regress/lib/libc/string/strlen/strlen_test.c   |  156 -------------
 regress/lib/libc/string/strrchr/Makefile       |   11 -
 regress/lib/libc/string/strrchr/strrchr_test.c |  256 ---------------------
 15 files changed, 2 insertions(+), 1295 deletions(-)

diffs (truncated from 1360 to 300 lines):

diff -r 202be9a34529 -r f54dfd7d603b regress/lib/libc/string/Makefile
--- a/regress/lib/libc/string/Makefile  Sat Dec 25 21:10:24 2010 +0000
+++ b/regress/lib/libc/string/Makefile  Sat Dec 25 21:13:37 2010 +0000
@@ -1,6 +1,5 @@
-# $NetBSD: Makefile,v 1.9 2006/08/12 23:51:12 christos Exp $
+# $NetBSD: Makefile,v 1.10 2010/12/25 21:13:37 pgoyette Exp $
 
-SUBDIR+= memchr memmem strcat strchr strcmp strcpy strlen strrchr swab wcsncpy\
-       memcpy stresep
+SUBDIR+= memmem swab wcsncpy memcpy stresep
 
 .include <bsd.subdir.mk>
diff -r 202be9a34529 -r f54dfd7d603b regress/lib/libc/string/memchr/Makefile
--- a/regress/lib/libc/string/memchr/Makefile   Sat Dec 25 21:10:24 2010 +0000
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,11 +0,0 @@
-#      $NetBSD: Makefile,v 1.1 2005/03/15 15:57:58 christos Exp $
-
-NOMAN=         # defined
-
-PROG=          memchr_test
-WARNS?=                3
-
-regress: ${PROG}
-       ./${PROG}
-
-.include <bsd.prog.mk>
diff -r 202be9a34529 -r f54dfd7d603b regress/lib/libc/string/memchr/memchr_test.c
--- a/regress/lib/libc/string/memchr/memchr_test.c      Sat Dec 25 21:10:24 2010 +0000
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,135 +0,0 @@
-/*
- * Written by J.T. Conklin <jtc%acorntoolworks.com@localhost>
- * Public domain.
- */
-
-/*
- * str*() regression suite
- *
- * Trivial str*() implementations can be audited by hand.  Optimized
- * versions that unroll loops, use naturally-aligned memory acesses,
- * and "magic" arithmetic sequences to detect zero-bytes, written in
- * assembler are much harder to validate.  This program attempts to
- * catch the corner cases.
- *
- * BUGS:
- *   Misssing checks for strncpy, strncat, strncmp, etc.
- *
- * TODO:
- *   Use mmap/mprotect to ensure the functions don't access memory
- *   across page boundaries.
- *
- *   Consider generating tables programmatically.  It would reduce
- *   the size, but it's also one more thing to go wrong.
- *
- *   Share tables between strlen, strcpy, and strcat?
- *   Share tables between strchr and strrchr?
- */
-
-#include <assert.h>
-#include <string.h>
-
-void check_memchr(void);
-
-void
-check_memchr(void)
-{
-    /* try to trick the compiler */
-    void * (*f)(const void *, int, size_t) = memchr;
-    
-    int a;
-    int t;
-    void * off;
-    char buf[32];
-
-    struct tab {
-       const char      *val;
-       size_t           len;
-       char             match;
-       size_t           off;
-    };
-
-    const struct tab tab[] = {
-       { "",                   0, 0, 0 },
-
-       { "/",                  0, 0, 0 },
-       { "/",                  1, 1, 0 },
-       { "/a",                 2, 1, 0 },
-       { "/ab",                3, 1, 0 },
-       { "/abc",               4, 1, 0 },
-       { "/abcd",              5, 1, 0 },
-       { "/abcde",             6, 1, 0 },
-       { "/abcdef",            7, 1, 0 },
-       { "/abcdefg",           8, 1, 0 },
-
-       { "a/",                 1, 0, 0 },
-       { "a/",                 2, 1, 1 },
-       { "a/b",                3, 1, 1 },
-       { "a/bc",               4, 1, 1 },
-       { "a/bcd",              5, 1, 1 },
-       { "a/bcde",             6, 1, 1 },
-       { "a/bcdef",            7, 1, 1 },
-       { "a/bcdefg",           8, 1, 1 },
-
-       { "ab/",                2, 0, 0 },
-       { "ab/",                3, 1, 2 },
-       { "ab/c",               4, 1, 2 },
-       { "ab/cd",              5, 1, 2 },
-       { "ab/cde",             6, 1, 2 },
-       { "ab/cdef",            7, 1, 2 },
-       { "ab/cdefg",           8, 1, 2 },
-
-       { "abc/",               3, 0, 0 },
-       { "abc/",               4, 1, 3 },
-       { "abc/d",              5, 1, 3 },
-       { "abc/de",             6, 1, 3 },
-       { "abc/def",            7, 1, 3 },
-       { "abc/defg",           8, 1, 3 },
-
-       { "abcd/",              4, 0, 0 },
-       { "abcd/",              5, 1, 4 },
-       { "abcd/e",             6, 1, 4 },
-       { "abcd/ef",            7, 1, 4 },
-       { "abcd/efg",           8, 1, 4 },
-
-       { "abcde/",             5, 0, 0 },
-       { "abcde/",             6, 1, 5 },
-       { "abcde/f",            7, 1, 5 },
-       { "abcde/fg",           8, 1, 5 },
-
-       { "abcdef/",            6, 0, 0 },
-       { "abcdef/",            7, 1, 6 },
-       { "abcdef/g",           8, 1, 6 },
-
-       { "abcdefg/",           7, 0, 0 },
-       { "abcdefg/",           8, 1, 7 },
-
-       { "\xff\xff\xff\xff" "efg/",    8, 1, 7 },
-       { "a" "\xff\xff\xff\xff" "fg/", 8, 1, 7 },
-       { "ab" "\xff\xff\xff\xff" "g/", 8, 1, 7 },
-       { "abc" "\xff\xff\xff\xff" "/", 8, 1, 7 },
-    };
-
-    for (a = 1; a < 1 + sizeof(long); ++a) {
-       for (t = 0; t < (sizeof(tab) / sizeof(tab[0])); ++t) {
-           buf[a-1] = '/';
-           strcpy(&buf[a], tab[t].val);
-           
-           off = f(&buf[a], '/', tab[t].len);
-           assert((tab[t].match == 0 && off == 0) ||
-                  (tab[t].match == 1 && (tab[t].off == ((char*)off - &buf[a]))));
-           
-           // check zero extension of char arg
-           off = f(&buf[a], 0xffffff00 | '/', tab[t].len);
-           assert((tab[t].match == 0 && off == 0) ||
-                  (tab[t].match == 1 && (tab[t].off == ((char*)off - &buf[a]))));
-       }
-    }
-}
-
-int
-main(void)
-{
-       check_memchr();
-       return 0;
-}
diff -r 202be9a34529 -r f54dfd7d603b regress/lib/libc/string/strcat/Makefile
--- a/regress/lib/libc/string/strcat/Makefile   Sat Dec 25 21:10:24 2010 +0000
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,11 +0,0 @@
-#      $NetBSD: Makefile,v 1.1 2005/03/15 15:57:58 christos Exp $
-
-NOMAN=         # defined
-
-PROG=          strcat_test
-WARNS?=                3
-
-regress: ${PROG}
-       ./${PROG}
-
-.include <bsd.prog.mk>
diff -r 202be9a34529 -r f54dfd7d603b regress/lib/libc/string/strcat/strcat_test.c
--- a/regress/lib/libc/string/strcat/strcat_test.c      Sat Dec 25 21:10:24 2010 +0000
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,130 +0,0 @@
-/*
- * Written by J.T. Conklin <jtc%acorntoolworks.com@localhost>
- * Public domain.
- */
-
-/*
- * str*() regression suite
- *
- * Trivial str*() implementations can be audited by hand.  Optimized
- * versions that unroll loops, use naturally-aligned memory acesses,
- * and "magic" arithmetic sequences to detect zero-bytes, written in
- * assembler are much harder to validate.  This program attempts to
- * catch the corner cases.
- *
- * BUGS:
- *   Misssing checks for strncpy, strncat, strncmp, etc.
- *
- * TODO:
- *   Use mmap/mprotect to ensure the functions don't access memory
- *   across page boundaries.
- *
- *   Consider generating tables programmatically.  It would reduce
- *   the size, but it's also one more thing to go wrong.
- *
- *   Share tables between strlen, strcpy, and strcat?
- *   Share tables between strchr and strrchr?
- */
-
-#include <assert.h>
-#include <string.h>
-
-void check_strcat(void);
-
-void
-check_strcat(void)
-{
-    /* try to trick the compiler */
-    char * (*f)(char *, const char *s) = strcat;
-    
-    int a0, a1;
-    int t0, t1;
-    char buf0[64];
-    char buf1[64];
-    char *ret;
-
-    struct tab {
-       const char*     val;
-       size_t          len;
-    };
-
-    const struct tab tab[] = {
-       /*
-        * patterns that check for all combinations of leading and
-        * trailing unaligned characters (on a 64 bit processor)
-        */
-
-       { "",                           0 },
-       { "a",                          1 },
-       { "ab",                         2 },
-       { "abc",                        3 },
-       { "abcd",                       4 },
-       { "abcde",                      5 },
-       { "abcdef",                     6 },
-       { "abcdefg",                    7 },
-       { "abcdefgh",                   8 },
-       { "abcdefghi",                  9 },
-       { "abcdefghij",                 10 },
-       { "abcdefghijk",                11 },
-       { "abcdefghijkl",               12 },
-       { "abcdefghijklm",              13 },
-       { "abcdefghijklmn",             14 },
-       { "abcdefghijklmno",            15 },
-       { "abcdefghijklmnop",           16 },
-       { "abcdefghijklmnopq",          17 },
-       { "abcdefghijklmnopqr",         18 },
-       { "abcdefghijklmnopqrs",        19 },
-       { "abcdefghijklmnopqrst",       20 },
-       { "abcdefghijklmnopqrstu",      21 },
-       { "abcdefghijklmnopqrstuv",     22 },
-       { "abcdefghijklmnopqrstuvw",    23 },
-
-       /*
-        * patterns that check for the cases where the expression:
-        *
-        *      ((word - 0x7f7f..7f) & 0x8080..80)
-        *
-        * returns non-zero even though there are no zero bytes in the
-        * word.
-        */
-
-       { "" "\xff\xff\xff\xff\xff\xff\xff\xff" "abcdefgh",     16 },
-       { "a" "\xff\xff\xff\xff\xff\xff\xff\xff" "bcdefgh",     16 },
-       { "ab" "\xff\xff\xff\xff\xff\xff\xff\xff" "cdefgh",     16 },
-       { "abc" "\xff\xff\xff\xff\xff\xff\xff\xff" "defgh",     16 },
-       { "abcd" "\xff\xff\xff\xff\xff\xff\xff\xff" "efgh",     16 },
-       { "abcde" "\xff\xff\xff\xff\xff\xff\xff\xff" "fgh",     16 },
-       { "abcdef" "\xff\xff\xff\xff\xff\xff\xff\xff" "gh",     16 },
-       { "abcdefg" "\xff\xff\xff\xff\xff\xff\xff\xff" "h",     16 },
-       { "abcdefgh" "\xff\xff\xff\xff\xff\xff\xff\xff" "",     16 },
-    };
-
-    for (a0 = 0; a0 < sizeof(long); ++a0) {
-       for (a1 = 0; a1 < sizeof(long); ++a1) {
-           for (t0 = 0; t0 < (sizeof(tab) / sizeof(tab[0])); ++t0) {
-               for (t1 = 0; t1 < (sizeof(tab) / sizeof(tab[0])); ++t1) {
-                   
-                   memcpy(&buf0[a0], tab[t0].val, tab[t0].len + 1);
-                   memcpy(&buf1[a1], tab[t1].val, tab[t1].len + 1);
-
-                   ret = f(&buf0[a0], &buf1[a1]);
-                   
-                   // verify strcat returns address of first parameter
-                   assert(&buf0[a0] == ret);
-
-                   // verify string was copied correctly



Home | Main Index | Thread Index | Old Index