diff options
author | Thomas Nordin <nordin@cvs.openbsd.org> | 2001-12-17 01:22:06 +0000 |
---|---|---|
committer | Thomas Nordin <nordin@cvs.openbsd.org> | 2001-12-17 01:22:06 +0000 |
commit | 6c1dce855fd3707e6e2030d04dea6ae56bf5798b (patch) | |
tree | 1640ebc6a7a1e4b33f615ec239654ecfa55c67aa /regress/sys/kern/getrusage | |
parent | 0010267e96aaaf97e6480064e2a87cd397eb54e6 (diff) |
Check for monotonic user and system time.
Diffstat (limited to 'regress/sys/kern/getrusage')
-rw-r--r-- | regress/sys/kern/getrusage/Makefile | 11 | ||||
-rw-r--r-- | regress/sys/kern/getrusage/getrusage.c | 35 |
2 files changed, 46 insertions, 0 deletions
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; +} |