ovs-ofctl: Correct formatting of instructions in manpage.
[sliver-openvswitch.git] / tests / test-timeval.c
index b336f39..9896cf7 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, 2010 Nicira Networks.
+ * Copyright (c) 2009, 2010, 2011 Nicira, Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -37,7 +37,7 @@ gettimeofday_in_msec(void)
 {
     struct timeval tv;
 
-    assert(!gettimeofday(&tv, NULL));
+    xgettimeofday(&tv);
     return timeval_to_msec(&tv);
 }
 
@@ -93,11 +93,16 @@ main(int argc, char *argv[])
 {
     proctitle_init(argc, argv);
     set_program_name(argv[0]);
-    time_init();
 
     if (argc != 2) {
         usage();
     } else if (!strcmp(argv[1], "plain")) {
+        /* If we're not caching time there isn't much to test and SIGALRM won't
+         * be around to pull us out of the select() call, so just skip out */
+        if (!CACHE_TIME) {
+            exit (77);
+        }
+
         do_test();
     } else if (!strcmp(argv[1], "daemon")) {
         /* Test that time still advances even in a daemon.  This is an
@@ -105,6 +110,10 @@ main(int argc, char *argv[])
         char cwd[1024], *pidfile;
         FILE *success;
 
+        if (!CACHE_TIME) {
+            exit (77);
+        }
+
         assert(getcwd(cwd, sizeof cwd) == cwd);
 
         unlink("test-timeval.success");