1 /* 2 * Copyright (c) 2009-2011, The Regents of the University of California, 3 * through Lawrence Berkeley National Laboratory (subject to receipt of any 4 * required approvals from the U.S. Dept. of Energy). All rights reserved. 5 * 6 * This code is distributed under a BSD style license, see the LICENSE file 7 * for complete information. 8 */ 9 10 #include <stdio.h> 11 #include <stdlib.h> 12 #include <unistd.h> 13 #include <sys/time.h> 14 15 #include "timer.h" 16 17 int 18 main(int argc, char **argv) 19 { 20 struct timer *tp; 21 tp = new_timer(3, 0); 22 23 sleep(2); 24 25 if (tp->expired(tp)) 26 { 27 printf("timer should not have expired\n"); 28 exit(-1); 29 } 30 sleep(1); 31 32 if (!tp->expired(tp)) 33 { 34 printf("timer should have expired\n"); 35 exit(-2); 36 } 37 exit(0); 38 } 39