X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;ds=sidebyside;f=tests%2Ftest-poll.c;h=7ba02805d3d652d84cfd1b3c0b522c2f3aff8772;hb=1f28fa660e4ca110f073251a24ef3a94ad97ef69;hp=967da7acbca8cdff2a242dc2e83003f86c074f78;hpb=1602f0afed21be664fcf5c42d59db07cc22c56d6;p=gnulib.git
diff --git a/tests/test-poll.c b/tests/test-poll.c
index 967da7acb..7ba02805d 100644
--- a/tests/test-poll.c
+++ b/tests/test-poll.c
@@ -12,8 +12,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software Foundation,
- Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
+ along with this program; if not, see . */
/* Written by Paolo Bonzini. */
@@ -36,11 +35,13 @@ SIGNATURE_CHECK (poll, int, (struct pollfd[], nfds_t, int));
#include
#include
+#include "macros.h"
+
#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
-# define WIN32_NATIVE
+# define WINDOWS_NATIVE
#endif
-#ifdef WIN32_NATIVE
+#ifdef WINDOWS_NATIVE
#include
#define pipe(x) _pipe(x, 256, O_BINARY)
#endif
@@ -132,7 +133,7 @@ connect_to_socket (int blocking)
if (!blocking)
{
-#ifdef WIN32_NATIVE
+#ifdef WINDOWS_NATIVE
unsigned long iMode = 1;
ioctl (s, FIONBIO, (char *) &iMode);
@@ -246,7 +247,7 @@ test_connect_first (void)
static void
test_accept_first (void)
{
-#ifndef WIN32_NATIVE
+#ifndef WINDOWS_NATIVE
int s = open_server_socket ();
struct sockaddr_in ia;
socklen_t addrlen;
@@ -261,9 +262,10 @@ test_accept_first (void)
{
addrlen = sizeof (ia);
c = accept (s, (struct sockaddr *) &ia, &addrlen);
+ ASSERT (c >= 0);
close (s);
- write (c, "foo", 3);
- read (c, buf, 3);
+ ASSERT (write (c, "foo", 3) == 3);
+ ASSERT (read (c, buf, 3) == 3);
shutdown (c, SHUT_RD);
close (c);
exit (0);
@@ -272,15 +274,16 @@ test_accept_first (void)
{
close (s);
c = connect_to_socket (true);
+ ASSERT (c >= 0);
if (poll1_nowait (c, POLLOUT | POLLWRNORM | POLLRDBAND)
!= (POLLOUT | POLLWRNORM))
failed ("cannot write after blocking connect");
- write (c, "foo", 3);
+ ASSERT (write (c, "foo", 3) == 3);
wait (&pid);
if (poll1_wait (c, POLLIN) != POLLIN)
failed ("cannot read data left in the socket by closed process");
- read (c, buf, 3);
- write (c, "foo", 3);
+ ASSERT (read (c, buf, 3) == 3);
+ ASSERT (write (c, "foo", 3) == 3);
if ((poll1_wait (c, POLLIN | POLLOUT) & (POLLHUP | POLLERR)) == 0)
failed ("expecting POLLHUP after shutdown");
close (c);
@@ -304,7 +307,7 @@ test_pair (int rd, int wd)
!= POLLWRNORM)
failed ("expecting POLLWRNORM before writing");
- write (wd, "foo", 3);
+ ASSERT (write (wd, "foo", 3) == 3);
if (poll1_wait (rd, POLLIN | POLLRDNORM) != (POLLIN | POLLRDNORM))
failed ("expecting POLLIN | POLLRDNORM after writing");
if (poll1_nowait (rd, POLLIN) != POLLIN)
@@ -312,7 +315,7 @@ test_pair (int rd, int wd)
if (poll1_nowait (rd, POLLRDNORM) != POLLRDNORM)
failed ("expecting POLLRDNORM after writing");
- read (rd, buf, 3);
+ ASSERT (read (rd, buf, 3) == 3);
}
@@ -327,12 +330,15 @@ test_socket_pair (void)
int s = open_server_socket ();
int c1 = connect_to_socket (false);
int c2 = accept (s, (struct sockaddr *) &ia, &addrlen);
+ ASSERT (s >= 0);
+ ASSERT (c1 >= 0);
+ ASSERT (c2 >= 0);
close (s);
test_pair (c1, c2);
close (c1);
- write (c2, "foo", 3);
+ ASSERT (write (c2, "foo", 3) == 3);
if ((poll1_nowait (c2, POLLIN | POLLOUT) & (POLLHUP | POLLERR)) == 0)
failed ("expecting POLLHUP after shutdown");
@@ -347,7 +353,7 @@ test_pipe (void)
{
int fd[2];
- pipe (fd);
+ ASSERT (pipe (fd) >= 0);
test_pair (fd[0], fd[1]);
close (fd[0]);
if ((poll1_wait (fd[1], POLLIN | POLLOUT) & (POLLHUP | POLLERR)) == 0)