Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src Migrate the remaining libc/gen tests to atf
details: https://anonhg.NetBSD.org/src/rev/8deb952c661a
branches: trunk
changeset: 760140:8deb952c661a
user: pgoyette <pgoyette%NetBSD.org@localhost>
date: Tue Dec 28 12:46:15 2010 +0000
description:
Migrate the remaining libc/gen tests to atf
diffstat:
distrib/sets/lists/tests/mi | 14 +-
tests/lib/libc/gen/Makefile | 9 +-
tests/lib/libc/gen/t_dir.c | 163 ++++++++++++++++++++
tests/lib/libc/gen/t_fmtcheck.c | 116 ++++++++++++++
tests/lib/libc/gen/t_humanize_number.c | 257 +++++++++++++++++++++++++++++++++
tests/lib/libc/gen/t_rbstress.c | 127 ++++++++++++++++
tests/lib/libc/gen/t_vis.c | 98 ++++++++++++
7 files changed, 780 insertions(+), 4 deletions(-)
diffs (truncated from 844 to 300 lines):
diff -r bc826e53301d -r 8deb952c661a distrib/sets/lists/tests/mi
--- a/distrib/sets/lists/tests/mi Tue Dec 28 10:20:27 2010 +0000
+++ b/distrib/sets/lists/tests/mi Tue Dec 28 12:46:15 2010 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.195 2010/12/28 09:15:24 he Exp $
+# $NetBSD: mi,v 1.196 2010/12/28 12:46:15 pgoyette Exp $
#
# Note: don't delete entries from here - mark them as "obsolete" instead.
#
@@ -319,9 +319,14 @@
./usr/libdata/debug/usr/tests/lib/libc tests-lib-debug
./usr/libdata/debug/usr/tests/lib/libc/gen tests-lib-debug
./usr/libdata/debug/usr/tests/lib/libc/gen/t_basedirname.debug tests-lib-debug debug,atf
+./usr/libdata/debug/usr/tests/lib/libc/gen/t_dir.debug tests-lib-debug debug,atf
+./usr/libdata/debug/usr/tests/lib/libc/gen/t_fmtcheck.debug tests-lib-debug debug,atf
./usr/libdata/debug/usr/tests/lib/libc/gen/t_glob_star.debug tests-lib-debug debug,atf
-./usr/libdata/debug/usr/tests/lib/libc/gen/t_syslog_pthread.debug tests-lib-debug debug,atf
+./usr/libdata/debug/usr/tests/lib/libc/gen/t_humanize_number.debug tests-lib-debug debug,atf
+./usr/libdata/debug/usr/tests/lib/libc/gen/t_rbstress.debug tests-lib-debug debug,atf
+./usr/libdata/debug/usr/tests/lib/libc/gen/t_syslog_pthread.debug tests-lib-debug debug,atf
./usr/libdata/debug/usr/tests/lib/libc/gen/t_siginfo.debug tests-lib-debug debug,atf
+./usr/libdata/debug/usr/tests/lib/libc/gen/t_vis.debug tests-lib-debug debug,atf
./usr/libdata/debug/usr/tests/lib/libc/hash tests-lib-debug
./usr/libdata/debug/usr/tests/lib/libc/hash/t_sha2.debug tests-lib-debug debug,atf
./usr/libdata/debug/usr/tests/lib/libc/setjmp tests-lib-debug
@@ -1565,9 +1570,14 @@
./usr/tests/lib/libc/gen tests-lib-tests
./usr/tests/lib/libc/gen/Atffile tests-lib-tests atf
./usr/tests/lib/libc/gen/t_basedirname tests-lib-tests atf
+./usr/tests/lib/libc/gen/t_dir tests-lib-tests atf
+./usr/tests/lib/libc/gen/t_fmtcheck tests-lib-tests atf
./usr/tests/lib/libc/gen/t_glob_star tests-lib-tests atf
+./usr/tests/lib/libc/gen/t_humanize_number tests-lib-tests atf
+./usr/tests/lib/libc/gen/t_rbstress tests-lib-tests atf
./usr/tests/lib/libc/gen/t_syslog_pthread tests-lib-tests atf
./usr/tests/lib/libc/gen/t_siginfo tests-lib-tests atf
+./usr/tests/lib/libc/gen/t_vis tests-lib-tests atf
./usr/tests/lib/libc/hash tests-lib-tests
./usr/tests/lib/libc/hash/Atffile tests-lib-tests atf
./usr/tests/lib/libc/hash/t_sha2 tests-lib-tests atf
diff -r bc826e53301d -r 8deb952c661a tests/lib/libc/gen/Makefile
--- a/tests/lib/libc/gen/Makefile Tue Dec 28 10:20:27 2010 +0000
+++ b/tests/lib/libc/gen/Makefile Tue Dec 28 12:46:15 2010 +0000
@@ -1,12 +1,17 @@
-# $NetBSD: Makefile,v 1.6 2010/12/25 01:25:37 pgoyette Exp $
+# $NetBSD: Makefile,v 1.7 2010/12/28 12:46:15 pgoyette Exp $
.include <bsd.own.mk>
TESTSDIR= ${TESTSBASE}/lib/libc/gen
+TESTS_C+= t_basedirname
+TESTS_C+= t_dir
+TESTS_C+= t_fmtcheck
TESTS_C+= t_glob_star
+TESTS_C+= t_humanize_number
+TESTS_C+= t_rbstress
TESTS_C+= t_syslog_pthread
-TESTS_C+= t_basedirname
+TESTS_C+= t_vis
.if !make(obj) && !make(cleandir)
HAVE_SIGINFO != if (echo "\#include <signal.h>" && echo "SA_SIGINFO") | ${CC} -E -I${DESTDIR}/usr/include - | grep -sq 0x0040; then echo yes; else echo no; fi
diff -r bc826e53301d -r 8deb952c661a tests/lib/libc/gen/t_dir.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/lib/libc/gen/t_dir.c Tue Dec 28 12:46:15 2010 +0000
@@ -0,0 +1,163 @@
+/* $NetBSD: t_dir.c,v 1.1 2010/12/28 12:46:15 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 <assert.h>
+#include <dirent.h>
+#include <err.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include <sys/stat.h>
+
+ATF_TC(seekdir);
+
+ATF_TC_HEAD(seekdir, tc)
+{
+
+ atf_tc_set_md_var(tc, "descr",
+ "Check telldir(3) and seekdir(3) for correct behavior (PR/24324)");
+}
+
+ATF_TC_BODY(seekdir, tc)
+{
+ DIR *dp;
+ char *wasname;
+ struct dirent *entry;
+ long here;
+
+ mkdir("t", 0755);
+ creat("t/a", 0600);
+ creat("t/b", 0600);
+ creat("t/c", 0600);
+
+ dp = opendir("t");
+ if ( dp == NULL)
+ atf_tc_fail("Could not open temp directory.");
+
+ /* skip two for . and .. */
+ entry = readdir(dp);
+ entry = readdir(dp);
+
+ /* get first entry */
+ entry = readdir(dp);
+ here = telldir(dp);
+
+ /* get second entry */
+ entry = readdir(dp);
+ wasname = strdup(entry->d_name);
+
+ /* get third entry */
+ entry = readdir(dp);
+
+ /* try to return to the position after the first entry */
+ seekdir(dp, here);
+ entry = readdir(dp);
+
+ if (strcmp(entry->d_name, wasname) != 0)
+ atf_tc_fail("1st seekdir found wrong name");
+
+ /* try again, and throw in a telldir() for good measure */
+ seekdir(dp, here);
+ here = telldir(dp);
+ entry = readdir(dp);
+
+ if (strcmp(entry->d_name, wasname) != 0)
+ atf_tc_fail("2nd seekdir found wrong name");
+
+ /* One more time, to make sure that telldir() doesn't affect result */
+ seekdir(dp, here);
+ entry = readdir(dp);
+
+ if (strcmp(entry->d_name, wasname) != 0)
+ atf_tc_fail("3rd seekdir found wrong name");
+
+ closedir(dp);
+}
+
+ATF_TC(telldir_leak);
+
+ATF_TC_HEAD(telldir_leak, tc)
+{
+
+ atf_tc_set_md_var(tc, "descr",
+ "Check telldir(3) for memory leakage (PR/24324)");
+}
+
+ATF_TC_BODY(telldir_leak, tc)
+{
+ DIR *dp;
+ long loc;
+ char *memused;
+ int i;
+ int oktouse = 4096;
+
+ dp = opendir(".");
+ if (dp == NULL)
+ atf_tc_fail("Could not open current directory");
+
+ loc = telldir(dp);
+ memused = sbrk(0);
+ closedir(dp);
+
+ for (i=0; i<1000; i++) {
+ dp = opendir(".");
+ if (dp == NULL)
+ atf_tc_fail("Could not open current directory");
+
+ loc = telldir(dp);
+ closedir(dp);
+
+ if ((char *)(sbrk(0)) - memused > oktouse) {
+ (void)printf("Used %td extra bytes for %d telldir "
+ "calls", ((char *)(sbrk(0)) - memused), i);
+ oktouse = (char *)(sbrk(0)) - memused;
+ }
+ }
+ if (oktouse > 4096) {
+ atf_tc_fail("Failure: leaked %td bytes", oktouse);
+ } else {
+ (void)printf("OK: used %td bytes\n", (char *)(sbrk(0))-memused);
+ }
+}
+
+ATF_TP_ADD_TCS(tp)
+{
+
+ ATF_TP_ADD_TC(tp, seekdir);
+ ATF_TP_ADD_TC(tp, telldir_leak);
+
+ return atf_no_error();
+}
diff -r bc826e53301d -r 8deb952c661a tests/lib/libc/gen/t_fmtcheck.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/lib/libc/gen/t_fmtcheck.c Tue Dec 28 12:46:15 2010 +0000
@@ -0,0 +1,116 @@
+/* $NetBSD: t_fmtcheck.c,v 1.1 2010/12/28 12:46:15 pgoyette Exp $ */
+
+/*-
+ * Copyright (c) 2000 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code was contributed to The NetBSD Foundation by Allen Briggs.
+ *
+ * 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>
+
+const char *fmtcheck(const char *f1, const char *f2)
+ __attribute__((__format_arg__(2)));
+
+#include <err.h>
+
+struct test_fmt {
+ const char *fmt1;
+ const char *fmt2;
+ int correct;
+} test_fmts[] = {
+ { "%d", "%d", 1 },
+ { "%2d", "%2.2d", 1 },
+ { "%x", "%d", 1 },
+ { "%u", "%d", 1 },
+ { "%03d", "%d", 1 },
+ { "%-2d", "%d", 1 },
+ { "%d", "%-12.1d", 1 },
+ { "%d", "%-01.3d", 1 },
+ { "%X", "%-01.3d", 1 },
+ { "%D", "%ld", 1 },
+ { "%s", "%s", 1 },
+ { "%s", "This is a %s test", 1 },
+ { "Hi, there. This is a %s test", "%s", 1 },
+ { "%d", "%s", 2 },
+ { "%e", "%s", 2 },
+ { "%r", "%d", 2 },
+ { "%*.2d", "%*d", 1 },
+ { "%2.*d", "%*d", 2 },
+ { "%*d", "%*d", 1 },
+ { "%-3", "%d", 2 },
+ { "%d %s", "%d", 2 },
Home |
Main Index |
Thread Index |
Old Index