Module Name: src
Committed By: pgoyette
Date: Sun Jan 2 22:03:25 UTC 2011
Modified Files:
src/tests/lib/libc: Makefile
src/tests/lib/libc/hash: Makefile
Added Files:
src/tests/lib/libc: h_protoent.c h_servent.c t_protoent.sh t_servent.sh
src/tests/lib/libc/hash: h_hash.c t_hash.sh
src/tests/lib/libc/hash/data: md5test-in md5test-out sha1test-in
sha1test-out sha1test2-out
Log Message:
Atf-ify servent and protoent tests, and the remaining hash test.
To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/tests/lib/libc/Makefile
cvs rdiff -u -r0 -r1.1 src/tests/lib/libc/h_protoent.c \
src/tests/lib/libc/h_servent.c src/tests/lib/libc/t_protoent.sh \
src/tests/lib/libc/t_servent.sh
cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libc/hash/Makefile
cvs rdiff -u -r0 -r1.1 src/tests/lib/libc/hash/h_hash.c \
src/tests/lib/libc/hash/t_hash.sh
cvs rdiff -u -r0 -r1.1 src/tests/lib/libc/hash/data/md5test-in \
src/tests/lib/libc/hash/data/md5test-out \
src/tests/lib/libc/hash/data/sha1test-in \
src/tests/lib/libc/hash/data/sha1test-out \
src/tests/lib/libc/hash/data/sha1test2-out
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/Makefile
diff -u src/tests/lib/libc/Makefile:1.16 src/tests/lib/libc/Makefile:1.17
--- src/tests/lib/libc/Makefile:1.16 Sun Jan 2 03:51:20 2011
+++ src/tests/lib/libc/Makefile Sun Jan 2 22:03:25 2011
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.16 2011/01/02 03:51:20 pgoyette Exp $
+# $NetBSD: Makefile,v 1.17 2011/01/02 22:03:25 pgoyette Exp $
.include <bsd.own.mk>
.include <bsd.sys.mk>
@@ -25,4 +25,13 @@
TESTS_C+= t_randomid
TESTS_C+= t_strptime
+TESTS_SH+= t_protoent
+TESTS_SH+= t_servent
+
+BINDIR= ${TESTSDIR}
+MKMAN= no
+
+PROGS+= h_protoent
+PROGS+= h_servent
+
.include <bsd.test.mk>
Index: src/tests/lib/libc/hash/Makefile
diff -u src/tests/lib/libc/hash/Makefile:1.1 src/tests/lib/libc/hash/Makefile:1.2
--- src/tests/lib/libc/hash/Makefile:1.1 Sun Jan 24 21:12:17 2010
+++ src/tests/lib/libc/hash/Makefile Sun Jan 2 22:03:25 2011
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.1 2010/01/24 21:12:17 joerg Exp $
+# $NetBSD: Makefile,v 1.2 2011/01/02 22:03:25 pgoyette Exp $
.include <bsd.own.mk>
@@ -6,4 +6,19 @@
TESTS_C+= t_sha2
+TESTS_SH+= t_hash
+
+BINDIR= ${TESTSDIR}
+MKMAN= no
+
+PROGS+= h_hash
+
+FILESDIR= ${TESTSDIR}/data
+
+FILES+= data/md5test-in
+FILES+= data/md5test-out
+FILES+= data/sha1test-in
+FILES+= data/sha1test-out
+FILES+= data/sha1test2-out
+
.include <bsd.test.mk>
Added files:
Index: src/tests/lib/libc/h_protoent.c
diff -u /dev/null src/tests/lib/libc/h_protoent.c:1.1
--- /dev/null Sun Jan 2 22:03:25 2011
+++ src/tests/lib/libc/h_protoent.c Sun Jan 2 22:03:25 2011
@@ -0,0 +1,100 @@
+/* $NetBSD: h_protoent.c,v 1.1 2011/01/02 22:03:25 pgoyette Exp $ */
+
+/*-
+ * Copyright (c) 2011 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 <netdb.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <netinet/in.h>
+#include <sys/types.h>
+#include <stdio.h>
+
+static void
+pserv(const struct protoent *prp)
+{
+ char **pp;
+
+ printf("name=%s, proto=%d, aliases=",
+ prp->p_name, prp->p_proto);
+ for (pp = prp->p_aliases; *pp; pp++)
+ printf("%s ", *pp);
+ printf("\n");
+}
+
+static void
+usage(void)
+{
+ (void)fprintf(stderr, "Usage: %s\n"
+ "\t%s -p <proto>\n"
+ "\t%s -n <name>\n", getprogname(), getprogname(),
+ getprogname());
+ exit(1);
+}
+
+int
+main(int argc, char *argv[])
+{
+ struct protoent *prp;
+ const char *proto = NULL, *name = NULL;
+ int c;
+
+ while ((c = getopt(argc, argv, "p:n:")) != -1) {
+ switch (c) {
+ case 'n':
+ name = optarg;
+ break;
+ case 'p':
+ proto = optarg;
+ break;
+ default:
+ usage();
+ }
+ }
+
+ if (proto && name)
+ usage();
+ if (proto) {
+ if ((prp = getprotobynumber(atoi(proto))) != NULL)
+ pserv(prp);
+ return 0;
+ }
+ if (name) {
+ if ((prp = getprotobyname(name)) != NULL)
+ pserv(prp);
+ return 0;
+ }
+
+ setprotoent(0);
+ while ((prp = getprotoent()) != NULL)
+ pserv(prp);
+ endprotoent();
+ return 0;
+}
Index: src/tests/lib/libc/h_servent.c
diff -u /dev/null src/tests/lib/libc/h_servent.c:1.1
--- /dev/null Sun Jan 2 22:03:25 2011
+++ src/tests/lib/libc/h_servent.c Sun Jan 2 22:03:25 2011
@@ -0,0 +1,103 @@
+/* $NetBSD: h_servent.c,v 1.1 2011/01/02 22:03:25 pgoyette Exp $ */
+
+/*-
+ * Copyright (c) 2011 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 <netdb.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <netinet/in.h>
+#include <sys/types.h>
+#include <stdio.h>
+
+static void
+pserv(const struct servent *svp)
+{
+ char **pp;
+
+ printf("name=%s, port=%d, proto=%s, aliases=",
+ svp->s_name, ntohs((uint16_t)svp->s_port), svp->s_proto);
+ for (pp = svp->s_aliases; *pp; pp++)
+ printf("%s ", *pp);
+ printf("\n");
+}
+
+static void
+usage(void)
+{
+ (void)fprintf(stderr, "Usage: %s\n"
+ "\t%s -p <port> [-P <proto>]\n"
+ "\t%s -n <name> [-P <proto>]\n", getprogname(), getprogname(),
+ getprogname());
+ exit(1);
+}
+
+int
+main(int argc, char *argv[])
+{
+ struct servent *svp;
+ const char *port = NULL, *proto = NULL, *name = NULL;
+ int c;
+
+ while ((c = getopt(argc, argv, "p:n:P:")) != -1) {
+ switch (c) {
+ case 'n':
+ name = optarg;
+ break;
+ case 'p':
+ port = optarg;
+ break;
+ case 'P':
+ proto = optarg;
+ break;
+ default:
+ usage();
+ }
+ }
+
+ if (port && name)
+ usage();
+ if (port) {
+ if ((svp = getservbyport(htons(atoi(port)), proto)) != NULL)
+ pserv(svp);
+ return 0;
+ }
+ if (name) {
+ if ((svp = getservbyname(name, proto)) != NULL)
+ pserv(svp);
+ return 0;
+ }
+
+ setservent(0);
+ while ((svp = getservent()) != NULL)
+ pserv(svp);
+ endservent();
+ return 0;
+}
Index: src/tests/lib/libc/t_protoent.sh
diff -u /dev/null src/tests/lib/libc/t_protoent.sh:1.1
--- /dev/null Sun Jan 2 22:03:25 2011
+++ src/tests/lib/libc/t_protoent.sh Sun Jan 2 22:03:25 2011
@@ -0,0 +1,93 @@
+# $NetBSD: t_protoent.sh,v 1.1 2011/01/02 22:03:25 pgoyette Exp $
+#
+# Copyright (c) 2008 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.
+#
+
+atf_test_case protoent
+protoent_head()
+{
+ atf_set "descr" "Checks {get,set,end}protoent(3)"
+}
+protoent_body()
+{
+ #
+ # Munge original to:
+ # (1) match output format of the test program
+ # (2) fold all names for the same port/proto together
+ # (3) prune duplicates
+ #
+ tr '\t' ' ' </etc/protocols | awk '
+ function add(key, name, i, n, ar) {
+ n = split(names[key], ar);
+ for (i=1; i<=n; i++) {
+ if (name == ar[i]) {
+ return;
+ }
+ }
+ delete ar;
+ names[key] = names[key] " " name;
+ }
+
+ {
+ sub("#.*", "", $0);
+ gsub(" *", " ", $0);
+ if (NF==0) {
+ next;
+ }
+ add($2, $1, 0);
+ for (i=3; i<=NF; i++) {
+ add($2, $i, 1);
+ }
+ }
+ END {
+ for (key in names) {
+ proto = key;
+
+ n = split(names[key], ar);
+ printf "name=%s, proto=%s, aliases=", ar[1], proto;
+ for (i=2; i<=n; i++) {
+ if (i>2) {
+ printf " ";
+ }
+ printf "%s", ar[i];
+ }
+ printf "\n";
+ delete ar;
+ }
+ }
+ ' | sort >exp
+
+ # run test program
+ "$(atf_get_srcdir)/h_protoent" | sed 's/ *$//' | sort >out
+
+ atf_expect_fail "PR misc/44311: protocol entry for manet is wrong"
+ diff -u exp out || \
+ atf_fail "Observed output does not match reference output"
+}
+
+atf_init_test_cases()
+{
+ atf_add_test_case protoent
+}
Index: src/tests/lib/libc/t_servent.sh
diff -u /dev/null src/tests/lib/libc/t_servent.sh:1.1
--- /dev/null Sun Jan 2 22:03:25 2011
+++ src/tests/lib/libc/t_servent.sh Sun Jan 2 22:03:25 2011
@@ -0,0 +1,93 @@
+# $NetBSD: t_servent.sh,v 1.1 2011/01/02 22:03:25 pgoyette Exp $
+#
+# Copyright (c) 2008 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.
+#
+
+atf_test_case servent
+servent_head()
+{
+ atf_set "descr" "Checks {get,set,end}servent(3)"
+}
+servent_body()
+{
+ #
+ # Munge original to:
+ # (1) match output format of the test program
+ # (2) fold all names for the same port/proto together
+ # (3) prune duplicates
+ #
+ tr '\t' ' ' </etc/services | awk '
+ function add(key, name, i, n, ar) {
+ n = split(names[key], ar);
+ for (i=1; i<=n; i++) {
+ if (name == ar[i]) {
+ return;
+ }
+ }
+ delete ar;
+ names[key] = names[key] " " name;
+ }
+
+ {
+ sub("#.*", "", $0);
+ gsub(" *", " ", $0);
+ if (NF==0) {
+ next;
+ }
+ add($2, $1, 0);
+ for (i=3; i<=NF; i++) {
+ add($2, $i, 1);
+ }
+ }
+ END {
+ for (key in names) {
+ portproto = key;
+ sub("/", ", proto=", portproto);
+ portproto = "port=" portproto;
+
+ n = split(names[key], ar);
+ printf "name=%s, %s, aliases=", ar[1], portproto;
+ for (i=2; i<=n; i++) {
+ if (i>2) {
+ printf " ";
+ }
+ printf "%s", ar[i];
+ }
+ printf "\n";
+ delete ar;
+ }
+ }
+ ' | sort >exp
+
+ # run test program
+ "$(atf_get_srcdir)/h_servent" | sed 's/ *$//' | sort >out
+
+ diff -u exp out || atf_fail "Observed output does not match reference output"
+}
+
+atf_init_test_cases()
+{
+ atf_add_test_case servent
+}
Index: src/tests/lib/libc/hash/h_hash.c
diff -u /dev/null src/tests/lib/libc/hash/h_hash.c:1.1
--- /dev/null Sun Jan 2 22:03:25 2011
+++ src/tests/lib/libc/hash/h_hash.c Sun Jan 2 22:03:25 2011
@@ -0,0 +1,167 @@
+/* $NetBSD: h_hash.c,v 1.1 2011/01/02 22:03:25 pgoyette Exp $ */
+
+/*-
+ * Copyright (c) 2000 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.
+ */
+
+/*
+ * Combined MD5/SHA1 time and regression test.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <md5.h>
+#include <sha1.h>
+
+
+int mflag, rflag, sflag, tflag;
+
+static void
+usage(void)
+{
+ (void)fprintf(stderr,
+ "Usage:\t%s -r[ms] < test-file\n"
+ "\t%s -t[ms]\n",
+ getprogname(), getprogname());
+ exit(1);
+ /* NOTREACHED */
+}
+
+static void
+hexdump (unsigned char *buf, int len)
+{
+ int i;
+ for (i=0; i<len; i++) {
+ printf("%02x", buf[i]);
+ }
+ printf("\n");
+}
+
+
+static void
+timetest(void)
+{
+ printf("sorry, not yet\n");
+}
+
+#define CHOMP(buf, len, last) \
+ if ((len > 0) && \
+ (buf[len-1] == '\n')) { \
+ buf[len-1] = '\0'; \
+ len--; \
+ last = 1; \
+ }
+
+static void
+regress(void)
+{
+ unsigned char buf[1024];
+ unsigned char out[20];
+ int len, outlen, last;
+
+ while (fgets((char *)buf, sizeof(buf), stdin) != NULL) {
+ last = 0;
+
+ len = strlen((char *)buf);
+ CHOMP(buf, len, last);
+ if (mflag) {
+ MD5_CTX ctx;
+
+ MD5Init(&ctx);
+ MD5Update(&ctx, buf, len);
+ while (!last &&
+ fgets((char *)buf, sizeof(buf), stdin) != NULL) {
+ len = strlen((char *)buf);
+ CHOMP(buf, len, last);
+ MD5Update(&ctx, buf, len);
+ }
+ MD5Final(out, &ctx);
+ outlen = 16;
+ } else {
+ SHA1_CTX ctx;
+
+ SHA1Init(&ctx);
+ SHA1Update(&ctx, buf, len);
+ while (!last &&
+ fgets((char *)buf, sizeof(buf), stdin) != NULL) {
+ len = strlen((char *)buf);
+ CHOMP(buf, len, last);
+ SHA1Update(&ctx, buf, len);
+ }
+ SHA1Final(out, &ctx);
+ outlen = 20;
+ }
+ hexdump(out, outlen);
+ }
+}
+
+int
+main(int argc, char **argv)
+{
+ int ch;
+
+ while ((ch = getopt(argc, argv, "mrst")) != -1)
+ switch (ch) {
+ case 'm':
+ mflag = 1;
+ break;
+ case 'r':
+ rflag = 1;
+ break;
+ case 's':
+ sflag = 1;
+ break;
+ case 't':
+ tflag = 1;
+ break;
+ case '?':
+ default:
+ usage();
+ }
+ argc -= optind;
+ argv += optind;
+ if (argc > 0)
+ usage();
+
+ if (!(mflag || sflag))
+ mflag = 1;
+
+ if ((mflag ^ sflag) != 1)
+ usage();
+
+ if ((tflag ^ rflag) != 1)
+ usage();
+
+ if (tflag)
+ timetest();
+
+ if (rflag)
+ regress();
+
+ exit(0);
+
+}
Index: src/tests/lib/libc/hash/t_hash.sh
diff -u /dev/null src/tests/lib/libc/hash/t_hash.sh:1.1
--- /dev/null Sun Jan 2 22:03:25 2011
+++ src/tests/lib/libc/hash/t_hash.sh Sun Jan 2 22:03:25 2011
@@ -0,0 +1,67 @@
+# $NetBSD: t_hash.sh,v 1.1 2011/01/02 22:03:25 pgoyette Exp $
+#
+# Copyright (c) 2008 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.
+#
+
+prog()
+{
+ echo "$(atf_get_srcdir)/h_hash"
+}
+
+datadir()
+{
+ echo "$(atf_get_srcdir)/data"
+}
+
+atf_test_case md5
+md5_head()
+{
+ atf_set "descr" "Checks MD5 functions"
+}
+md5_body()
+{
+ atf_check -o file:"$(datadir)/md5test-out" -x \
+ "$(prog) -r < $(datadir)/md5test-in"
+}
+
+atf_test_case sha1
+sha1_head()
+{
+ atf_set "descr" "Checks SHA1 functions"
+}
+sha1_body()
+{
+ atf_check -o file:"$(datadir)/sha1test-out" -x \
+ "$(prog) -rs < $(datadir)/sha1test-in"
+
+ atf_check -o file:"$(datadir)/sha1test2-out" -x \
+ "jot -s '' -b 'a' -n 1000000 | $(prog) -rs"
+}
+
+atf_init_test_cases()
+{
+ atf_add_test_case md5
+ atf_add_test_case sha1
+}
Index: src/tests/lib/libc/hash/data/md5test-in
diff -u /dev/null src/tests/lib/libc/hash/data/md5test-in:1.1
--- /dev/null Sun Jan 2 22:03:25 2011
+++ src/tests/lib/libc/hash/data/md5test-in Sun Jan 2 22:03:25 2011
@@ -0,0 +1,7 @@
+
+a
+abc
+message digest
+abcdefghijklmnopqrstuvwxyz
+ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
+12345678901234567890123456789012345678901234567890123456789012345678901234567890
Index: src/tests/lib/libc/hash/data/md5test-out
diff -u /dev/null src/tests/lib/libc/hash/data/md5test-out:1.1
--- /dev/null Sun Jan 2 22:03:25 2011
+++ src/tests/lib/libc/hash/data/md5test-out Sun Jan 2 22:03:25 2011
@@ -0,0 +1,7 @@
+d41d8cd98f00b204e9800998ecf8427e
+0cc175b9c0f1b6a831c399e269772661
+900150983cd24fb0d6963f7d28e17f72
+f96b697d7cb7938d525a2f31aaf161d0
+c3fcd3d76192e4007dfb496cca67e13b
+d174ab98d277d9f5a5611c2c9f419d9f
+57edf4a22be3c955ac49da2e2107b67a
Index: src/tests/lib/libc/hash/data/sha1test-in
diff -u /dev/null src/tests/lib/libc/hash/data/sha1test-in:1.1
--- /dev/null Sun Jan 2 22:03:25 2011
+++ src/tests/lib/libc/hash/data/sha1test-in Sun Jan 2 22:03:25 2011
@@ -0,0 +1,2 @@
+abc
+abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq
Index: src/tests/lib/libc/hash/data/sha1test-out
diff -u /dev/null src/tests/lib/libc/hash/data/sha1test-out:1.1
--- /dev/null Sun Jan 2 22:03:25 2011
+++ src/tests/lib/libc/hash/data/sha1test-out Sun Jan 2 22:03:25 2011
@@ -0,0 +1,2 @@
+a9993e364706816aba3e25717850c26c9cd0d89d
+84983e441c3bd26ebaae4aa1f95129e5e54670f1
Index: src/tests/lib/libc/hash/data/sha1test2-out
diff -u /dev/null src/tests/lib/libc/hash/data/sha1test2-out:1.1
--- /dev/null Sun Jan 2 22:03:25 2011
+++ src/tests/lib/libc/hash/data/sha1test2-out Sun Jan 2 22:03:25 2011
@@ -0,0 +1 @@
+34aa973cd4c4daa4f61eeb2bdbad27316534016f