Module Name: src Committed By: joerg Date: Sun Jul 22 20:38:20 UTC 2012
Modified Files: src/distrib/sets/lists/tests: mi src/tests/usr.bin: Makefile Added Files: src/tests/usr.bin/nbperf: Makefile h_nbperf.sh hash_driver.c t_nbperf.sh Log Message: Add basic regression test for nbperf(1) To generate a diff of this commit: cvs rdiff -u -r1.477 -r1.478 src/distrib/sets/lists/tests/mi cvs rdiff -u -r1.15 -r1.16 src/tests/usr.bin/Makefile cvs rdiff -u -r0 -r1.1 src/tests/usr.bin/nbperf/Makefile \ src/tests/usr.bin/nbperf/h_nbperf.sh \ src/tests/usr.bin/nbperf/hash_driver.c \ src/tests/usr.bin/nbperf/t_nbperf.sh Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/distrib/sets/lists/tests/mi diff -u src/distrib/sets/lists/tests/mi:1.477 src/distrib/sets/lists/tests/mi:1.478 --- src/distrib/sets/lists/tests/mi:1.477 Sat Jul 14 14:13:03 2012 +++ src/distrib/sets/lists/tests/mi Sun Jul 22 20:38:20 2012 @@ -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 Index: src/tests/usr.bin/Makefile diff -u src/tests/usr.bin/Makefile:1.15 src/tests/usr.bin/Makefile:1.16 --- src/tests/usr.bin/Makefile:1.15 Wed Jun 6 21:23:10 2012 +++ src/tests/usr.bin/Makefile Sun Jul 22 20:38:20 2012 @@ -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 @@ TESTSDIR= ${TESTSBASE}/usr.bin 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> Added files: Index: src/tests/usr.bin/nbperf/Makefile diff -u /dev/null src/tests/usr.bin/nbperf/Makefile:1.1 --- /dev/null Sun Jul 22 20:38:20 2012 +++ src/tests/usr.bin/nbperf/Makefile Sun Jul 22 20:38:20 2012 @@ -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> Index: src/tests/usr.bin/nbperf/h_nbperf.sh diff -u /dev/null src/tests/usr.bin/nbperf/h_nbperf.sh:1.1 --- /dev/null Sun Jul 22 20:38:20 2012 +++ src/tests/usr.bin/nbperf/h_nbperf.sh Sun Jul 22 20:38:20 2012 @@ -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 Index: src/tests/usr.bin/nbperf/hash_driver.c diff -u /dev/null src/tests/usr.bin/nbperf/hash_driver.c:1.1 --- /dev/null Sun Jul 22 20:38:20 2012 +++ src/tests/usr.bin/nbperf/hash_driver.c Sun Jul 22 20:38:20 2012 @@ -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; +} Index: src/tests/usr.bin/nbperf/t_nbperf.sh diff -u /dev/null src/tests/usr.bin/nbperf/t_nbperf.sh:1.1 --- /dev/null Sun Jul 22 20:38:20 2012 +++ src/tests/usr.bin/nbperf/t_nbperf.sh Sun Jul 22 20:38:20 2012 @@ -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 +}