summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--modules/select-tests1
-rw-r--r--tests/test-select.c44
3 files changed, 30 insertions, 21 deletions
diff --git a/ChangeLog b/ChangeLog
index 03bdd3fee1..e7838e1109 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
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".
diff --git a/modules/select-tests b/modules/select-tests
index 6019b44951..566e4d9595 100644
--- a/modules/select-tests
+++ b/modules/select-tests
@@ -1,4 +1,5 @@
Files:
+tests/macros.h
tests/signature.h
tests/test-select.c
tests/test-select-fd.c
diff --git a/tests/test-select.c b/tests/test-select.c
index 884e823394..9c895c3b21 100644
--- a/tests/test-select.c
+++ b/tests/test-select.c
@@ -48,6 +48,8 @@ SIGNATURE_CHECK (FD_ZERO, void, (fd_set *));
#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__
@@ -263,9 +265,9 @@ test_connect_first (void)
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);
}
@@ -289,26 +291,26 @@ test_accept_first (void)
{
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
}
@@ -325,13 +327,13 @@ test_pair (int rd, int wd)
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);
}
@@ -347,12 +349,12 @@ test_socket_pair (void)
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);
}
@@ -363,10 +365,10 @@ test_pipe (void)
{
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);
}