2010-10-13 Jim Meyering <meyering@redhat.com>
+ test-select: avoid warn_unused_result warnings
+ * tests/test-select.c: Include "macros.h".
+ ASSERT that each call to read, write, and pipe succeeds.
+ While not technically required, also check each "close".
+ * modules/select-tests (Files): Add tests/macros.h.
+
test-symlinkat: remove declaration of unused local
* tests/test-symlinkat.c (main): Remove unused local, "buf".
#include <sys/ioctl.h>
#include <errno.h>
+#include "macros.h"
+
enum { SEL_IN = 1, SEL_OUT = 2, SEL_EXC = 4 };
#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
addrlen = sizeof (ia);
c2 = accept (s, (struct sockaddr *) &ia, &addrlen);
- close (s);
- close (c1);
- close (c2);
+ ASSERT (close (s) == 0);
+ ASSERT (close (c1) == 0);
+ ASSERT (close (c2) == 0);
}
{
addrlen = sizeof (ia);
c = accept (s, (struct sockaddr *) &ia, &addrlen);
- close (s);
- write (c, "foo", 3);
- read (c, buf, 3);
+ ASSERT (close (s) == 0);
+ ASSERT (write (c, "foo", 3) == 3);
+ ASSERT (read (c, buf, 3) == 3);
shutdown (c, SHUT_RD);
- close (c);
+ ASSERT (close (c) == 0);
exit (0);
}
else
{
- close (s);
+ ASSERT (close (s) == 0);
c = connect_to_socket (true);
if (do_select_nowait (c, SEL_OUT) != SEL_OUT)
failed ("cannot write after blocking connect");
- write (c, "foo", 3);
+ ASSERT (write (c, "foo", 3) == 3);
wait (&pid);
if (do_select_wait (c, SEL_IN) != SEL_IN)
failed ("cannot read data left in the socket by closed process");
- read (c, buf, 3);
- write (c, "foo", 3);
- close (c);
+ ASSERT (read (c, buf, 3) == 3);
+ ASSERT (write (c, "foo", 3) == 3);
+ ASSERT (close (c) == 0);
}
#endif
}
if (do_select_nowait (wd, SEL_IN | SEL_OUT | SEL_EXC) != SEL_OUT)
failed ("expecting writability before writing");
- write (wd, "foo", 3);
+ ASSERT (write (wd, "foo", 3) == 3);
if (do_select_wait (rd, SEL_IN) != SEL_IN)
failed ("expecting readability after writing");
if (do_select_nowait (rd, SEL_IN) != SEL_IN)
failed ("expecting readability after writing");
- read (rd, buf, 3);
+ ASSERT (read (rd, buf, 3) == 3);
}
int c1 = connect_to_socket (false);
int c2 = accept (s, (struct sockaddr *) &ia, &addrlen);
- close (s);
+ ASSERT (close (s) == 0);
test_pair (c1, c2);
- close (c1);
- write (c2, "foo", 3);
- close (c2);
+ ASSERT (close (c1) == 0);
+ ASSERT (write (c2, "foo", 3) == 3);
+ ASSERT (close (c2) == 0);
}
{
int fd[2];
- pipe (fd);
+ ASSERT (pipe (fd) == 0);
test_pair (fd[0], fd[1]);
- close (fd[0]);
- close (fd[1]);
+ ASSERT (close (fd[0]) == 0);
+ ASSERT (close (fd[1]) == 0);
}