X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=tests%2Ftest-timeval.c;h=533f81aed3ff87e7e236628cb237d9ff800df591;hb=169e3808f7c510a048589d8e658336919079a6a0;hp=ba8b3d39df3089ee4cd61fb3ee60eb3f645f7a53;hpb=e7cfedd6dedab619603ddc3c3832a2b7a0f82f89;p=openvswitch diff --git a/tests/test-timeval.c b/tests/test-timeval.c index ba8b3d39..533f81ae 100644 --- a/tests/test-timeval.c +++ b/tests/test-timeval.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009 Nicira Networks. + * Copyright (c) 2009, 2010 Nicira Networks. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,10 +20,12 @@ #include #include +#include #include #include #include +#include "command-line.h" #include "daemon.h" #include "util.h" @@ -55,9 +57,16 @@ do_test(void) /* Wait up to 1 second. Using select() to do the timeout avoids * interfering with the interval timer. */ struct timeval timeout; + int retval; + timeout.tv_sec = 1; timeout.tv_usec = 0; - assert(select(0, NULL, NULL, NULL, &timeout) == -1 && errno == EINTR); + retval = select(0, NULL, NULL, NULL, &timeout); + if (retval != -1) { + ovs_fatal(0, "select returned %d", retval); + } else if (errno != EINTR) { + ovs_fatal(errno, "select reported unexpected error"); + } if (gettimeofday_in_msec() - start_gtod >= TIME_UPDATE_INTERVAL) { assert(time_msec() - start_time_msec >= TIME_UPDATE_INTERVAL); @@ -76,6 +85,7 @@ usage(void) int main(int argc, char *argv[]) { + proctitle_init(argc, argv); set_program_name(argv[0]); time_init(); @@ -86,7 +96,7 @@ main(int argc, char *argv[]) } else if (!strcmp(argv[1], "daemon")) { /* Test that time still advances even in a daemon. This is an * interesting test because fork() cancels the interval timer. */ - char cwd[1024]; + char cwd[1024], *pidfile; FILE *success; assert(getcwd(cwd, sizeof cwd) == cwd); @@ -95,7 +105,9 @@ main(int argc, char *argv[]) /* Daemonize, with a pidfile in the current directory. */ set_detach(); - set_pidfile(xasprintf("%s/test-timeval.pid", cwd)); + pidfile = xasprintf("%s/test-timeval.pid", cwd); + set_pidfile(pidfile); + free(pidfile); set_no_chdir(); daemonize();