summaryrefslogtreecommitdiff
path: root/regress/sys
diff options
context:
space:
mode:
authorThomas Nordin <nordin@cvs.openbsd.org>2001-12-17 01:22:06 +0000
committerThomas Nordin <nordin@cvs.openbsd.org>2001-12-17 01:22:06 +0000
commit6c1dce855fd3707e6e2030d04dea6ae56bf5798b (patch)
tree1640ebc6a7a1e4b33f615ec239654ecfa55c67aa /regress/sys
parent0010267e96aaaf97e6480064e2a87cd397eb54e6 (diff)
Check for monotonic user and system time.
Diffstat (limited to 'regress/sys')
-rw-r--r--regress/sys/kern/Makefile4
-rw-r--r--regress/sys/kern/getrusage/Makefile11
-rw-r--r--regress/sys/kern/getrusage/getrusage.c35
3 files changed, 48 insertions, 2 deletions
diff --git a/regress/sys/kern/Makefile b/regress/sys/kern/Makefile
index d9fd038af74..c6db9d52663 100644
--- a/regress/sys/kern/Makefile
+++ b/regress/sys/kern/Makefile
@@ -1,7 +1,7 @@
-# $OpenBSD: Makefile,v 1.6 2001/10/08 22:44:24 art Exp $
+# $OpenBSD: Makefile,v 1.7 2001/12/17 01:22:05 nordin Exp $
# $NetBSD: Makefile,v 1.2 1995/04/20 22:42:51 cgd Exp $
-SUBDIR+= execve mmap dup2
+SUBDIR+= execve getrusage mmap dup2
regress: _SUBDIRUSE
diff --git a/regress/sys/kern/getrusage/Makefile b/regress/sys/kern/getrusage/Makefile
new file mode 100644
index 00000000000..97cbab8a5e0
--- /dev/null
+++ b/regress/sys/kern/getrusage/Makefile
@@ -0,0 +1,11 @@
+# $OpenBSD: Makefile,v 1.1 2001/12/17 01:22:05 nordin Exp $
+
+PROG= getrusage
+NOMAN= noman, no way, man
+
+install:
+
+regress:
+ ./getrusage
+
+.include <bsd.prog.mk>
diff --git a/regress/sys/kern/getrusage/getrusage.c b/regress/sys/kern/getrusage/getrusage.c
new file mode 100644
index 00000000000..ffc4bad49b1
--- /dev/null
+++ b/regress/sys/kern/getrusage/getrusage.c
@@ -0,0 +1,35 @@
+#include <err.h>
+#include <limits.h>
+#include <stddef.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <sys/time.h>
+#include <sys/resource.h>
+#include <sys/types.h>
+
+int
+main()
+{
+ struct timeval utime;
+ struct timeval stime;
+ struct rusage r;
+ int i;
+
+ timerclear(&utime);
+ timerclear(&stime);
+ do {
+ if (getrusage(RUSAGE_SELF, &r) == -1)
+ err(1, "getrusage");
+
+ if (timercmp(&(r.ru_utime), &utime, <))
+ errx(1, "user time decreased");
+ utime = r.ru_utime;
+
+ if (timercmp(&(r.ru_stime), &stime, <))
+ errx(1, "system time decreased");
+ stime = r.ru_stime;
+ } while (utime.tv_sec < 1 && stime.tv_sec < 1);
+
+ return 0;
+}