Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src Add basic regression test for nbperf(1)
details: https://anonhg.NetBSD.org/src/rev/d0923212607d
branches: trunk
changeset: 780411:d0923212607d
user: joerg <joerg%NetBSD.org@localhost>
date: Sun Jul 22 20:38:20 2012 +0000
description:
Add basic regression test for nbperf(1)
diffstat:
distrib/sets/lists/tests/mi | 7 +++-
tests/usr.bin/Makefile | 5 +-
tests/usr.bin/nbperf/Makefile | 17 ++++++++
tests/usr.bin/nbperf/h_nbperf.sh | 32 ++++++++++++++++
tests/usr.bin/nbperf/hash_driver.c | 53 ++++++++++++++++++++++++++
tests/usr.bin/nbperf/t_nbperf.sh | 75 ++++++++++++++++++++++++++++++++++++++
6 files changed, 186 insertions(+), 3 deletions(-)
diffs (232 lines):
diff -r 3fa7f0e94a3b -r d0923212607d distrib/sets/lists/tests/mi
--- a/distrib/sets/lists/tests/mi Sun Jul 22 20:32:31 2012 +0000
+++ b/distrib/sets/lists/tests/mi Sun Jul 22 20:38:20 2012 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.477 2012/07/14 14:13:03 christos Exp $
+# $NetBSD: mi,v 1.478 2012/07/22 20:38:20 joerg Exp $
#
# Note: don't delete entries from here - mark them as "obsolete" instead.
#
@@ -3142,6 +3142,11 @@
./usr/tests/usr.bin/mkdep tests-usr.bin-tests
./usr/tests/usr.bin/mkdep/Atffile tests-usr.bin-tests atf
./usr/tests/usr.bin/mkdep/t_mkdep tests-usr.bin-tests atf
+./usr/tests/usr.bin/nbperf tests-usr.bin-tests
+./usr/tests/usr.bin/nbperf/Atffile tests-usr.bin-tests atf
+./usr/tests/usr.bin/nbperf/h_nbperf tests-usr.bin-tests atf
+./usr/tests/usr.bin/nbperf/hash_driver.c tests-usr.bin-tests atf
+./usr/tests/usr.bin/nbperf/t_nbperf tests-usr.bin-tests atf
./usr/tests/usr.bin/pr tests-usr.bin-tests
./usr/tests/usr.bin/pr/Atffile tests-usr.bin-tests atf
./usr/tests/usr.bin/pr/d_basic.in tests-usr.bin-tests atf
diff -r 3fa7f0e94a3b -r d0923212607d tests/usr.bin/Makefile
--- a/tests/usr.bin/Makefile Sun Jul 22 20:32:31 2012 +0000
+++ b/tests/usr.bin/Makefile Sun Jul 22 20:38:20 2012 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.15 2012/06/06 21:23:10 martin Exp $
+# $NetBSD: Makefile,v 1.16 2012/07/22 20:38:20 joerg Exp $
#
.include <bsd.own.mk>
@@ -7,6 +7,7 @@
TESTS_SUBDIRS= awk basename bzip2 cc cmp config cut \
diff dirname find grep gzip id infocmp jot m4 make mkdep \
- pr rump_server shmif_dumpbus sdiff sed sort tmux unifdef xlint
+ nbperf pr rump_server shmif_dumpbus sdiff sed sort tmux \
+ unifdef xlint
.include <bsd.test.mk>
diff -r 3fa7f0e94a3b -r d0923212607d tests/usr.bin/nbperf/Makefile
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/nbperf/Makefile Sun Jul 22 20:38:20 2012 +0000
@@ -0,0 +1,17 @@
+# $NetBSD: Makefile,v 1.1 2012/07/22 20:38:20 joerg Exp $
+
+NOMAN= # defined
+
+.include <bsd.own.mk>
+
+TESTSDIR= ${TESTSBASE}/usr.bin/nbperf
+
+TESTS_SH= t_nbperf
+
+SCRIPTSDIR= ${TESTSDIR}
+SCRIPTS+= h_nbperf
+
+FILESDIR= ${TESTSDIR}
+FILES= hash_driver.c
+
+.include <bsd.test.mk>
diff -r 3fa7f0e94a3b -r d0923212607d tests/usr.bin/nbperf/h_nbperf.sh
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/nbperf/h_nbperf.sh Sun Jul 22 20:38:20 2012 +0000
@@ -0,0 +1,32 @@
+#!/bin/sh
+# $NetBSD: h_nbperf.sh,v 1.1 2012/07/22 20:38:20 joerg Exp $
+#
+# Copyright (c) 2012 The NetBSD Foundation, Inc.
+# All rights reserved.
+#
+# 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.
+#
+
+set -e
+head -n $4 $1 | nbperf -a $2 > hash.c 2> /dev/null
+cc -o testprog -I. $5
+head -n $4 $1 | ./testprog | $3
diff -r 3fa7f0e94a3b -r d0923212607d tests/usr.bin/nbperf/hash_driver.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/nbperf/hash_driver.c Sun Jul 22 20:38:20 2012 +0000
@@ -0,0 +1,53 @@
+/* $NetBSD: hash_driver.c,v 1.1 2012/07/22 20:38:20 joerg Exp $ */
+/*-
+ * Copyright (c) 2012 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Joerg Sonnenberger.
+ *
+ * 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 COPYRIGHT HOLDERS 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
+ * COPYRIGHT HOLDERS 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 <stdio.h>
+#include <inttypes.h>
+
+#include "hash.c"
+
+int
+main(void)
+{
+ char *line = NULL;
+ size_t buflen;
+ ssize_t len;
+
+ while ((len = getline(&line, &len, stdin)) > 0) {
+ if (len && line[len - 1] == '\n')
+ --len;
+ printf("%" PRId32 "\n", 1 + hash(line, len));
+ }
+ free(line);
+ return 0;
+}
diff -r 3fa7f0e94a3b -r d0923212607d tests/usr.bin/nbperf/t_nbperf.sh
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/nbperf/t_nbperf.sh Sun Jul 22 20:38:20 2012 +0000
@@ -0,0 +1,75 @@
+# $NetBSD: t_nbperf.sh,v 1.1 2012/07/22 20:38:20 joerg Exp $
+#
+# Copyright (c) 2012 The NetBSD Foundation, Inc.
+# All rights reserved.
+#
+# 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.
+#
+
+cleanup()
+{
+ rm -f reference.txt hash.c testprog
+}
+
+atf_test_case chm
+chm_head()
+{
+ atf_set "descr" "Checks chm algorithm"
+}
+chm_body()
+{
+ for n in 4 32 128 1024 65536; do
+ seq $n > reference.txt
+ atf_check -o file:reference.txt \
+ $(atf_get_srcdir)/h_nbperf /usr/share/dict/web2 chm cat \
+ $n $(atf_get_srcdir)/hash_driver.c
+ done
+}
+chm_clean()
+{
+ cleanup
+}
+
+atf_test_case chm3
+chm3_head()
+{
+ atf_set "descr" "Checks chm3 algorithm"
+}
+chm3_body()
+{
+ for n in 4 32 128 1024 65536; do
+ seq $n > reference.txt
+ atf_check -o file:reference.txt \
+ $(atf_get_srcdir)/h_nbperf /usr/share/dict/web2 chm3 cat \
+ $n $(atf_get_srcdir)/hash_driver.c
+ done
+}
+chm3_clean()
+{
+ cleanup
+}
+
+atf_init_test_cases()
+{
+ atf_add_test_case chm
+ atf_add_test_case chm3
+}
Home |
Main Index |
Thread Index |
Old Index