Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src Move the clock_gettime(2) timer test to the right place.
details: https://anonhg.NetBSD.org/src/rev/8cce2122f131
branches: trunk
changeset: 770379:8cce2122f131
user: jruoho <jruoho%NetBSD.org@localhost>
date: Sat Oct 15 06:42:16 2011 +0000
description:
Move the clock_gettime(2) timer test to the right place.
diffstat:
distrib/sets/lists/tests/mi | 8 +-
tests/kernel/Makefile | 3 +-
tests/kernel/t_time.c | 211 ----------------------------------
tests/lib/libc/sys/Makefile | 3 +-
tests/lib/libc/sys/t_clock_gettime.c | 212 +++++++++++++++++++++++++++++++++++
5 files changed, 220 insertions(+), 217 deletions(-)
diffs (truncated from 508 to 300 lines):
diff -r a8b962f6c9c5 -r 8cce2122f131 distrib/sets/lists/tests/mi
--- a/distrib/sets/lists/tests/mi Sat Oct 15 06:33:45 2011 +0000
+++ b/distrib/sets/lists/tests/mi Sat Oct 15 06:42:16 2011 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.405 2011/10/15 06:33:46 jruoho Exp $
+# $NetBSD: mi,v 1.406 2011/10/15 06:42:17 jruoho Exp $
#
# Note: don't delete entries from here - mark them as "obsolete" instead.
#
@@ -332,7 +332,7 @@
./usr/libdata/debug/usr/tests/kernel/t_pty.debug tests-kernel-tests debug,atf
./usr/libdata/debug/usr/tests/kernel/t_rnd.debug tests-kernel-tests debug,atf
./usr/libdata/debug/usr/tests/kernel/t_sigaction.debug tests-kernel-tests debug,atf
-./usr/libdata/debug/usr/tests/kernel/t_time.debug tests-kernel-tests debug,atf
+./usr/libdata/debug/usr/tests/kernel/t_time.debug tests-obsolete obsolete
./usr/libdata/debug/usr/tests/kernel/t_ucontext.debug tests-kernel-tests debug,atf
./usr/libdata/debug/usr/tests/kernel/t_writev.debug tests-kernel-tests debug,atf
./usr/libdata/debug/usr/tests/kernel/tty tests-kernel-tests
@@ -488,6 +488,7 @@
./usr/libdata/debug/usr/tests/lib/libc/sys/t_access.debug tests-lib-debug debug,atf
./usr/libdata/debug/usr/tests/lib/libc/sys/t_cerror.debug tests-obsolete obsolete
./usr/libdata/debug/usr/tests/lib/libc/sys/t_chroot.debug tests-lib-debug debug,atf
+./usr/libdata/debug/usr/tests/lib/libc/sys/t_clock_gettime.debug tests-lib-debug debug,atf
./usr/libdata/debug/usr/tests/lib/libc/sys/t_clone.debug tests-lib-debug debug,atf
./usr/libdata/debug/usr/tests/lib/libc/sys/t_context.debug tests-obsolete obsolete
./usr/libdata/debug/usr/tests/lib/libc/sys/t_dup.debug tests-lib-debug debug,atf
@@ -1859,7 +1860,7 @@
./usr/tests/kernel/t_pty tests-kernel-tests atf
./usr/tests/kernel/t_rnd tests-kernel-tests atf
./usr/tests/kernel/t_sigaction tests-kernel-tests atf
-./usr/tests/kernel/t_time tests-kernel-tests atf
+./usr/tests/kernel/t_time tests-obsolete obsolete
./usr/tests/kernel/t_ucontext tests-kernel-tests atf
./usr/tests/kernel/t_umount tests-kernel-tests atf
./usr/tests/kernel/t_writev tests-kernel-tests atf
@@ -2103,6 +2104,7 @@
./usr/tests/lib/libc/sys/t_access tests-lib-tests atf
./usr/tests/lib/libc/sys/t_cerror tests-obsolete obsolete
./usr/tests/lib/libc/sys/t_chroot tests-lib-tests atf
+./usr/tests/lib/libc/sys/t_clock_gettime tests-lib-tests atf
./usr/tests/lib/libc/sys/t_clone tests-lib-tests atf
./usr/tests/lib/libc/sys/t_context tests-obsolete obsolete
./usr/tests/lib/libc/sys/t_dup tests-lib-tests atf
diff -r a8b962f6c9c5 -r 8cce2122f131 tests/kernel/Makefile
--- a/tests/kernel/Makefile Sat Oct 15 06:33:45 2011 +0000
+++ b/tests/kernel/Makefile Sat Oct 15 06:42:16 2011 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.17 2011/10/15 06:33:45 jruoho Exp $
+# $NetBSD: Makefile,v 1.18 2011/10/15 06:42:16 jruoho Exp $
NOMAN= # defined
@@ -12,7 +12,6 @@
TESTS_C+= t_lwpctl
TESTS_C+= t_pty
TESTS_C+= t_rnd
-TESTS_C+= t_time
TESTS_C+= t_ucontext
TESTS_C+= t_writev
TESTS_C+= t_extattrctl
diff -r a8b962f6c9c5 -r 8cce2122f131 tests/kernel/t_time.c
--- a/tests/kernel/t_time.c Sat Oct 15 06:33:45 2011 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,211 +0,0 @@
-/* $NetBSD: t_time.c,v 1.2 2010/11/08 21:38:13 pooka Exp $ */
-
-/*-
- * Copyright (c) 2008 The NetBSD Foundation, Inc.
- * All rights reserved.
- *
- * This code is derived from software contributed to The NetBSD Foundation
- * by Frank Kardel.
- *
- * 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.
- */
-
-/*-
- * Copyright (c) 2006 Frank Kardel
- * 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.
- */
-
-#include <sys/cdefs.h>
-__COPYRIGHT("@(#) Copyright (c) 2008\
- The NetBSD Foundation, inc. All rights reserved.");
-__RCSID("$NetBSD: t_time.c,v 1.2 2010/11/08 21:38:13 pooka Exp $");
-
-#include <sys/param.h>
-#include <sys/sysctl.h>
-
-#include <machine/int_limits.h>
-
-#include <errno.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <time.h>
-#include <unistd.h>
-
-#include <atf-c.h>
-
-#include "../h_macros.h"
-
-#define MINPOSDIFF 15000000 /* 15 ms for now */
-#define TIMEOUT 5
-
-#define TC_HARDWARE "kern.timecounter.hardware"
-#define TC_CHOICE "kern.timecounter.choice"
-
-static void
-check_timecounter(void)
-{
- struct timespec tsa, tsb, tsl, res;
- long long mindiff = INTMAX_MAX;
- time_t endlimit;
-
-#define CL(x) \
- do { \
- if ((x) != -1) \
- break; \
- atf_tc_fail_nonfatal("%s: %s", #x, strerror(errno)); \
- return; \
- } while (0)
-
- CL(clock_gettime(CLOCK_REALTIME, &tsa));
- tsl = tsa;
-
- CL(time(&endlimit));
- endlimit += TIMEOUT + 1;
-
- while ((time_t)tsa.tv_sec < endlimit) {
- long long diff;
-
- CL(clock_gettime(CLOCK_REALTIME, &tsb));
- diff = 1000000000LL * (tsb.tv_sec - tsa.tv_sec)
- + tsb.tv_nsec - tsa.tv_nsec;
-
- if (diff > 0 && mindiff > diff)
- mindiff = diff;
-
- if (diff < 0 || diff > MINPOSDIFF) {
- long long elapsed;
- (void)printf("%stime TSA: 0x%jx.%08jx, TSB: 0x%jx.%08jx, "
- "diff = %lld nsec, ", (diff < 0) ? "BAD " : "",
- (uintmax_t)tsa.tv_sec, (uintmax_t)tsa.tv_nsec,
- (uintmax_t)tsb.tv_sec, (uintmax_t)tsb.tv_nsec, diff);
-
- elapsed = 1000000000LL * (tsb.tv_sec - tsl.tv_sec)
- + tsb.tv_nsec - tsl.tv_nsec;
-
-
- (void)printf("%lld nsec\n", elapsed);
- tsl = tsb;
-
- ATF_CHECK(diff >= 0);
- if (diff < 0)
- return;
- }
-
- tsa.tv_sec = tsb.tv_sec;
- tsa.tv_nsec = tsb.tv_nsec;
- }
-
- if (clock_getres(CLOCK_REALTIME, &res) == 0) {
- long long r = res.tv_sec * 1000000000 + res.tv_nsec;
-
- (void)printf("Claimed resolution: %lld nsec (%f Hz) or "
- "better\n", r, 1.0 / r * 1e9);
- (void)printf("Observed minimum non zero delta: %lld "
- "nsec\n", mindiff);
- }
-
-#undef CL
-}
-
-ATF_TC(time);
-ATF_TC_HEAD(time, tc)
-{
- atf_tc_set_md_var(tc, "require.user", "root");
- atf_tc_set_md_var(tc, "descr",
- "Checks the monotonicity of the CLOCK_REALTIME implementation");
- atf_tc_set_md_var(tc, "timeout", "300");
-}
-ATF_TC_BODY(time, tc)
-{
- char name[128], cbuf[512], ctrbuf[10240];
- size_t cbufsiz = sizeof(cbuf);
- size_t ctrbufsiz = sizeof(ctrbuf);
- const char *p;
- char *save;
- int quality, n;
-
- if (sysctlbyname(TC_HARDWARE, cbuf, &cbufsiz, NULL, 0) != 0) {
- (void)printf("\nChecking legacy time implementation "
- "for %d seconds\n", TIMEOUT);
- check_timecounter();
- return;
- /* NOTREACHED */
- }
- (void)printf("%s = %s\n", TC_HARDWARE, cbuf);
- REQUIRE_LIBC(save = strdup(cbuf), NULL);
-
- RL(sysctlbyname(TC_CHOICE, ctrbuf, &ctrbufsiz, NULL, 0));
- (void)printf("%s = %s\n", TC_CHOICE, ctrbuf);
-
- for (p = ctrbuf, n = 0; sscanf(p, "%127[^(](q=%d, f=%*u Hz)%*[ ]%n",
- name, &quality, &n) == 2; p += n) {
- struct timespec ts;
- int ret;
-
- if (quality < 0)
- continue;
-
- (void)printf("\nChecking %s for %d seconds\n", name, TIMEOUT);
- CHECK_LIBC(ret = sysctlbyname(TC_HARDWARE, NULL, 0,
- name, strlen(name)), -1);
- if (ret == -1)
- continue;
-
- /* wait a bit to select new counter in clockinterrupt */
- ts.tv_sec = 0;
- ts.tv_nsec = 100000000;
- (void)nanosleep(&ts, NULL);
-
- check_timecounter();
- }
-
- RL(sysctlbyname(TC_HARDWARE, NULL, 0, save, strlen(save)));
-}
-
-ATF_TP_ADD_TCS(tp)
-{
- ATF_TP_ADD_TC(tp, time);
-
- return atf_no_error();
-}
diff -r a8b962f6c9c5 -r 8cce2122f131 tests/lib/libc/sys/Makefile
--- a/tests/lib/libc/sys/Makefile Sat Oct 15 06:33:45 2011 +0000
+++ b/tests/lib/libc/sys/Makefile Sat Oct 15 06:42:16 2011 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.12 2011/10/15 06:26:34 jruoho Exp $
+# $NetBSD: Makefile,v 1.13 2011/10/15 06:42:16 jruoho Exp $
MKMAN= no
@@ -10,6 +10,7 @@
TESTS_C+= t_access
TESTS_C+= t_chroot
+TESTS_C+= t_clock_gettime
TESTS_C+= t_clone
TESTS_C+= t_dup
TESTS_C+= t_fsync
diff -r a8b962f6c9c5 -r 8cce2122f131 tests/lib/libc/sys/t_clock_gettime.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/lib/libc/sys/t_clock_gettime.c Sat Oct 15 06:42:16 2011 +0000
@@ -0,0 +1,212 @@
+/* $NetBSD: t_clock_gettime.c,v 1.1 2011/10/15 06:42:16 jruoho Exp $ */
+
+/*-
+ * Copyright (c) 2008 The NetBSD Foundation, Inc.
Home |
Main Index |
Thread Index |
Old Index