mirror of
https://github.com/openbsd/src.git
synced 2025-01-10 06:47:55 -08:00
Test for monotonically increasing timeofday.
This commit is contained in:
parent
e46ab3b74a
commit
01f282fc10
5
regress/sys/kern/gettimeofday/Makefile
Normal file
5
regress/sys/kern/gettimeofday/Makefile
Normal file
@ -0,0 +1,5 @@
|
||||
# $OpenBSD: Makefile,v 1.1 2002/02/21 09:21:30 nordin Exp $
|
||||
|
||||
PROG= gettimeofday
|
||||
|
||||
.include <bsd.regress.mk>
|
31
regress/sys/kern/gettimeofday/gettimeofday.c
Normal file
31
regress/sys/kern/gettimeofday/gettimeofday.c
Normal file
@ -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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user