summaryrefslogtreecommitdiff
path: root/regress/sys/kern/gettimeofday/gettimeofday.c
diff options
context:
space:
mode:
Diffstat (limited to 'regress/sys/kern/gettimeofday/gettimeofday.c')
-rw-r--r--regress/sys/kern/gettimeofday/gettimeofday.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/regress/sys/kern/gettimeofday/gettimeofday.c b/regress/sys/kern/gettimeofday/gettimeofday.c
new file mode 100644
index 00000000000..b27d16f9c0a
--- /dev/null
+++ b/regress/sys/kern/gettimeofday/gettimeofday.c
@@ -0,0 +1,31 @@
+/* $OpenBSD: gettimeofday.c,v 1.1 2002/02/21 09:21:30 nordin Exp $ */
+/*
+ * Written by Thomas Nordin <nordin@openbsd.org> 2002 Public Domain.
+ */
+#include <err.h>
+#include <stdio.h>
+
+#include <sys/time.h>
+
+int
+main()
+{
+ struct timeval s;
+ struct timeval t1;
+ struct timeval t2;
+
+ if (gettimeofday(&s, NULL) == -1)
+ err(1, "gettimeofday");
+
+ do {
+ if (gettimeofday(&t1, NULL) == -1)
+ err(1, "gettimeofday");
+ if (gettimeofday(&t2, NULL) == -1)
+ err(1, "gettimeofday");
+
+ if (timercmp(&t2, &t1, <))
+ errx(1, "time of day decreased");
+ } while (t1.tv_sec - s.tv_sec < 7);
+
+ return 0;
+}