X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=tests%2Ftest-select-stdin.c;h=5a6f81a86ac9448e0df48e7534d54d903d5cd1c8;hb=e81d3b1b46e69f9799deb665769f9796c4e454e6;hp=e855f92d20dc28b53b018c347965967e1c168796;hpb=69374b85907050e3c6d8f845d5c9846c0fb581de;p=gnulib.git diff --git a/tests/test-select-stdin.c b/tests/test-select-stdin.c index e855f92d2..5a6f81a86 100644 --- a/tests/test-select-stdin.c +++ b/tests/test-select-stdin.c @@ -1,5 +1,5 @@ /* Test of select() substitute, reading from stdin. - Copyright (C) 2008 Free Software Foundation, Inc. + Copyright (C) 2008-2011 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -24,8 +24,10 @@ #include #include +#include "macros.h" + int -main () +main (void) { printf ("Applying select() from standard input. Press Ctrl-C to abort.\n"); for (;;) @@ -47,34 +49,35 @@ main () gettimeofday (&after, NULL); spent_usec = (after.tv_sec - before.tv_sec) * 1000000 - + after.tv_usec - before.tv_usec; + + after.tv_usec - before.tv_usec; if (ret < 0) - { - perror ("select failed"); - exit (1); - } + { + perror ("select failed"); + exit (1); + } if ((ret == 0) != ! FD_ISSET (0, &readfds)) - { - fprintf (stderr, "incorrect return value\n"); - exit (1); - } + { + fprintf (stderr, "incorrect return value\n"); + exit (1); + } if (ret == 0) - { - if (spent_usec < 250000) - { - fprintf (stderr, "returned too early\n"); - exit (1); - } - /* Timeout */ - printf ("."); fflush (stdout); - } + { + if (spent_usec < 250000) + { + fprintf (stderr, "returned too early\n"); + exit (1); + } + /* Timeout */ + printf ("."); + ASSERT (fflush (stdout) == 0); + } else - { - char c; + { + char c; - printf ("Input available! Trying to read 1 byte...\n"); - read (0, &c, 1); - } + printf ("Input available! Trying to read 1 byte...\n"); + ASSERT (read (0, &c, 1) == 1); + } } }