1
0
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:
nordin 2002-02-21 09:21:30 +00:00
parent e46ab3b74a
commit 01f282fc10
2 changed files with 36 additions and 0 deletions

View File

@ -0,0 +1,5 @@
# $OpenBSD: Makefile,v 1.1 2002/02/21 09:21:30 nordin Exp $
PROG= gettimeofday
.include <bsd.regress.mk>

View 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;
}