CVS commit: src/tests/lib/libc/string
Module Name:src Committed By: christos Date: Mon Jan 30 19:49:50 UTC 2023 Modified Files: src/tests/lib/libc/string: Makefile t_strchr.c Added Files: src/tests/lib/libc/string: t_strchrnul.c Log Message: PR/57205: Dag-Erling Sm�rgrav: Add tests strchrnul(3), fix strchr pasto from strlen. To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.13 src/tests/lib/libc/string/Makefile cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libc/string/t_strchr.c cvs rdiff -u -r0 -r1.1 src/tests/lib/libc/string/t_strchrnul.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libc/string/Makefile diff -u src/tests/lib/libc/string/Makefile:1.12 src/tests/lib/libc/string/Makefile:1.13 --- src/tests/lib/libc/string/Makefile:1.12 Thu Dec 19 14:19:28 2019 +++ src/tests/lib/libc/string/Makefile Mon Jan 30 14:49:49 2023 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.12 2019/12/19 19:19:28 macallan Exp $ +# $NetBSD: Makefile,v 1.13 2023/01/30 19:49:49 christos Exp $ .include @@ -15,6 +15,7 @@ TESTS_C+= t_memset TESTS_C+= t_popcount TESTS_C+= t_strcat TESTS_C+= t_strchr +TESTS_C+= t_strchrnul TESTS_C+= t_strcmp TESTS_C+= t_strcoll TESTS_C+= t_strcpy Index: src/tests/lib/libc/string/t_strchr.c diff -u src/tests/lib/libc/string/t_strchr.c:1.2 src/tests/lib/libc/string/t_strchr.c:1.3 --- src/tests/lib/libc/string/t_strchr.c:1.2 Tue Jan 10 10:34:49 2017 +++ src/tests/lib/libc/string/t_strchr.c Mon Jan 30 14:49:49 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: t_strchr.c,v 1.2 2017/01/10 15:34:49 christos Exp $ */ +/* $NetBSD: t_strchr.c,v 1.3 2023/01/30 19:49:49 christos Exp $ */ /* * Written by J.T. Conklin @@ -247,7 +247,7 @@ ATF_TC_BODY(strchr_basic, tc) }; dl_handle = dlopen(NULL, RTLD_LAZY); - strchr_fn = dlsym(dl_handle, "test_strlen"); + strchr_fn = dlsym(dl_handle, "test_strchr"); if (!strchr_fn) strchr_fn = strchr; @@ -269,11 +269,11 @@ ATF_TC_BODY(strchr_basic, tc) /* Then for the '/' in the strings */ verify_strchr(buf + a, '/', t, a); - /* check zero extension of char arg */ - verify_strchr(buf + a, 0xff00 | '/', t, a); + /* check zero extension of char arg */ + verify_strchr(buf + a, 0xff00 | '/', t, a); - /* Replace all the '/' with 0xff */ - while ((off = slow_strchr(buf + a, '/')) != NULL) + /* Replace all the '/' with 0xff */ + while ((off = slow_strchr(buf + a, '/')) != NULL) *off = 0xff; buf[a + len] = 0xff; Added files: Index: src/tests/lib/libc/string/t_strchrnul.c diff -u /dev/null src/tests/lib/libc/string/t_strchrnul.c:1.1 --- /dev/null Mon Jan 30 14:49:50 2023 +++ src/tests/lib/libc/string/t_strchrnul.c Mon Jan 30 14:49:49 2023 @@ -0,0 +1,293 @@ +/* $NetBSD: t_strchrnul.c,v 1.1 2023/01/30 19:49:49 christos Exp $ */ + +/* + * Written by J.T. Conklin + * Public domain. + */ + +#include +#include +#include +#include +#include +#include + +static char *slow_strchrnul(char *, int); +static void verify_strchrnul(char *, int, unsigned int, unsigned int); + +char * (*volatile strchrnul_fn)(const char *, int); + +static char * +slow_strchrnul(char *buf, int ch) +{ + unsigned char c = 1; + + ch &= 0xff; + + for (; ; buf++) { + c = *buf; + if (c == ch || c == 0) + return buf; + } +} + +static void +verify_strchrnul(char *buf, int ch, unsigned int t, unsigned int a) +{ + const char *off, *ok_off; + + off = strchrnul_fn(buf, ch); + ok_off = slow_strchrnul(buf, ch); + if (off == ok_off) + return; + + fprintf(stderr, "test_strchrnul(\"%s\", %#x) gave %zd not %zd (test %d, " + "alignment %d)\n", + buf, ch, off ? off - buf : -1, ok_off ? ok_off - buf : -1, t, a); + + atf_tc_fail("Check stderr for details"); +} + +ATF_TC(strchrnul_basic); +ATF_TC_HEAD(strchrnul_basic, tc) +{ + +atf_tc_set_md_var(tc, "descr", "Test strchrnul(3) results"); +} + +ATF_TC_BODY(strchrnul_basic, tc) +{ + void *dl_handle; + char *off; + char buf[32]; + unsigned int t, a; + + const char *tab[] = { + "", + "a", + "aa", + "abc", + "abcd", + "abcde", + "abcdef", + "abcdefg", + "abcdefgh", + + "/", + "//", + "/a", + "/a/", + "/ab", + "/ab/", + "/abc", + "/abc/", + "/abcd", + "/abcd/", + "/abcde", + "/abcde/", + "/abcdef", + "/abcdef/", + "/abcdefg", + "/abcdefg/", + "/abcdefgh", + "/abcdefgh/", + + "a/", + "a//", + "a/a", + "a/a/", + "a/ab", + "a/ab/", + "a/abc", + "a/abc/", + "a/abcd", + "a/abcd/", + "a/abcde", + "a/abcde/", + "a/abcdef", + "a/abcdef/", + "a/abcdefg", + "a/abcdefg/", + "a/abcdefgh", + "a/abcdefgh/", + + "ab/", + "ab//", + "ab/a", + "ab/a/", + "ab/ab", + "ab/ab/", + "ab/abc", + "ab/abc/", + "ab/abcd", + "ab/abcd/", + "ab/abcde", + "ab/abcde/", + "ab/abcdef", + "ab/abcdef/", + "ab/abcdefg", + "ab/abcdefg/", + "ab/abcdefgh", + "ab/abcdefgh/", + + "abc/", + "abc//", + "abc/a", + "abc/a/", + "abc/ab", + "abc/ab/", + "abc/abc", + "abc/abc/", +
CVS commit: src/tests/lib/libc/string
Module Name:src Committed By: christos Date: Mon Jan 30 19:49:50 UTC 2023 Modified Files: src/tests/lib/libc/string: Makefile t_strchr.c Added Files: src/tests/lib/libc/string: t_strchrnul.c Log Message: PR/57205: Dag-Erling Sm�rgrav: Add tests strchrnul(3), fix strchr pasto from strlen. To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.13 src/tests/lib/libc/string/Makefile cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libc/string/t_strchr.c cvs rdiff -u -r0 -r1.1 src/tests/lib/libc/string/t_strchrnul.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/tests/lib/libc/string
Module Name:src Committed By: christos Date: Fri Nov 27 16:50:02 UTC 2020 Modified Files: src/tests/lib/libc/string: t_memmem.c Log Message: map enough space for both the page we write and the guard so that we make sure we own the guard page before we set its protection to none. This fixes random SEGVs where the page we set protection to none probably belonged to the dynamic linker. Reported by gson@ To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/tests/lib/libc/string/t_memmem.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libc/string/t_memmem.c diff -u src/tests/lib/libc/string/t_memmem.c:1.5 src/tests/lib/libc/string/t_memmem.c:1.6 --- src/tests/lib/libc/string/t_memmem.c:1.5 Fri Nov 27 10:37:06 2020 +++ src/tests/lib/libc/string/t_memmem.c Fri Nov 27 11:50:02 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: t_memmem.c,v 1.5 2020/11/27 15:37:06 gson Exp $ */ +/* $NetBSD: t_memmem.c,v 1.6 2020/11/27 16:50:02 christos Exp $ */ /*- * Copyright (c) 2005 The NetBSD Foundation, Inc. @@ -105,11 +105,12 @@ ATF_TC_BODY(memmem_oob, tc) { static const char str[] = "abcde"; size_t pg = getpagesize(); - char *src = mmap(NULL, pg, PROT_READ|PROT_WRITE, + char *src = mmap(NULL, 2 * pg, PROT_READ|PROT_WRITE, MAP_ANON|MAP_PRIVATE, -1, (off_t)0); ATF_CHECK(src != MAP_FAILED); char *guard = mmap(src + pg, pg, PROT_NONE, MAP_ANON|MAP_PRIVATE|MAP_FIXED, -1, (off_t)0); +printf("%p\n", guard); for (size_t i = 2; i < 5; i++) { char *search = src + pg - i; char match[sizeof(str)];
CVS commit: src/tests/lib/libc/string
Module Name:src Committed By: christos Date: Fri Nov 27 16:50:02 UTC 2020 Modified Files: src/tests/lib/libc/string: t_memmem.c Log Message: map enough space for both the page we write and the guard so that we make sure we own the guard page before we set its protection to none. This fixes random SEGVs where the page we set protection to none probably belonged to the dynamic linker. Reported by gson@ To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/tests/lib/libc/string/t_memmem.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/tests/lib/libc/string
Module Name:src Committed By: gson Date: Fri Nov 27 15:37:06 UTC 2020 Modified Files: src/tests/lib/libc/string: t_memmem.c Log Message: delete trailing whitespace To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/tests/lib/libc/string/t_memmem.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libc/string/t_memmem.c diff -u src/tests/lib/libc/string/t_memmem.c:1.4 src/tests/lib/libc/string/t_memmem.c:1.5 --- src/tests/lib/libc/string/t_memmem.c:1.4 Mon Oct 15 17:55:28 2018 +++ src/tests/lib/libc/string/t_memmem.c Fri Nov 27 15:37:06 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: t_memmem.c,v 1.4 2018/10/15 17:55:28 christos Exp $ */ +/* $NetBSD: t_memmem.c,v 1.5 2020/11/27 15:37:06 gson Exp $ */ /*- * Copyright (c) 2005 The NetBSD Foundation, Inc. @@ -107,7 +107,7 @@ ATF_TC_BODY(memmem_oob, tc) size_t pg = getpagesize(); char *src = mmap(NULL, pg, PROT_READ|PROT_WRITE, MAP_ANON|MAP_PRIVATE, -1, (off_t)0); - ATF_CHECK(src != MAP_FAILED); + ATF_CHECK(src != MAP_FAILED); char *guard = mmap(src + pg, pg, PROT_NONE, MAP_ANON|MAP_PRIVATE|MAP_FIXED, -1, (off_t)0); for (size_t i = 2; i < 5; i++) {
CVS commit: src/tests/lib/libc/string
Module Name:src Committed By: gson Date: Fri Nov 27 15:37:06 UTC 2020 Modified Files: src/tests/lib/libc/string: t_memmem.c Log Message: delete trailing whitespace To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/tests/lib/libc/string/t_memmem.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/tests/lib/libc/string
Module Name:src Committed By: macallan Date: Thu Dec 19 19:19:28 UTC 2019 Modified Files: src/tests/lib/libc/string: Makefile Log Message: disable string op warnings for t_strcat now this builds on macppc with gcc 8.3 from riastradh@ To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/tests/lib/libc/string/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/tests/lib/libc/string
Module Name:src Committed By: macallan Date: Thu Dec 19 19:19:28 UTC 2019 Modified Files: src/tests/lib/libc/string: Makefile Log Message: disable string op warnings for t_strcat now this builds on macppc with gcc 8.3 from riastradh@ To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/tests/lib/libc/string/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libc/string/Makefile diff -u src/tests/lib/libc/string/Makefile:1.11 src/tests/lib/libc/string/Makefile:1.12 --- src/tests/lib/libc/string/Makefile:1.11 Mon Oct 15 17:55:28 2018 +++ src/tests/lib/libc/string/Makefile Thu Dec 19 19:19:28 2019 @@ -1,10 +1,12 @@ -# $NetBSD: Makefile,v 1.11 2018/10/15 17:55:28 christos Exp $ +# $NetBSD: Makefile,v 1.12 2019/12/19 19:19:28 macallan Exp $ .include TESTSDIR= ${TESTSBASE}/lib/libc/string DBG=-g +COPTS.t_strcat.c+= ${GCC_NO_STRINGOP_TRUNCATION} + TESTS_C+= t_bm TESTS_C+= t_memchr TESTS_C+= t_memcpy
CVS commit: src/tests/lib/libc/string
Module Name:src Committed By: christos Date: Mon Oct 15 17:55:28 UTC 2018 Modified Files: src/tests/lib/libc/string: Makefile t_memmem.c Log Message: simple memmem test to show buffer overrun. To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/tests/lib/libc/string/Makefile cvs rdiff -u -r1.3 -r1.4 src/tests/lib/libc/string/t_memmem.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libc/string/Makefile diff -u src/tests/lib/libc/string/Makefile:1.10 src/tests/lib/libc/string/Makefile:1.11 --- src/tests/lib/libc/string/Makefile:1.10 Thu May 25 21:24:19 2017 +++ src/tests/lib/libc/string/Makefile Mon Oct 15 13:55:28 2018 @@ -1,8 +1,9 @@ -# $NetBSD: Makefile,v 1.10 2017/05/26 01:24:19 perseant Exp $ +# $NetBSD: Makefile,v 1.11 2018/10/15 17:55:28 christos Exp $ .include TESTSDIR= ${TESTSBASE}/lib/libc/string +DBG=-g TESTS_C+= t_bm TESTS_C+= t_memchr Index: src/tests/lib/libc/string/t_memmem.c diff -u src/tests/lib/libc/string/t_memmem.c:1.3 src/tests/lib/libc/string/t_memmem.c:1.4 --- src/tests/lib/libc/string/t_memmem.c:1.3 Wed Jan 11 13:07:37 2017 +++ src/tests/lib/libc/string/t_memmem.c Mon Oct 15 13:55:28 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: t_memmem.c,v 1.3 2017/01/11 18:07:37 christos Exp $ */ +/* $NetBSD: t_memmem.c,v 1.4 2018/10/15 17:55:28 christos Exp $ */ /*- * Copyright (c) 2005 The NetBSD Foundation, Inc. @@ -34,6 +34,7 @@ #include #include #include +#include char p0[] = ""; int lp0 = 0; @@ -94,10 +95,40 @@ ATF_TC_BODY(memmem_basic, tc) expect(memmem(b2, lb2, p8, lp8) == NULL); } +ATF_TC(memmem_oob); +ATF_TC_HEAD(memmem_oob, tc) +{ + atf_tc_set_md_var(tc, "descr", "Test memmem out of bounds read"); +} + +ATF_TC_BODY(memmem_oob, tc) +{ + static const char str[] = "abcde"; + size_t pg = getpagesize(); + char *src = mmap(NULL, pg, PROT_READ|PROT_WRITE, + MAP_ANON|MAP_PRIVATE, -1, (off_t)0); + ATF_CHECK(src != MAP_FAILED); + char *guard = mmap(src + pg, pg, + PROT_NONE, MAP_ANON|MAP_PRIVATE|MAP_FIXED, -1, (off_t)0); + for (size_t i = 2; i < 5; i++) { + char *search = src + pg - i; + char match[sizeof(str)]; + search[-1] = str[0]; + search[0] = str[0]; + search[1] = str[0]; + memcpy(match, str, i); + ATF_CHECK(memmem(search, i, match, i) != search); + } + munmap(guard, pg); + munmap(src, pg); +} + + ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, memmem_basic); + ATF_TP_ADD_TC(tp, memmem_oob); return atf_no_error(); }
CVS commit: src/tests/lib/libc/string
Module Name:src Committed By: christos Date: Mon Oct 15 17:55:28 UTC 2018 Modified Files: src/tests/lib/libc/string: Makefile t_memmem.c Log Message: simple memmem test to show buffer overrun. To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/tests/lib/libc/string/Makefile cvs rdiff -u -r1.3 -r1.4 src/tests/lib/libc/string/t_memmem.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/tests/lib/libc/string
Module Name:src Committed By: christos Date: Wed Aug 23 10:29:51 UTC 2017 Modified Files: src/tests/lib/libc/string: t_stresep.c Log Message: Add test from PR/52499 To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/tests/lib/libc/string/t_stresep.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libc/string/t_stresep.c diff -u src/tests/lib/libc/string/t_stresep.c:1.3 src/tests/lib/libc/string/t_stresep.c:1.4 --- src/tests/lib/libc/string/t_stresep.c:1.3 Fri Feb 15 18:56:32 2013 +++ src/tests/lib/libc/string/t_stresep.c Wed Aug 23 06:29:51 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: t_stresep.c,v 1.3 2013/02/15 23:56:32 christos Exp $ */ +/* $NetBSD: t_stresep.c,v 1.4 2017/08/23 10:29:51 christos Exp $ */ /*- * Copyright (c) 2005 The NetBSD Foundation, Inc. @@ -61,6 +61,12 @@ ATF_TC_BODY(stresep_basic, tc) expect("bar foo"); expect(" baz"); expect("bar "); + + char brkstr2[] = "aa bb cc\\ \\ \\ \\ dd-"; + q = brkstr2; + expect("aa"); + expect("bb"); + expect("ccdd-"); } ATF_TP_ADD_TCS(tp)
CVS commit: src/tests/lib/libc/string
Module Name:src Committed By: christos Date: Wed Aug 23 10:29:51 UTC 2017 Modified Files: src/tests/lib/libc/string: t_stresep.c Log Message: Add test from PR/52499 To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/tests/lib/libc/string/t_stresep.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/tests/lib/libc/string
Module Name:src Committed By: perseant Date: Fri May 26 01:24:19 UTC 2017 Modified Files: src/tests/lib/libc/string: Makefile Added Files: src/tests/lib/libc/string: t_strcoll.c Log Message: Add simple expect-fail test case for strcoll(3) To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/tests/lib/libc/string/Makefile cvs rdiff -u -r0 -r1.1 src/tests/lib/libc/string/t_strcoll.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/tests/lib/libc/string
Module Name:src Committed By: perseant Date: Fri May 26 01:24:19 UTC 2017 Modified Files: src/tests/lib/libc/string: Makefile Added Files: src/tests/lib/libc/string: t_strcoll.c Log Message: Add simple expect-fail test case for strcoll(3) To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/tests/lib/libc/string/Makefile cvs rdiff -u -r0 -r1.1 src/tests/lib/libc/string/t_strcoll.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libc/string/Makefile diff -u src/tests/lib/libc/string/Makefile:1.9 src/tests/lib/libc/string/Makefile:1.10 --- src/tests/lib/libc/string/Makefile:1.9 Mon Jun 23 10:53:20 2014 +++ src/tests/lib/libc/string/Makefile Fri May 26 01:24:19 2017 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.9 2014/06/23 10:53:20 shm Exp $ +# $NetBSD: Makefile,v 1.10 2017/05/26 01:24:19 perseant Exp $ .include @@ -13,6 +13,7 @@ TESTS_C+= t_popcount TESTS_C+= t_strcat TESTS_C+= t_strchr TESTS_C+= t_strcmp +TESTS_C+= t_strcoll TESTS_C+= t_strcpy TESTS_C+= t_strcspn TESTS_C+= t_strerror Added files: Index: src/tests/lib/libc/string/t_strcoll.c diff -u /dev/null src/tests/lib/libc/string/t_strcoll.c:1.1 --- /dev/null Fri May 26 01:24:19 2017 +++ src/tests/lib/libc/string/t_strcoll.c Fri May 26 01:24:19 2017 @@ -0,0 +1,106 @@ +/* $NetBSD: t_strcoll.c,v 1.1 2017/05/26 01:24:19 perseant Exp $ */ + +/*- + * Copyright (c) 2017 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Konrad Schroder + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + *notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + *notice, this list of conditions and the following disclaimer in the + *documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include +__COPYRIGHT("@(#) Copyright (c) 2017\ + The NetBSD Foundation, inc. All rights reserved."); +__RCSID("$NetBSD: t_strcoll.c,v 1.1 2017/05/26 01:24:19 perseant Exp $"); + +#include +#include +#include +#include + +#include + +static struct test { + const char *locale; + const char * const data[5]; +} tests[] = { + { + "C", + { "aardvark", "absolution", "zyzygy", NULL }, + }, { + "ru_RU.KOI8-R", + { "\xc5\xc4\xcf\xcb", "\xa3\xd6", "\xc5\xda\xc4\xc9\xd4\xd8", NULL }, + }, { + NULL, + { NULL, NULL, NULL, NULL }, + } +}; + +static void +h_ordering(const struct test *t) +{ + const char * const *a; + const char * const *b; + char buf_a[1024], buf_b[1024]; + + ATF_REQUIRE_STREQ(setlocale(LC_ALL, "C"), "C"); + printf("Trying locale %s...\n", t->locale); + ATF_REQUIRE(setlocale(LC_COLLATE, t->locale) != NULL); + + for (a = t->data; *a != NULL; ++a) { + strvis(buf_a, *a, VIS_WHITE | VIS_OCTAL); + for (b = a + 1; *b != NULL; ++b) { + strvis(buf_b, *b, VIS_WHITE | VIS_OCTAL); + printf("Checking \"%s\" < \"%s\"\n", buf_a, buf_b); + ATF_REQUIRE(strcoll(*a, *b) < 0); + printf("...good\n"); + } + } +} + +ATF_TC(ordering); + +ATF_TC_HEAD(ordering, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Checks collation ordering under diferent locales"); +} + +ATF_TC_BODY(ordering, tc) +{ + struct test *t; + + atf_tc_expect_fail("%s", "LC_COLLATE not supported"); + for (t = [0]; t->locale != NULL; ++t) + h_ordering(t); + atf_tc_expect_pass(); +} + +ATF_TP_ADD_TCS(tp) +{ + + ATF_TP_ADD_TC(tp, ordering); + + return atf_no_error(); +}
CVS commit: src/tests/lib/libc/string
Module Name:src Committed By: christos Date: Sat Jan 14 20:49:24 UTC 2017 Modified Files: src/tests/lib/libc/string: t_strlen.c Log Message: PR/51815: Ngie Cooper: don't leak dlopen'ed handle To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/tests/lib/libc/string/t_strlen.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/tests/lib/libc/string
Module Name:src Committed By: christos Date: Sat Jan 14 20:49:24 UTC 2017 Modified Files: src/tests/lib/libc/string: t_strlen.c Log Message: PR/51815: Ngie Cooper: don't leak dlopen'ed handle To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/tests/lib/libc/string/t_strlen.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libc/string/t_strlen.c diff -u src/tests/lib/libc/string/t_strlen.c:1.5 src/tests/lib/libc/string/t_strlen.c:1.6 --- src/tests/lib/libc/string/t_strlen.c:1.5 Thu Jul 14 03:33:20 2011 +++ src/tests/lib/libc/string/t_strlen.c Sat Jan 14 15:49:24 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: t_strlen.c,v 1.5 2011/07/14 07:33:20 jruoho Exp $ */ +/* $NetBSD: t_strlen.c,v 1.6 2017/01/14 20:49:24 christos Exp $ */ /* * Written by J.T. Conklin@@ -40,6 +40,7 @@ ATF_TC_HEAD(strlen_basic, tc) ATF_TC_BODY(strlen_basic, tc) { + void *dl_handle; /* try to trick the compiler */ size_t (*strlen_fn)(const char *); @@ -107,7 +108,8 @@ ATF_TC_BODY(strlen_basic, tc) * During testing it is useful have the rest of the program * use a known good version! */ - strlen_fn = dlsym(dlopen(NULL, RTLD_LAZY), "test_strlen"); + dl_handle = dlopen(NULL, RTLD_LAZY); + strlen_fn = dlsym(dl_handle, "test_strlen"); if (!strlen_fn) strlen_fn = strlen; @@ -134,6 +136,7 @@ ATF_TC_BODY(strlen_basic, tc) } } } + (void)dlclose(dl_handle); } ATF_TC(strlen_huge);
CVS commit: src/tests/lib/libc/string
Module Name:src Committed By: christos Date: Wed Jan 11 18:07:37 UTC 2017 Modified Files: src/tests/lib/libc/string: t_memmem.c Log Message: PR/51822: Ngie Cooper: add additional t_memmem check To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libc/string/t_memmem.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/tests/lib/libc/string
Module Name:src Committed By: christos Date: Wed Jan 11 18:07:37 UTC 2017 Modified Files: src/tests/lib/libc/string: t_memmem.c Log Message: PR/51822: Ngie Cooper: add additional t_memmem check To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libc/string/t_memmem.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libc/string/t_memmem.c diff -u src/tests/lib/libc/string/t_memmem.c:1.2 src/tests/lib/libc/string/t_memmem.c:1.3 --- src/tests/lib/libc/string/t_memmem.c:1.2 Thu Jul 7 04:27:36 2011 +++ src/tests/lib/libc/string/t_memmem.c Wed Jan 11 13:07:37 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: t_memmem.c,v 1.2 2011/07/07 08:27:36 jruoho Exp $ */ +/* $NetBSD: t_memmem.c,v 1.3 2017/01/11 18:07:37 christos Exp $ */ /*- * Copyright (c) 2005 The NetBSD Foundation, Inc. @@ -51,6 +51,8 @@ char p6[] = "9"; int lp6 = 1; char p7[] = "654"; int lp7 = 3; +char p8[] = "89abc"; +int lp8 = 5; char b0[] = ""; int lb0 = 0; @@ -89,6 +91,7 @@ ATF_TC_BODY(memmem_basic, tc) expect(memmem(b2, lb2, p4, lp4) == NULL); expect(memmem(b2, lb2, p7, lp7) == NULL); + expect(memmem(b2, lb2, p8, lp8) == NULL); } ATF_TP_ADD_TCS(tp)
CVS commit: src/tests/lib/libc/string
Module Name:src Committed By: christos Date: Wed Jan 11 18:05:54 UTC 2017 Modified Files: src/tests/lib/libc/string: t_memcpy.c Log Message: PR/51823: Ngie Cooper: Add output diagnostic if memcmp of the md5 string fails To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/tests/lib/libc/string/t_memcpy.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libc/string/t_memcpy.c diff -u src/tests/lib/libc/string/t_memcpy.c:1.5 src/tests/lib/libc/string/t_memcpy.c:1.6 --- src/tests/lib/libc/string/t_memcpy.c:1.5 Sat Mar 16 22:23:31 2013 +++ src/tests/lib/libc/string/t_memcpy.c Wed Jan 11 13:05:54 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: t_memcpy.c,v 1.5 2013/03/17 02:23:31 christos Exp $ */ +/* $NetBSD: t_memcpy.c,v 1.6 2017/01/11 18:05:54 christos Exp $ */ /*- * Copyright (c) 2010 The NetBSD Foundation, Inc. @@ -96,7 +96,8 @@ ATF_TC_BODY(memcpy_basic, tc) if (i != j) runTest(start[i], start[j]); MD5End(mc, result); - ATF_REQUIRE_EQ(strcmp(result, goodResult), 0); + ATF_REQUIRE_EQ_MSG(strcmp(result, goodResult), 0, "%s != %s", + result, goodResult); } ATF_TC(memccpy_simple);
CVS commit: src/tests/lib/libc/string
Module Name:src Committed By: christos Date: Wed Jan 11 18:05:54 UTC 2017 Modified Files: src/tests/lib/libc/string: t_memcpy.c Log Message: PR/51823: Ngie Cooper: Add output diagnostic if memcmp of the md5 string fails To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/tests/lib/libc/string/t_memcpy.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/tests/lib/libc/string
Module Name:src Committed By: christos Date: Tue Jan 10 20:35:49 UTC 2017 Modified Files: src/tests/lib/libc/string: t_strerror.c Log Message: add To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/tests/lib/libc/string/t_strerror.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/tests/lib/libc/string
Module Name:src Committed By: christos Date: Tue Jan 10 20:35:49 UTC 2017 Modified Files: src/tests/lib/libc/string: t_strerror.c Log Message: add To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/tests/lib/libc/string/t_strerror.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libc/string/t_strerror.c diff -u src/tests/lib/libc/string/t_strerror.c:1.3 src/tests/lib/libc/string/t_strerror.c:1.4 --- src/tests/lib/libc/string/t_strerror.c:1.3 Tue May 10 02:55:27 2011 +++ src/tests/lib/libc/string/t_strerror.c Tue Jan 10 15:35:49 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: t_strerror.c,v 1.3 2011/05/10 06:55:27 jruoho Exp $ */ +/* $NetBSD: t_strerror.c,v 1.4 2017/01/10 20:35:49 christos Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -29,10 +29,11 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__RCSID("$NetBSD: t_strerror.c,v 1.3 2011/05/10 06:55:27 jruoho Exp $"); +__RCSID("$NetBSD: t_strerror.c,v 1.4 2017/01/10 20:35:49 christos Exp $"); #include #include +#include /* Needed for sys_nerr on FreeBSD */ #include #include #include
CVS commit: src/tests/lib/libc/string
Module Name:src Committed By: christos Date: Tue Jan 10 15:34:49 UTC 2017 Modified Files: src/tests/lib/libc/string: t_strchr.c Log Message: PR/51815: Ngie Cooper: don't leak dlopen'ed handle To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libc/string/t_strchr.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libc/string/t_strchr.c diff -u src/tests/lib/libc/string/t_strchr.c:1.1 src/tests/lib/libc/string/t_strchr.c:1.2 --- src/tests/lib/libc/string/t_strchr.c:1.1 Thu Jul 7 04:59:33 2011 +++ src/tests/lib/libc/string/t_strchr.c Tue Jan 10 10:34:49 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: t_strchr.c,v 1.1 2011/07/07 08:59:33 jruoho Exp $ */ +/* $NetBSD: t_strchr.c,v 1.2 2017/01/10 15:34:49 christos Exp $ */ /* * Written by J.T. Conklin@@ -58,9 +58,10 @@ ATF_TC_HEAD(strchr_basic, tc) ATF_TC_BODY(strchr_basic, tc) { - unsigned int t, a; + void *dl_handle; char *off; char buf[32]; + unsigned int t, a; const char *tab[] = { "", @@ -245,8 +246,8 @@ ATF_TC_BODY(strchr_basic, tc) "abcdefgh/abcdefgh/", }; - - strchr_fn = dlsym(dlopen(0, RTLD_LAZY), "test_strchr"); + dl_handle = dlopen(NULL, RTLD_LAZY); + strchr_fn = dlsym(dl_handle, "test_strlen"); if (!strchr_fn) strchr_fn = strchr; @@ -281,6 +282,7 @@ ATF_TC_BODY(strchr_basic, tc) verify_strchr(buf + a, 0xff, t, a); } } + (void)dlclose(dl_handle); } ATF_TP_ADD_TCS(tp)
CVS commit: src/tests/lib/libc/string
Module Name:src Committed By: christos Date: Tue Jan 10 15:34:49 UTC 2017 Modified Files: src/tests/lib/libc/string: t_strchr.c Log Message: PR/51815: Ngie Cooper: don't leak dlopen'ed handle To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libc/string/t_strchr.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/tests/lib/libc/string
Module Name:src Committed By: martin Date: Fri Sep 11 09:25:52 UTC 2015 Modified Files: src/tests/lib/libc/string: t_memset.c Log Message: Add two test cases that should cover PR 50228. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/tests/lib/libc/string/t_memset.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/tests/lib/libc/string
Module Name:src Committed By: martin Date: Fri Sep 11 09:25:52 UTC 2015 Modified Files: src/tests/lib/libc/string: t_memset.c Log Message: Add two test cases that should cover PR 50228. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/tests/lib/libc/string/t_memset.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libc/string/t_memset.c diff -u src/tests/lib/libc/string/t_memset.c:1.3 src/tests/lib/libc/string/t_memset.c:1.4 --- src/tests/lib/libc/string/t_memset.c:1.3 Sun Mar 17 02:23:31 2013 +++ src/tests/lib/libc/string/t_memset.c Fri Sep 11 09:25:52 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: t_memset.c,v 1.3 2013/03/17 02:23:31 christos Exp $ */ +/* $NetBSD: t_memset.c,v 1.4 2015/09/11 09:25:52 martin Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__RCSID("$NetBSD: t_memset.c,v 1.3 2013/03/17 02:23:31 christos Exp $"); +__RCSID("$NetBSD: t_memset.c,v 1.4 2015/09/11 09:25:52 martin Exp $"); #include @@ -42,6 +42,8 @@ static long page = 0; static void fill(char *, size_t, char); static bool check(char *, size_t, char); +int zero; /* always zero, but the compiler does not know */ + ATF_TC(memset_array); ATF_TC_HEAD(memset_array, tc) { @@ -133,6 +135,50 @@ ATF_TC_BODY(memset_nonzero, tc) free(buf); } +ATF_TC(memset_zero_size); + +ATF_TC_HEAD(memset_zero_size, tc) +{ + atf_tc_set_md_var(tc, "descr", "Test memset(3) with zero size"); +} + +ATF_TC_BODY(memset_zero_size, tc) +{ + char buf[1024]; + + (void)memset(buf, 'x', sizeof(buf)); + + if (check(buf, sizeof(buf), 'x') != true) + atf_tc_fail("memset(3) did not fill a static buffer"); + + (void)memset(buf+sizeof(buf)/2, 0, zero); + + if (check(buf, sizeof(buf), 'x') != true) + atf_tc_fail("memset(3) with 0 size did change the buffer"); +} + +ATF_TC(bzero_zero_size); + +ATF_TC_HEAD(bzero_zero_size, tc) +{ + atf_tc_set_md_var(tc, "descr", "Test bzero(3) with zero size"); +} + +ATF_TC_BODY(bzero_zero_size, tc) +{ + char buf[1024]; + + (void)memset(buf, 'x', sizeof(buf)); + + if (check(buf, sizeof(buf), 'x') != true) + atf_tc_fail("memset(3) did not fill a static buffer"); + + (void)bzero(buf+sizeof(buf)/2, zero); + + if (check(buf, sizeof(buf), 'x') != true) + atf_tc_fail("bzero(3) with 0 size did change the buffer"); +} + ATF_TC(memset_struct); ATF_TC_HEAD(memset_struct, tc) { @@ -202,6 +248,8 @@ ATF_TP_ADD_TCS(tp) ATF_TP_ADD_TC(tp, memset_nonzero); ATF_TP_ADD_TC(tp, memset_struct); ATF_TP_ADD_TC(tp, memset_return); + ATF_TP_ADD_TC(tp, memset_zero_size); + ATF_TP_ADD_TC(tp, bzero_zero_size); return atf_no_error(); }
CVS commit: src/tests/lib/libc/string
Module Name:src Committed By: christos Date: Sun Mar 17 02:23:31 UTC 2013 Modified Files: src/tests/lib/libc/string: t_memcpy.c t_memset.c Log Message: check return values To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/tests/lib/libc/string/t_memcpy.c cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libc/string/t_memset.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libc/string/t_memcpy.c diff -u src/tests/lib/libc/string/t_memcpy.c:1.4 src/tests/lib/libc/string/t_memcpy.c:1.5 --- src/tests/lib/libc/string/t_memcpy.c:1.4 Thu Jul 14 01:46:04 2011 +++ src/tests/lib/libc/string/t_memcpy.c Sat Mar 16 22:23:31 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: t_memcpy.c,v 1.4 2011/07/14 05:46:04 jruoho Exp $ */ +/* $NetBSD: t_memcpy.c,v 1.5 2013/03/17 02:23:31 christos Exp $ */ /*- * Copyright (c) 2010 The NetBSD Foundation, Inc. @@ -125,10 +125,25 @@ ATF_TC_BODY(memccpy_simple, tc) ATF_CHECK(strncmp(buf, xxx, 7) == 0); } +ATF_TC(memcpy_return); +ATF_TC_HEAD(memcpy_return, tc) +{ + atf_tc_set_md_var(tc, descr, Test memcpy(3) return value); +} + +ATF_TC_BODY(memcpy_return, tc) +{ + char *b = (char *)0x1; + char c[2]; + ATF_REQUIRE_EQ(memcpy(b, b, 0), b); + ATF_REQUIRE_EQ(memcpy(c, ab, sizeof(c)), c); +} + ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, memcpy_basic); + ATF_TP_ADD_TC(tp, memcpy_return); ATF_TP_ADD_TC(tp, memccpy_simple); return atf_no_error(); Index: src/tests/lib/libc/string/t_memset.c diff -u src/tests/lib/libc/string/t_memset.c:1.2 src/tests/lib/libc/string/t_memset.c:1.3 --- src/tests/lib/libc/string/t_memset.c:1.2 Thu Jul 14 03:33:20 2011 +++ src/tests/lib/libc/string/t_memset.c Sat Mar 16 22:23:31 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: t_memset.c,v 1.2 2011/07/14 07:33:20 jruoho Exp $ */ +/* $NetBSD: t_memset.c,v 1.3 2013/03/17 02:23:31 christos Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include sys/cdefs.h -__RCSID($NetBSD: t_memset.c,v 1.2 2011/07/14 07:33:20 jruoho Exp $); +__RCSID($NetBSD: t_memset.c,v 1.3 2013/03/17 02:23:31 christos Exp $); #include sys/stat.h @@ -63,6 +63,20 @@ ATF_TC_BODY(memset_array, tc) atf_tc_fail(memset(3) did not fill a static buffer); } +ATF_TC(memset_return); +ATF_TC_HEAD(memset_return, tc) +{ + atf_tc_set_md_var(tc, descr, Test memset(3) return value); +} + +ATF_TC_BODY(memset_return, tc) +{ + char *b = (char *)0x1; + char c[2]; + ATF_REQUIRE_EQ(memset(b, 0, 0), b); + ATF_REQUIRE_EQ(memset(c, 2, sizeof(c)), c); +} + ATF_TC(memset_basic); ATF_TC_HEAD(memset_basic, tc) { @@ -187,6 +201,7 @@ ATF_TP_ADD_TCS(tp) ATF_TP_ADD_TC(tp, memset_basic); ATF_TP_ADD_TC(tp, memset_nonzero); ATF_TP_ADD_TC(tp, memset_struct); + ATF_TP_ADD_TC(tp, memset_return); return atf_no_error(); }
CVS commit: src/tests/lib/libc/string
Module Name:src Committed By: christos Date: Sun Mar 17 02:23:31 UTC 2013 Modified Files: src/tests/lib/libc/string: t_memcpy.c t_memset.c Log Message: check return values To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/tests/lib/libc/string/t_memcpy.c cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libc/string/t_memset.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/tests/lib/libc/string
Module Name:src Committed By: christos Date: Fri Feb 15 23:56:32 UTC 2013 Modified Files: src/tests/lib/libc/string: t_stresep.c Log Message: don't brk the build. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libc/string/t_stresep.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libc/string/t_stresep.c diff -u src/tests/lib/libc/string/t_stresep.c:1.2 src/tests/lib/libc/string/t_stresep.c:1.3 --- src/tests/lib/libc/string/t_stresep.c:1.2 Thu Jul 7 04:27:36 2011 +++ src/tests/lib/libc/string/t_stresep.c Fri Feb 15 18:56:32 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: t_stresep.c,v 1.2 2011/07/07 08:27:36 jruoho Exp $ */ +/* $NetBSD: t_stresep.c,v 1.3 2013/02/15 23:56:32 christos Exp $ */ /*- * Copyright (c) 2005 The NetBSD Foundation, Inc. @@ -51,9 +51,9 @@ ATF_TC_HEAD(stresep_basic, tc) ATF_TC_BODY(stresep_basic, tc) { - char brk[] = foo\\ \\ bar baz bar\\ foo\\ bar\\ \\ foo \\ \\ \\ + char brkstr[] = foo\\ \\ bar baz bar\\ foo\\ bar\\ \\ foo \\ \\ \\ baz bar\\ \\ ; - char *p, *q = brk; + char *p, *q = brkstr; expect(foo bar); expect(baz);
CVS commit: src/tests/lib/libc/string
Module Name:src Committed By: christos Date: Fri Feb 15 23:56:32 UTC 2013 Modified Files: src/tests/lib/libc/string: t_stresep.c Log Message: don't brk the build. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libc/string/t_stresep.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/tests/lib/libc/string
Module Name:src Committed By: jruoho Date: Fri Apr 6 07:53:11 UTC 2012 Modified Files: src/tests/lib/libc/string: t_memchr.c Log Message: Adjust. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libc/string/t_memchr.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libc/string/t_memchr.c diff -u src/tests/lib/libc/string/t_memchr.c:1.2 src/tests/lib/libc/string/t_memchr.c:1.3 --- src/tests/lib/libc/string/t_memchr.c:1.2 Thu Jul 14 05:46:04 2011 +++ src/tests/lib/libc/string/t_memchr.c Fri Apr 6 07:53:10 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: t_memchr.c,v 1.2 2011/07/14 05:46:04 jruoho Exp $ */ +/* $NetBSD: t_memchr.c,v 1.3 2012/04/06 07:53:10 jruoho Exp $ */ /* * Written by J.T. Conklin j...@acorntoolworks.com @@ -169,7 +169,6 @@ ATF_TC_HEAD(memrchr_simple, tc) ATF_TC_BODY(memrchr_simple, tc) { char buf[] = abcdabcd; - short i = 8; ATF_CHECK(memrchr(buf, 'a', 0) == NULL); ATF_CHECK(memrchr(buf, 'g', 0) == NULL); @@ -178,15 +177,10 @@ ATF_TC_BODY(memrchr_simple, tc) ATF_CHECK(memrchr(\0, 'x', 0) == NULL); ATF_CHECK(memrchr(\0, 'x', 1) == NULL); - while (i = 16) { - - ATF_CHECK(memrchr(buf, 'a', i) == buf + 4); - ATF_CHECK(memrchr(buf, 'b', i) == buf + 5); - ATF_CHECK(memrchr(buf, 'c', i) == buf + 6); - ATF_CHECK(memrchr(buf, 'd', i) == buf + 7); - - i *= 2; - } + ATF_CHECK(memrchr(buf, 'a', 8) == buf + 4); + ATF_CHECK(memrchr(buf, 'b', 8) == buf + 5); + ATF_CHECK(memrchr(buf, 'c', 8) == buf + 6); + ATF_CHECK(memrchr(buf, 'd', 8) == buf + 7); } ATF_TP_ADD_TCS(tp)
CVS commit: src/tests/lib/libc/string
Module Name:src Committed By: jruoho Date: Fri Apr 6 07:53:11 UTC 2012 Modified Files: src/tests/lib/libc/string: t_memchr.c Log Message: Adjust. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libc/string/t_memchr.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/tests/lib/libc/string
Module Name:src Committed By: jruoho Date: Thu Jul 14 07:33:20 UTC 2011 Modified Files: src/tests/lib/libc/string: t_memset.c t_strcmp.c t_strlen.c Log Message: Use ATF_CHECK() when appropriate. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libc/string/t_memset.c cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libc/string/t_strcmp.c cvs rdiff -u -r1.4 -r1.5 src/tests/lib/libc/string/t_strlen.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libc/string/t_memset.c diff -u src/tests/lib/libc/string/t_memset.c:1.1 src/tests/lib/libc/string/t_memset.c:1.2 --- src/tests/lib/libc/string/t_memset.c:1.1 Fri Jun 3 06:39:52 2011 +++ src/tests/lib/libc/string/t_memset.c Thu Jul 14 07:33:20 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: t_memset.c,v 1.1 2011/06/03 06:39:52 jruoho Exp $ */ +/* $NetBSD: t_memset.c,v 1.2 2011/07/14 07:33:20 jruoho Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include sys/cdefs.h -__RCSID($NetBSD: t_memset.c,v 1.1 2011/06/03 06:39:52 jruoho Exp $); +__RCSID($NetBSD: t_memset.c,v 1.2 2011/07/14 07:33:20 jruoho Exp $); #include sys/stat.h @@ -142,16 +142,16 @@ (void)memset(st, 0, sizeof(struct stat)); - ATF_REQUIRE(st.st_dev == 0); - ATF_REQUIRE(st.st_ino == 0); - ATF_REQUIRE(st.st_mode == 0); - ATF_REQUIRE(st.st_nlink == 0); - ATF_REQUIRE(st.st_uid == 0); - ATF_REQUIRE(st.st_gid == 0); - ATF_REQUIRE(st.st_rdev == 0); - ATF_REQUIRE(st.st_size == 0); - ATF_REQUIRE(st.st_atime == 0); - ATF_REQUIRE(st.st_mtime == 0); + ATF_CHECK(st.st_dev == 0); + ATF_CHECK(st.st_ino == 0); + ATF_CHECK(st.st_mode == 0); + ATF_CHECK(st.st_nlink == 0); + ATF_CHECK(st.st_uid == 0); + ATF_CHECK(st.st_gid == 0); + ATF_CHECK(st.st_rdev == 0); + ATF_CHECK(st.st_size == 0); + ATF_CHECK(st.st_atime == 0); + ATF_CHECK(st.st_mtime == 0); } static void Index: src/tests/lib/libc/string/t_strcmp.c diff -u src/tests/lib/libc/string/t_strcmp.c:1.2 src/tests/lib/libc/string/t_strcmp.c:1.3 --- src/tests/lib/libc/string/t_strcmp.c:1.2 Thu Jul 7 09:31:27 2011 +++ src/tests/lib/libc/string/t_strcmp.c Thu Jul 14 07:33:20 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: t_strcmp.c,v 1.2 2011/07/07 09:31:27 jruoho Exp $ */ +/* $NetBSD: t_strcmp.c,v 1.3 2011/07/14 07:33:20 jruoho Exp $ */ /* * Written by J.T. Conklin j...@acorntoolworks.com @@ -108,22 +108,22 @@ char buf1[10] = xxx; char buf2[10] = xxy; - ATF_REQUIRE(strcmp(buf1, buf1) == 0); - ATF_REQUIRE(strcmp(buf2, buf2) == 0); + ATF_CHECK(strcmp(buf1, buf1) == 0); + ATF_CHECK(strcmp(buf2, buf2) == 0); - ATF_REQUIRE(strcmp(xöx, xox) 0); - ATF_REQUIRE(strcmp(xxx, xxxyyy) 0); - ATF_REQUIRE(strcmp(xxxyyy, xxx) 0); - - ATF_REQUIRE(strcmp(buf1 + 0, buf2 + 0) 0); - ATF_REQUIRE(strcmp(buf1 + 1, buf2 + 1) 0); - ATF_REQUIRE(strcmp(buf1 + 2, buf2 + 2) 0); - ATF_REQUIRE(strcmp(buf1 + 3, buf2 + 3) == 0); - - ATF_REQUIRE(strcmp(buf2 + 0, buf1 + 0) 0); - ATF_REQUIRE(strcmp(buf2 + 1, buf1 + 1) 0); - ATF_REQUIRE(strcmp(buf2 + 2, buf1 + 2) 0); - ATF_REQUIRE(strcmp(buf2 + 3, buf1 + 3) == 0); + ATF_CHECK(strcmp(xöx, xox) 0); + ATF_CHECK(strcmp(xxx, xxxyyy) 0); + ATF_CHECK(strcmp(xxxyyy, xxx) 0); + + ATF_CHECK(strcmp(buf1 + 0, buf2 + 0) 0); + ATF_CHECK(strcmp(buf1 + 1, buf2 + 1) 0); + ATF_CHECK(strcmp(buf1 + 2, buf2 + 2) 0); + ATF_CHECK(strcmp(buf1 + 3, buf2 + 3) == 0); + + ATF_CHECK(strcmp(buf2 + 0, buf1 + 0) 0); + ATF_CHECK(strcmp(buf2 + 1, buf1 + 1) 0); + ATF_CHECK(strcmp(buf2 + 2, buf1 + 2) 0); + ATF_CHECK(strcmp(buf2 + 3, buf1 + 3) == 0); } ATF_TP_ADD_TCS(tp) Index: src/tests/lib/libc/string/t_strlen.c diff -u src/tests/lib/libc/string/t_strlen.c:1.4 src/tests/lib/libc/string/t_strlen.c:1.5 --- src/tests/lib/libc/string/t_strlen.c:1.4 Tue Jul 12 12:08:07 2011 +++ src/tests/lib/libc/string/t_strlen.c Thu Jul 14 07:33:20 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: t_strlen.c,v 1.4 2011/07/12 12:08:07 njoly Exp $ */ +/* $NetBSD: t_strlen.c,v 1.5 2011/07/14 07:33:20 jruoho Exp $ */ /* * Written by J.T. Conklin j...@acorntoolworks.com @@ -178,14 +178,14 @@ buf[0] = '\0'; - ATF_REQUIRE(strnlen(buf, 000) == 0); - ATF_REQUIRE(strnlen(buf, 111) == 0); + ATF_CHECK(strnlen(buf, 000) == 0); + ATF_CHECK(strnlen(buf, 111) == 0); - ATF_REQUIRE(strnlen(xxx, 0) == 0); - ATF_REQUIRE(strnlen(xxx, 1) == 1); - ATF_REQUIRE(strnlen(xxx, 2) == 2); - ATF_REQUIRE(strnlen(xxx, 3) == 3); - ATF_REQUIRE(strnlen(xxx, 9) == 3); + ATF_CHECK(strnlen(xxx, 0) == 0); + ATF_CHECK(strnlen(xxx, 1) == 1); + ATF_CHECK(strnlen(xxx, 2) == 2); + ATF_CHECK(strnlen(xxx, 3) == 3); + ATF_CHECK(strnlen(xxx, 9) == 3); } ATF_TP_ADD_TCS(tp)
CVS commit: src/tests/lib/libc/string
Module Name:src Committed By: jruoho Date: Thu Jul 14 07:33:20 UTC 2011 Modified Files: src/tests/lib/libc/string: t_memset.c t_strcmp.c t_strlen.c Log Message: Use ATF_CHECK() when appropriate. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libc/string/t_memset.c cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libc/string/t_strcmp.c cvs rdiff -u -r1.4 -r1.5 src/tests/lib/libc/string/t_strlen.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/tests/lib/libc/string
Module Name:src Committed By: jruoho Date: Thu Jul 14 05:46:04 UTC 2011 Modified Files: src/tests/lib/libc/string: t_memchr.c t_memcpy.c t_strcat.c Log Message: Add few simple test cases. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libc/string/t_memchr.c \ src/tests/lib/libc/string/t_strcat.c cvs rdiff -u -r1.3 -r1.4 src/tests/lib/libc/string/t_memcpy.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libc/string/t_memchr.c diff -u src/tests/lib/libc/string/t_memchr.c:1.1 src/tests/lib/libc/string/t_memchr.c:1.2 --- src/tests/lib/libc/string/t_memchr.c:1.1 Thu Jul 7 08:59:32 2011 +++ src/tests/lib/libc/string/t_memchr.c Thu Jul 14 05:46:04 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: t_memchr.c,v 1.1 2011/07/07 08:59:32 jruoho Exp $ */ +/* $NetBSD: t_memchr.c,v 1.2 2011/07/14 05:46:04 jruoho Exp $ */ /* * Written by J.T. Conklin j...@acorntoolworks.com @@ -14,7 +14,7 @@ ATF_TC(memchr_basic); ATF_TC_HEAD(memchr_basic, tc) { -atf_tc_set_md_var(tc, descr, Test memchr(3) results); +atf_tc_set_md_var(tc, descr, Test memchr(3) results, #1); } ATF_TC_BODY(memchr_basic, tc) @@ -128,10 +128,73 @@ } } +ATF_TC(memchr_simple); +ATF_TC_HEAD(memchr_simple, tc) +{ +atf_tc_set_md_var(tc, descr, Test memchr(3) results, #2); +} + +ATF_TC_BODY(memchr_simple, tc) +{ + char buf[] = abcdefg; + short i = 7; + + ATF_CHECK(memchr(buf, 'a', 0) == NULL); + ATF_CHECK(memchr(buf, 'g', 0) == NULL); + ATF_CHECK(memchr(buf, 'x', 7) == NULL); + + ATF_CHECK(memchr(\0, 'x', 0) == NULL); + ATF_CHECK(memchr(\0, 'x', 1) == NULL); + + while (i = 14) { + + ATF_CHECK(memchr(buf, 'a', i) == buf + 0); + ATF_CHECK(memchr(buf, 'b', i) == buf + 1); + ATF_CHECK(memchr(buf, 'c', i) == buf + 2); + ATF_CHECK(memchr(buf, 'd', i) == buf + 3); + ATF_CHECK(memchr(buf, 'e', i) == buf + 4); + ATF_CHECK(memchr(buf, 'f', i) == buf + 5); + ATF_CHECK(memchr(buf, 'g', i) == buf + 6); + + i *= 2; + } +} + +ATF_TC(memrchr_simple); +ATF_TC_HEAD(memrchr_simple, tc) +{ +atf_tc_set_md_var(tc, descr, Test memrchr(3) results); +} + +ATF_TC_BODY(memrchr_simple, tc) +{ + char buf[] = abcdabcd; + short i = 8; + + ATF_CHECK(memrchr(buf, 'a', 0) == NULL); + ATF_CHECK(memrchr(buf, 'g', 0) == NULL); + ATF_CHECK(memrchr(buf, 'x', 8) == NULL); + + ATF_CHECK(memrchr(\0, 'x', 0) == NULL); + ATF_CHECK(memrchr(\0, 'x', 1) == NULL); + + while (i = 16) { + + ATF_CHECK(memrchr(buf, 'a', i) == buf + 4); + ATF_CHECK(memrchr(buf, 'b', i) == buf + 5); + ATF_CHECK(memrchr(buf, 'c', i) == buf + 6); + ATF_CHECK(memrchr(buf, 'd', i) == buf + 7); + + i *= 2; + } +} + ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, memchr_basic); + ATF_TP_ADD_TC(tp, memchr_simple); + ATF_TP_ADD_TC(tp, memrchr_simple); return atf_no_error(); } Index: src/tests/lib/libc/string/t_strcat.c diff -u src/tests/lib/libc/string/t_strcat.c:1.1 src/tests/lib/libc/string/t_strcat.c:1.2 --- src/tests/lib/libc/string/t_strcat.c:1.1 Thu Jul 7 08:59:32 2011 +++ src/tests/lib/libc/string/t_strcat.c Thu Jul 14 05:46:04 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: t_strcat.c,v 1.1 2011/07/07 08:59:32 jruoho Exp $ */ +/* $NetBSD: t_strcat.c,v 1.2 2011/07/14 05:46:04 jruoho Exp $ */ /* * Written by J.T. Conklin j...@acorntoolworks.com @@ -123,10 +123,31 @@ } } +ATF_TC(strncat_simple); +ATF_TC_HEAD(strncat_simple, tc) +{ +atf_tc_set_md_var(tc, descr, Test strncat(3) results); +} + +ATF_TC_BODY(strncat_simple, tc) +{ + char buf[100] = abcdefg; + + ATF_CHECK(strncat(buf, xxx, 0) == buf); + ATF_CHECK(strcmp(buf, abcdefg) == 0); + ATF_CHECK(strncat(buf, xxx, 1) == buf); + ATF_CHECK(strcmp(buf, abcdefgx) == 0); + ATF_CHECK(strncat(buf, xxx, 2) == buf); + ATF_CHECK(strcmp(buf, abcdefgxxx) == 0); + ATF_CHECK(strncat(buf, \0, 1) == buf); + ATF_CHECK(strcmp(buf, abcdefgxxx) == 0); +} + ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, strcat_basic); + ATF_TP_ADD_TC(tp, strncat_simple); return atf_no_error(); } Index: src/tests/lib/libc/string/t_memcpy.c diff -u src/tests/lib/libc/string/t_memcpy.c:1.3 src/tests/lib/libc/string/t_memcpy.c:1.4 --- src/tests/lib/libc/string/t_memcpy.c:1.3 Thu Jul 7 08:27:36 2011 +++ src/tests/lib/libc/string/t_memcpy.c Thu Jul 14 05:46:04 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: t_memcpy.c,v 1.3 2011/07/07 08:27:36 jruoho Exp $ */ +/* $NetBSD: t_memcpy.c,v 1.4 2011/07/14 05:46:04 jruoho Exp $ */ /*- * Copyright (c) 2010 The NetBSD Foundation, Inc. @@ -99,10 +99,37 @@ ATF_REQUIRE_EQ(strcmp(result, goodResult), 0); } +ATF_TC(memccpy_simple); +ATF_TC_HEAD(memccpy_simple, tc) +{ +atf_tc_set_md_var(tc, descr, Test memccpy(3) results); +} + +ATF_TC_BODY(memccpy_simple, tc) +{ + char buf[100]; + char c = ' '; + + (void)memset(buf, c, sizeof(buf)); + + ATF_CHECK(memccpy(buf, foo bar, c, sizeof(buf)) != NULL); + ATF_CHECK(buf[4] == c); + + ATF_CHECK(memccpy(buf, foo bar, '\0', sizeof(buf)
CVS commit: src/tests/lib/libc/string
Module Name:src Committed By: jruoho Date: Thu Jul 14 05:46:04 UTC 2011 Modified Files: src/tests/lib/libc/string: t_memchr.c t_memcpy.c t_strcat.c Log Message: Add few simple test cases. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libc/string/t_memchr.c \ src/tests/lib/libc/string/t_strcat.c cvs rdiff -u -r1.3 -r1.4 src/tests/lib/libc/string/t_memcpy.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/tests/lib/libc/string
Module Name:src Committed By: njoly Date: Tue Jul 12 12:08:07 UTC 2011 Modified Files: src/tests/lib/libc/string: t_strlen.c Log Message: Fix off-by-one in strlen_huge testcase. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/tests/lib/libc/string/t_strlen.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libc/string/t_strlen.c diff -u src/tests/lib/libc/string/t_strlen.c:1.3 src/tests/lib/libc/string/t_strlen.c:1.4 --- src/tests/lib/libc/string/t_strlen.c:1.3 Thu Jul 7 09:31:27 2011 +++ src/tests/lib/libc/string/t_strlen.c Tue Jul 12 12:08:07 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: t_strlen.c,v 1.3 2011/07/07 09:31:27 jruoho Exp $ */ +/* $NetBSD: t_strlen.c,v 1.4 2011/07/12 12:08:07 njoly Exp $ */ /* * Written by J.T. Conklin j...@acorntoolworks.com @@ -159,7 +159,7 @@ continue; (void)memset(str, 'x', i * page); - str[i * page + 1] = '\0'; + str[i * page] = '\0'; ATF_REQUIRE(strlen(str) == i * page); free(str);
CVS commit: src/tests/lib/libc/string
Module Name:src Committed By: njoly Date: Tue Jul 12 12:08:07 UTC 2011 Modified Files: src/tests/lib/libc/string: t_strlen.c Log Message: Fix off-by-one in strlen_huge testcase. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/tests/lib/libc/string/t_strlen.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/tests/lib/libc/string
Module Name:src Committed By: jruoho Date: Thu Jul 7 08:27:36 UTC 2011 Modified Files: src/tests/lib/libc/string: t_memcpy.c t_memmem.c t_popcount.c t_stresep.c t_swab.c Log Message: Rename some test case names for consistency. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libc/string/t_memcpy.c cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libc/string/t_memmem.c \ src/tests/lib/libc/string/t_stresep.c src/tests/lib/libc/string/t_swab.c cvs rdiff -u -r1.3 -r1.4 src/tests/lib/libc/string/t_popcount.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libc/string/t_memcpy.c diff -u src/tests/lib/libc/string/t_memcpy.c:1.2 src/tests/lib/libc/string/t_memcpy.c:1.3 --- src/tests/lib/libc/string/t_memcpy.c:1.2 Thu Apr 7 18:14:09 2011 +++ src/tests/lib/libc/string/t_memcpy.c Thu Jul 7 08:27:36 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: t_memcpy.c,v 1.2 2011/04/07 18:14:09 jruoho Exp $ */ +/* $NetBSD: t_memcpy.c,v 1.3 2011/07/07 08:27:36 jruoho Exp $ */ /*- * Copyright (c) 2010 The NetBSD Foundation, Inc. @@ -75,15 +75,13 @@ } } -ATF_TC(check_memcpy); - -ATF_TC_HEAD(check_memcpy, tc) +ATF_TC(memcpy_basic); +ATF_TC_HEAD(memcpy_basic, tc) { - atf_tc_set_md_var(tc, descr, Test memcpy results); } - -ATF_TC_BODY(check_memcpy, tc) + +ATF_TC_BODY(memcpy_basic, tc) { int i, j; testBlock_t auto1, auto2; @@ -104,7 +102,7 @@ ATF_TP_ADD_TCS(tp) { - ATF_TP_ADD_TC(tp, check_memcpy); + ATF_TP_ADD_TC(tp, memcpy_basic); return atf_no_error(); } Index: src/tests/lib/libc/string/t_memmem.c diff -u src/tests/lib/libc/string/t_memmem.c:1.1 src/tests/lib/libc/string/t_memmem.c:1.2 --- src/tests/lib/libc/string/t_memmem.c:1.1 Sun Dec 26 13:35:54 2010 +++ src/tests/lib/libc/string/t_memmem.c Thu Jul 7 08:27:36 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: t_memmem.c,v 1.1 2010/12/26 13:35:54 pgoyette Exp $ */ +/* $NetBSD: t_memmem.c,v 1.2 2011/07/07 08:27:36 jruoho Exp $ */ /*- * Copyright (c) 2005 The NetBSD Foundation, Inc. @@ -65,15 +65,14 @@ atf_tc_fail(Check stderr for test id/line); \ } -ATF_TC(check_memmem); - -ATF_TC_HEAD(check_memmem, tc) +ATF_TC(memmem_basic); +ATF_TC_HEAD(memmem_basic, tc) { atf_tc_set_md_var(tc, descr, Test memmem results); } -ATF_TC_BODY(check_memmem, tc) +ATF_TC_BODY(memmem_basic, tc) { expect(memmem(b2, lb2, p0, lp0) == b2); @@ -95,7 +94,7 @@ ATF_TP_ADD_TCS(tp) { - ATF_TP_ADD_TC(tp, check_memmem); + ATF_TP_ADD_TC(tp, memmem_basic); return atf_no_error(); } Index: src/tests/lib/libc/string/t_stresep.c diff -u src/tests/lib/libc/string/t_stresep.c:1.1 src/tests/lib/libc/string/t_stresep.c:1.2 --- src/tests/lib/libc/string/t_stresep.c:1.1 Sun Dec 26 13:35:54 2010 +++ src/tests/lib/libc/string/t_stresep.c Thu Jul 7 08:27:36 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: t_stresep.c,v 1.1 2010/12/26 13:35:54 pgoyette Exp $ */ +/* $NetBSD: t_stresep.c,v 1.2 2011/07/07 08:27:36 jruoho Exp $ */ /*- * Copyright (c) 2005 The NetBSD Foundation, Inc. @@ -42,15 +42,14 @@ atf_tc_fail(Check stderr for test id/line); \ } -ATF_TC(check_stresep); - -ATF_TC_HEAD(check_stresep, tc) +ATF_TC(stresep_basic); +ATF_TC_HEAD(stresep_basic, tc) { atf_tc_set_md_var(tc, descr, Test stresep results); } -ATF_TC_BODY(check_stresep, tc) +ATF_TC_BODY(stresep_basic, tc) { char brk[] = foo\\ \\ bar baz bar\\ foo\\ bar\\ \\ foo \\ \\ \\ baz bar\\ \\ ; @@ -67,7 +66,7 @@ ATF_TP_ADD_TCS(tp) { - ATF_TP_ADD_TC(tp, check_stresep); + ATF_TP_ADD_TC(tp, stresep_basic); return atf_no_error(); } Index: src/tests/lib/libc/string/t_swab.c diff -u src/tests/lib/libc/string/t_swab.c:1.1 src/tests/lib/libc/string/t_swab.c:1.2 --- src/tests/lib/libc/string/t_swab.c:1.1 Sun Dec 26 13:35:54 2010 +++ src/tests/lib/libc/string/t_swab.c Thu Jul 7 08:27:36 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: t_swab.c,v 1.1 2010/12/26 13:35:54 pgoyette Exp $ */ +/* $NetBSD: t_swab.c,v 1.2 2011/07/07 08:27:36 jruoho Exp $ */ /*- * Copyright (c) 2001 The NetBSD Foundation, Inc. @@ -61,15 +61,14 @@ printf(\n); } -ATF_TC(check_swab); - -ATF_TC_HEAD(check_swab, tc) +ATF_TC(swab_basic); +ATF_TC_HEAD(swab_basic, tc) { atf_tc_set_md_var(tc, descr, Test swab results); } -ATF_TC_BODY(check_swab, tc) +ATF_TC_BODY(swab_basic, tc) { char a[MAXCHK], b[MAXCHK], r[MAXCHK]; size_t i; @@ -90,7 +89,7 @@ ATF_TP_ADD_TCS(tp) { - ATF_TP_ADD_TC(tp, check_swab); + ATF_TP_ADD_TC(tp, swab_basic); return atf_no_error(); } Index: src/tests/lib/libc/string/t_popcount.c diff -u src/tests/lib/libc/string/t_popcount.c:1.3 src/tests/lib/libc/string/t_popcount.c:1.4 --- src/tests/lib/libc/string/t_popcount.c:1.3 Sun Dec 26 13:29:47 2010 +++ src/tests/lib/libc/string/t_popcount.c Thu Jul 7 08:27:36 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: t_popcount.c,v 1.3 2010/12/26 13:29:47 pgoyette Exp $ */ +/* $NetBSD: t_popcount.c,v 1.4 2011/07/07
CVS commit: src/tests/lib/libc/string
Module Name:src Committed By: jruoho Date: Thu Jul 7 09:16:06 UTC 2011 Modified Files: src/tests/lib/libc/string: t_strlen.c Log Message: Add one simple test case. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libc/string/t_strlen.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libc/string/t_strlen.c diff -u src/tests/lib/libc/string/t_strlen.c:1.1 src/tests/lib/libc/string/t_strlen.c:1.2 --- src/tests/lib/libc/string/t_strlen.c:1.1 Thu Jul 7 08:59:33 2011 +++ src/tests/lib/libc/string/t_strlen.c Thu Jul 7 09:16:06 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: t_strlen.c,v 1.1 2011/07/07 08:59:33 jruoho Exp $ */ +/* $NetBSD: t_strlen.c,v 1.2 2011/07/07 09:16:06 jruoho Exp $ */ /* * Written by J.T. Conklin j...@acorntoolworks.com @@ -11,6 +11,7 @@ #include stdio.h #include stdlib.h #include dlfcn.h +#include unistd.h static void write_num(int); @@ -135,10 +136,41 @@ } } +ATF_TC(strlen_huge); +ATF_TC_HEAD(strlen_huge, tc) +{ +atf_tc_set_md_var(tc, descr, Test strlen(3) with huge strings); +} + +ATF_TC_BODY(strlen_huge, tc) +{ + long page; + char *str; + size_t i; + + page = sysconf(_SC_PAGESIZE); + ATF_REQUIRE(page = 0); + + for (i = 1; i 1000; i = i + 100) { + + str = malloc(i * page + 1); + + if (str == NULL) + continue; + + (void)memset(str, 'x', i * page); + str[i * page + 1] = '\0'; + + ATF_REQUIRE(strlen(str) == i * page); + free(str); + } +} + ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, strlen_basic); + ATF_TP_ADD_TC(tp, strlen_huge); return atf_no_error(); }
CVS commit: src/tests/lib/libc/string
Module Name:src Committed By: jruoho Date: Thu Jul 7 09:31:27 UTC 2011 Modified Files: src/tests/lib/libc/string: t_strcmp.c t_strlen.c Log Message: Few basic checks, including a case for strnlen(3). To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libc/string/t_strcmp.c cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libc/string/t_strlen.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libc/string/t_strcmp.c diff -u src/tests/lib/libc/string/t_strcmp.c:1.1 src/tests/lib/libc/string/t_strcmp.c:1.2 --- src/tests/lib/libc/string/t_strcmp.c:1.1 Thu Jul 7 08:59:33 2011 +++ src/tests/lib/libc/string/t_strcmp.c Thu Jul 7 09:31:27 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: t_strcmp.c,v 1.1 2011/07/07 08:59:33 jruoho Exp $ */ +/* $NetBSD: t_strcmp.c,v 1.2 2011/07/07 09:31:27 jruoho Exp $ */ /* * Written by J.T. Conklin j...@acorntoolworks.com @@ -14,7 +14,7 @@ ATF_TC(strcmp_basic); ATF_TC_HEAD(strcmp_basic, tc) { -atf_tc_set_md_var(tc, descr, Test strcmp(3) results); +atf_tc_set_md_var(tc, descr, Test strcmp(3) results, #1); } ATF_TC_BODY(strcmp_basic, tc) @@ -97,10 +97,40 @@ } } +ATF_TC(strcmp_simple); +ATF_TC_HEAD(strcmp_simple, tc) +{ +atf_tc_set_md_var(tc, descr, Test strcmp(3) results, #2); +} + +ATF_TC_BODY(strcmp_simple, tc) +{ + char buf1[10] = xxx; + char buf2[10] = xxy; + + ATF_REQUIRE(strcmp(buf1, buf1) == 0); + ATF_REQUIRE(strcmp(buf2, buf2) == 0); + + ATF_REQUIRE(strcmp(xöx, xox) 0); + ATF_REQUIRE(strcmp(xxx, xxxyyy) 0); + ATF_REQUIRE(strcmp(xxxyyy, xxx) 0); + + ATF_REQUIRE(strcmp(buf1 + 0, buf2 + 0) 0); + ATF_REQUIRE(strcmp(buf1 + 1, buf2 + 1) 0); + ATF_REQUIRE(strcmp(buf1 + 2, buf2 + 2) 0); + ATF_REQUIRE(strcmp(buf1 + 3, buf2 + 3) == 0); + + ATF_REQUIRE(strcmp(buf2 + 0, buf1 + 0) 0); + ATF_REQUIRE(strcmp(buf2 + 1, buf1 + 1) 0); + ATF_REQUIRE(strcmp(buf2 + 2, buf1 + 2) 0); + ATF_REQUIRE(strcmp(buf2 + 3, buf1 + 3) == 0); +} + ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, strcmp_basic); + ATF_TP_ADD_TC(tp, strcmp_simple); return atf_no_error(); } Index: src/tests/lib/libc/string/t_strlen.c diff -u src/tests/lib/libc/string/t_strlen.c:1.2 src/tests/lib/libc/string/t_strlen.c:1.3 --- src/tests/lib/libc/string/t_strlen.c:1.2 Thu Jul 7 09:16:06 2011 +++ src/tests/lib/libc/string/t_strlen.c Thu Jul 7 09:31:27 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: t_strlen.c,v 1.2 2011/07/07 09:16:06 jruoho Exp $ */ +/* $NetBSD: t_strlen.c,v 1.3 2011/07/07 09:31:27 jruoho Exp $ */ /* * Written by J.T. Conklin j...@acorntoolworks.com @@ -166,11 +166,34 @@ } } +ATF_TC(strnlen_basic); +ATF_TC_HEAD(strnlen_basic, tc) +{ +atf_tc_set_md_var(tc, descr, A naive test of strnlen(3)); +} + +ATF_TC_BODY(strnlen_basic, tc) +{ + char buf[1]; + + buf[0] = '\0'; + + ATF_REQUIRE(strnlen(buf, 000) == 0); + ATF_REQUIRE(strnlen(buf, 111) == 0); + + ATF_REQUIRE(strnlen(xxx, 0) == 0); + ATF_REQUIRE(strnlen(xxx, 1) == 1); + ATF_REQUIRE(strnlen(xxx, 2) == 2); + ATF_REQUIRE(strnlen(xxx, 3) == 3); + ATF_REQUIRE(strnlen(xxx, 9) == 3); +} + ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, strlen_basic); ATF_TP_ADD_TC(tp, strlen_huge); + ATF_TP_ADD_TC(tp, strnlen_basic); return atf_no_error(); }
CVS commit: src/tests/lib/libc/string
Module Name:src Committed By: jruoho Date: Thu Jul 7 08:27:36 UTC 2011 Modified Files: src/tests/lib/libc/string: t_memcpy.c t_memmem.c t_popcount.c t_stresep.c t_swab.c Log Message: Rename some test case names for consistency. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libc/string/t_memcpy.c cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libc/string/t_memmem.c \ src/tests/lib/libc/string/t_stresep.c src/tests/lib/libc/string/t_swab.c cvs rdiff -u -r1.3 -r1.4 src/tests/lib/libc/string/t_popcount.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/tests/lib/libc/string
Module Name:src Committed By: jruoho Date: Thu Jul 7 09:16:06 UTC 2011 Modified Files: src/tests/lib/libc/string: t_strlen.c Log Message: Add one simple test case. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libc/string/t_strlen.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/tests/lib/libc/string
Module Name:src Committed By: jruoho Date: Thu Jul 7 09:31:27 UTC 2011 Modified Files: src/tests/lib/libc/string: t_strcmp.c t_strlen.c Log Message: Few basic checks, including a case for strnlen(3). To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libc/string/t_strcmp.c cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libc/string/t_strlen.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/tests/lib/libc/string
Module Name:src Committed By: jruoho Date: Tue May 10 06:55:27 UTC 2011 Modified Files: src/tests/lib/libc/string: t_strerror.c Log Message: Fix typo. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libc/string/t_strerror.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libc/string/t_strerror.c diff -u src/tests/lib/libc/string/t_strerror.c:1.2 src/tests/lib/libc/string/t_strerror.c:1.3 --- src/tests/lib/libc/string/t_strerror.c:1.2 Mon May 9 06:05:54 2011 +++ src/tests/lib/libc/string/t_strerror.c Tue May 10 06:55:27 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: t_strerror.c,v 1.2 2011/05/09 06:05:54 jruoho Exp $ */ +/* $NetBSD: t_strerror.c,v 1.3 2011/05/10 06:55:27 jruoho Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include sys/cdefs.h -__RCSID($NetBSD: t_strerror.c,v 1.2 2011/05/09 06:05:54 jruoho Exp $); +__RCSID($NetBSD: t_strerror.c,v 1.3 2011/05/10 06:55:27 jruoho Exp $); #include atf-c.h #include errno.h @@ -77,7 +77,7 @@ ATF_TC(strerror_r_basic); ATF_TC_HEAD(strerror_r_basic, tc) { - atf_tc_set_md_var(tc, descr, A basic test of strerrorr_(3)); + atf_tc_set_md_var(tc, descr, A basic test of strerror_r(3)); } ATF_TC_BODY(strerror_r_basic, tc)
CVS commit: src/tests/lib/libc/string
Module Name:src Committed By: jruoho Date: Tue May 10 06:55:27 UTC 2011 Modified Files: src/tests/lib/libc/string: t_strerror.c Log Message: Fix typo. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libc/string/t_strerror.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/tests/lib/libc/string
Module Name:src Committed By: jruoho Date: Mon May 9 06:05:54 UTC 2011 Modified Files: src/tests/lib/libc/string: t_strerror.c Log Message: List the ATF_TC_() thins in the order of appearance. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libc/string/t_strerror.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libc/string/t_strerror.c diff -u src/tests/lib/libc/string/t_strerror.c:1.1 src/tests/lib/libc/string/t_strerror.c:1.2 --- src/tests/lib/libc/string/t_strerror.c:1.1 Mon May 9 06:04:14 2011 +++ src/tests/lib/libc/string/t_strerror.c Mon May 9 06:05:54 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: t_strerror.c,v 1.1 2011/05/09 06:04:14 jruoho Exp $ */ +/* $NetBSD: t_strerror.c,v 1.2 2011/05/09 06:05:54 jruoho Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include sys/cdefs.h -__RCSID($NetBSD: t_strerror.c,v 1.1 2011/05/09 06:04:14 jruoho Exp $); +__RCSID($NetBSD: t_strerror.c,v 1.2 2011/05/09 06:05:54 jruoho Exp $); #include atf-c.h #include errno.h @@ -43,6 +43,17 @@ atf_tc_set_md_var(tc, descr, A basic test of strerror(3)); } +ATF_TC_BODY(strerror_basic, tc) +{ + int i; + + for (i = 1; i sys_nerr; i++) + ATF_REQUIRE(strstr(strerror(i), Unknown error:) == NULL); + + for (; i sys_nerr + 10; i++) + ATF_REQUIRE(strstr(strerror(i), Unknown error:) != NULL); +} + ATF_TC(strerror_err); ATF_TC_HEAD(strerror_err, tc) { @@ -63,17 +74,6 @@ ATF_REQUIRE(errno == EINVAL); } -ATF_TC_BODY(strerror_basic, tc) -{ - int i; - - for (i = 1; i sys_nerr; i++) - ATF_REQUIRE(strstr(strerror(i), Unknown error:) == NULL); - - for (; i sys_nerr + 10; i++) - ATF_REQUIRE(strstr(strerror(i), Unknown error:) != NULL); -} - ATF_TC(strerror_r_basic); ATF_TC_HEAD(strerror_r_basic, tc) {
CVS commit: src/tests/lib/libc/string
Module Name:src Committed By: jruoho Date: Mon May 9 06:05:54 UTC 2011 Modified Files: src/tests/lib/libc/string: t_strerror.c Log Message: List the ATF_TC_() thins in the order of appearance. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libc/string/t_strerror.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/tests/lib/libc/string
Module Name:src Committed By: pgoyette Date: Sun Dec 26 13:29:47 UTC 2010 Modified Files: src/tests/lib/libc/string: t_popcount.c Log Message: Make running this test conditional on the setting of atf configuration variable run_popcount. This is a really long-running test (it takes several hours on a qemu-emulation on a 2.8GHz AMD Pheno II) but could still be useful if you want to run it manually, with the command atf-run -v run_popcount=YES To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libc/string/t_popcount.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libc/string/t_popcount.c diff -u src/tests/lib/libc/string/t_popcount.c:1.2 src/tests/lib/libc/string/t_popcount.c:1.3 --- src/tests/lib/libc/string/t_popcount.c:1.2 Tue Jul 21 21:45:33 2009 +++ src/tests/lib/libc/string/t_popcount.c Sun Dec 26 13:29:47 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: t_popcount.c,v 1.2 2009/07/21 21:45:33 drochner Exp $ */ +/* $NetBSD: t_popcount.c,v 1.3 2010/12/26 13:29:47 pgoyette Exp $ */ /*- * Copyright (c) 2009 The NetBSD Foundation, Inc. * All rights reserved. @@ -32,7 +32,7 @@ */ #include sys/cdefs.h -__RCSID($NetBSD: t_popcount.c,v 1.2 2009/07/21 21:45:33 drochner Exp $); +__RCSID($NetBSD: t_popcount.c,v 1.3 2010/12/26 13:29:47 pgoyette Exp $); #include atf-c.h #include strings.h @@ -40,17 +40,26 @@ static unsigned int byte_count[256]; static void -popcount_init(void) +popcount_init(const char *cfg_var) { unsigned int i, j; - for (i = 0; i 256; ++i) { - byte_count[i] = 0; - for (j = i; j != 0; j = 1) { - if (j 1) -++byte_count[i]; + if (strcasecmp(cfg_var, YES) == 0 || + strcasecmp(cfg_var, Y)== 0 || + strcasecmp(cfg_var, 1)== 0 || + strcasecmp(cfg_var, T)== 0 || + strcasecmp(cfg_var, TRUE) == 0) { + for (i = 0; i 256; ++i) { + byte_count[i] = 0; + for (j = i; j != 0; j = 1) { +if (j 1) + ++byte_count[i]; + } } + return; } + + atf_tc_skip(config variable \run_popcount\ not set to YES/TRUE); } unsigned int test_parts[256] = { @@ -121,17 +130,11 @@ }; ATF_TC(t_popcount); -ATF_TC(t_popcountll); ATF_TC_HEAD(t_popcount, tc) { - atf_tc_set_md_var(tc, descr, Test popcount results); - atf_tc_set_md_var(tc, timeout, 0); -} -ATF_TC_HEAD(t_popcountll, tc) -{ - atf_tc_set_md_var(tc, descr, Test popcountll results); + atf_tc_set_md_var(tc, descr, Test popcount results); atf_tc_set_md_var(tc, timeout, 0); } @@ -139,7 +142,7 @@ { unsigned int i, r; - popcount_init(); + popcount_init(atf_tc_get_config_var_wd(tc, run_popcount, NO)); for (i = 0; i 0x; ++i) { r = byte_count[i 255] + byte_count[(i 8) 255] @@ -151,12 +154,20 @@ ATF_CHECK_EQ(popcount(0x), 32); } +ATF_TC(t_popcountll); +ATF_TC_HEAD(t_popcountll, tc) +{ + + atf_tc_set_md_var(tc, descr, Test popcountll results); + atf_tc_set_md_var(tc, timeout, 0); +} + ATF_TC_BODY(t_popcountll, tc) { unsigned int i, j, r, r2, p; unsigned long long v; - popcount_init(); + popcount_init(atf_tc_get_config_var_wd(tc, run_popcount, NO)); for (j = 0; j 256; ++j) { p = test_parts[j];
CVS commit: src/tests/lib/libc/string
Module Name:src Committed By: pgoyette Date: Sun Dec 26 13:29:47 UTC 2010 Modified Files: src/tests/lib/libc/string: t_popcount.c Log Message: Make running this test conditional on the setting of atf configuration variable run_popcount. This is a really long-running test (it takes several hours on a qemu-emulation on a 2.8GHz AMD Pheno II) but could still be useful if you want to run it manually, with the command atf-run -v run_popcount=YES To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libc/string/t_popcount.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/tests/lib/libc/string
Module Name:src Committed By: drochner Date: Tue Jul 21 21:45:33 UTC 2009 Modified Files: src/tests/lib/libc/string: t_popcount.c Log Message: flag a 64-bit integer constant as ULL -- this is not clean but the code around it assumes it anyway fixes build on 32-bit To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libc/string/t_popcount.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libc/string/t_popcount.c diff -u src/tests/lib/libc/string/t_popcount.c:1.1 src/tests/lib/libc/string/t_popcount.c:1.2 --- src/tests/lib/libc/string/t_popcount.c:1.1 Tue Jul 21 13:18:44 2009 +++ src/tests/lib/libc/string/t_popcount.c Tue Jul 21 21:45:33 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: t_popcount.c,v 1.1 2009/07/21 13:18:44 joerg Exp $ */ +/* $NetBSD: t_popcount.c,v 1.2 2009/07/21 21:45:33 drochner Exp $ */ /*- * Copyright (c) 2009 The NetBSD Foundation, Inc. * All rights reserved. @@ -32,7 +32,7 @@ */ #include sys/cdefs.h -__RCSID($NetBSD: t_popcount.c,v 1.1 2009/07/21 13:18:44 joerg Exp $); +__RCSID($NetBSD: t_popcount.c,v 1.2 2009/07/21 21:45:33 drochner Exp $); #include atf-c.h #include strings.h @@ -176,7 +176,7 @@ } } - ATF_CHECK_EQ(popcountll(0x), 64); + ATF_CHECK_EQ(popcountll(0xULL), 64); } ATF_TP_ADD_TCS(tp)