Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src Migrate the last of the libc/string/ tests from regress to a...
details: https://anonhg.NetBSD.org/src/rev/be4e5be1fdf3
branches: trunk
changeset: 760094:be4e5be1fdf3
user: pgoyette <pgoyette%NetBSD.org@localhost>
date: Sun Dec 26 13:35:54 2010 +0000
description:
Migrate the last of the libc/string/ tests from regress to atf, and
re-enable building of t_popcount
diffstat:
distrib/sets/lists/tests/mi | 14 +++-
tests/lib/libc/string/Makefile | 10 ++-
tests/lib/libc/string/t_memcpy.c | 113 ++++++++++++++++++++++++++++++++++++++
tests/lib/libc/string/t_memmem.c | 101 +++++++++++++++++++++++++++++++++
tests/lib/libc/string/t_stresep.c | 73 ++++++++++++++++++++++++
tests/lib/libc/string/t_swab.c | 96 ++++++++++++++++++++++++++++++++
6 files changed, 400 insertions(+), 7 deletions(-)
diffs (truncated from 458 to 300 lines):
diff -r ebe845846505 -r be4e5be1fdf3 distrib/sets/lists/tests/mi
--- a/distrib/sets/lists/tests/mi Sun Dec 26 13:29:47 2010 +0000
+++ b/distrib/sets/lists/tests/mi Sun Dec 26 13:35:54 2010 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.190 2010/12/25 21:10:24 pgoyette Exp $
+# $NetBSD: mi,v 1.191 2010/12/26 13:35:54 pgoyette Exp $
#
# Note: don't delete entries from here - mark them as "obsolete" instead.
#
@@ -335,8 +335,12 @@
./usr/libdata/debug/usr/tests/lib/libc/stdlib/t_mi_vector_hash.debug tests-lib-debug debug,atf
./usr/libdata/debug/usr/tests/lib/libc/stdlib/t_strtox.debug tests-lib-debug debug,atf
./usr/libdata/debug/usr/tests/lib/libc/string tests-lib-debug
-#./usr/libdata/debug/usr/tests/lib/libc/string/t_popcount.debug tests-lib-debug debug,atf
+./usr/libdata/debug/usr/tests/lib/libc/string/t_memcpy.debug tests-lib-debug debug,atf
+./usr/libdata/debug/usr/tests/lib/libc/string/t_memmem.debug tests-lib-debug debug,atf
+./usr/libdata/debug/usr/tests/lib/libc/string/t_popcount.debug tests-lib-debug debug,atf
./usr/libdata/debug/usr/tests/lib/libc/string/t_string.debug tests-lib-debug debug,atf
+./usr/libdata/debug/usr/tests/lib/libc/string/t_stresep.debug tests-lib-debug debug,atf
+./usr/libdata/debug/usr/tests/lib/libc/string/t_swab.debug tests-lib-debug debug,atf
./usr/libdata/debug/usr/tests/lib/libdes tests-lib-debug
./usr/libdata/debug/usr/tests/lib/libdes/t_des.debug tests-lib-debug debug,atf,crypto
./usr/libdata/debug/usr/tests/lib/semaphore tests-lib-debug
@@ -1561,8 +1565,12 @@
./usr/tests/lib/libc/stdio/t_popen tests-lib-tests atf
./usr/tests/lib/libc/string tests-lib-tests
./usr/tests/lib/libc/string/Atffile tests-lib-tests atf
-#./usr/tests/lib/libc/string/t_popcount tests-lib-tests atf
+./usr/tests/lib/libc/string/t_memcpy tests-lib-tests atf
+./usr/tests/lib/libc/string/t_memmem tests-lib-tests atf
+./usr/tests/lib/libc/string/t_popcount tests-lib-tests atf
./usr/tests/lib/libc/string/t_string tests-lib-tests atf
+./usr/tests/lib/libc/string/t_stresep tests-lib-tests atf
+./usr/tests/lib/libc/string/t_swab tests-lib-tests atf
./usr/tests/lib/libdes tests-lib-tests
./usr/tests/lib/libdes/Atffile tests-lib-tests atf,crypto
./usr/tests/lib/libdes/t_des tests-lib-tests atf,crypto
diff -r ebe845846505 -r be4e5be1fdf3 tests/lib/libc/string/Makefile
--- a/tests/lib/libc/string/Makefile Sun Dec 26 13:29:47 2010 +0000
+++ b/tests/lib/libc/string/Makefile Sun Dec 26 13:35:54 2010 +0000
@@ -1,12 +1,14 @@
-# $NetBSD: Makefile,v 1.3 2010/12/25 21:10:24 pgoyette Exp $
+# $NetBSD: Makefile,v 1.4 2010/12/26 13:35:54 pgoyette Exp $
.include <bsd.own.mk>
TESTSDIR= ${TESTSBASE}/lib/libc/string
+TESTS_C+= t_memcpy
+TESTS_C+= t_memmem
+TESTS_C+= t_popcount
+TESTS_C+= t_stresep
TESTS_C+= t_string
-
-# EXPENSIVE, REALY, REALY EXPENSIVE test! Disable for now.
-#TESTS_C+= t_popcount
+TESTS_C+= t_swab
.include <bsd.test.mk>
diff -r ebe845846505 -r be4e5be1fdf3 tests/lib/libc/string/t_memcpy.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/lib/libc/string/t_memcpy.c Sun Dec 26 13:35:54 2010 +0000
@@ -0,0 +1,113 @@
+/* $NetBSD: t_memcpy.c,v 1.1 2010/12/26 13:35:54 pgoyette Exp $ */
+
+/*-
+ * Copyright (c) 2010 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by
+ *
+ * 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 <atf-c.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <assert.h>
+#include <md5.h>
+
+#include <sys/types.h>
+
+#define ALIGNMENTS 16
+#define LENGTHS 4
+#define BLOCKTYPES 4
+
+MD5_CTX mc[1];
+
+typedef unsigned char testBlock_t[ALIGNMENTS * LENGTHS];
+
+testBlock_t bss1, bss2;
+
+unsigned char *start[BLOCKTYPES] = {
+ bss1, bss2
+};
+
+char result[100];
+const char goodResult[] = "7b405d24bc03195474c70ddae9e1f8fb";
+
+static void
+runTest(unsigned char *b1, unsigned char *b2)
+{
+ int i, j, k, m;
+ size_t n;
+
+ for (i = 0; i < ALIGNMENTS; ++i) {
+ for (j = 0; j < ALIGNMENTS; ++j) {
+ k = sizeof(testBlock_t) - (i > j ? i : j);
+ for (m = 0; m < k; ++m) {
+ for (n = 0; n < sizeof(testBlock_t); ++n) {
+ b1[n] = (unsigned char)random();
+ b2[n] = (unsigned char)random();
+ }
+ memcpy(b1 + i, b2 + j, m);
+ MD5Update(mc, b1, sizeof(testBlock_t));
+ MD5Update(mc, b2, sizeof(testBlock_t));
+ }
+ }
+ }
+}
+
+ATF_TC(check_memcpy);
+
+ATF_TC_HEAD(check_memcpy, tc)
+{
+
+ atf_tc_set_md_var(tc, "descr", "Test memcpy results");
+}
+
+ATF_TC_BODY(check_memcpy, tc)
+{
+ int i, j;
+ testBlock_t auto1, auto2;
+
+ start[2] = auto1;
+ start[3] = auto2;
+
+ srandom(0L);
+ MD5Init(mc);
+ for (i = 0; i < BLOCKTYPES; ++i)
+ for (j = 0; j < BLOCKTYPES; ++j)
+ if (i != j)
+ runTest(start[i], start[j]);
+ MD5End(mc, result);
+ ATF_REQUIRE_EQ(strcmp(result, goodResult), 0);
+}
+
+ATF_TP_ADD_TCS(tp)
+{
+
+ ATF_TP_ADD_TC(tp, check_memcpy);
+
+ return atf_no_error();
+}
diff -r ebe845846505 -r be4e5be1fdf3 tests/lib/libc/string/t_memmem.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/lib/libc/string/t_memmem.c Sun Dec 26 13:35:54 2010 +0000
@@ -0,0 +1,101 @@
+/* $NetBSD: t_memmem.c,v 1.1 2010/12/26 13:35:54 pgoyette Exp $ */
+
+/*-
+ * Copyright (c) 2005 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Perry E. Metzger of Metzger, Dowdeswell & Co. LLC.
+ *
+ * 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 <atf-c.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+char p0[] = "";
+int lp0 = 0;
+char p1[] = "0123";
+int lp1 = 4;
+char p2[] = "456";
+int lp2 = 3;
+char p3[] = "789";
+int lp3 = 3;
+char p4[] = "abc";
+int lp4 = 3;
+char p5[] = "0";
+int lp5 = 1;
+char p6[] = "9";
+int lp6 = 1;
+char p7[] = "654";
+int lp7 = 3;
+
+char b0[] = "";
+int lb0 = 0;
+char b1[] = "0";
+int lb1 = 1;
+char b2[] = "0123456789";
+int lb2 = 10;
+
+#define expect(b) \
+ if (!(b)) { \
+ fprintf(stderr, "failed on line %d\n", __LINE__); \
+ atf_tc_fail("Check stderr for test id/line"); \
+ }
+
+ATF_TC(check_memmem);
+
+ATF_TC_HEAD(check_memmem, tc)
+{
+
+ atf_tc_set_md_var(tc, "descr", "Test memmem results");
+}
+
+ATF_TC_BODY(check_memmem, tc)
+{
+
+ expect(memmem(b2, lb2, p0, lp0) == b2);
+ expect(memmem(b0, lb0, p0, lp0) == b0);
+ expect(memmem(b0, lb0, p1, lp1) == NULL);
+ expect(memmem(b1, lb1, p1, lp1) == NULL);
+
+ expect(memmem(b2, lb2, p1, lp1) == b2);
+ expect(memmem(b2, lb2, p2, lp2) == (b2 + 4));
+ expect(memmem(b2, lb2, p3, lp3) == (b2 + 7));
+
+ expect(memmem(b2, lb2, p5, lp5) == b2);
+ expect(memmem(b2, lb2, p6, lp6) == (b2 + 9));
+
+ expect(memmem(b2, lb2, p4, lp4) == NULL);
+ expect(memmem(b2, lb2, p7, lp7) == NULL);
+}
+
+ATF_TP_ADD_TCS(tp)
+{
+
+ ATF_TP_ADD_TC(tp, check_memmem);
+
+ return atf_no_error();
+}
diff -r ebe845846505 -r be4e5be1fdf3 tests/lib/libc/string/t_stresep.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/lib/libc/string/t_stresep.c Sun Dec 26 13:35:54 2010 +0000
@@ -0,0 +1,73 @@
+/* $NetBSD: t_stresep.c,v 1.1 2010/12/26 13:35:54 pgoyette Exp $ */
+
+/*-
+ * Copyright (c) 2005 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Christos Zoulas.
+ *
+ * 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
Home |
Main Index |
Thread Index |
Old Index