Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/tests/net/net make it work on linux, be pickier about errors...



details:   https://anonhg.NetBSD.org/src/rev/9c9bb0d1baee
branches:  trunk
changeset: 343926:9c9bb0d1baee
user:      christos <christos%NetBSD.org@localhost>
date:      Fri Mar 04 18:52:01 2016 +0000

description:
make it work on linux, be pickier about errors, and correct variable type.

diffstat:

 tests/net/net/t_tcp.c |  15 +++++++++++----
 1 files changed, 11 insertions(+), 4 deletions(-)

diffs (53 lines):

diff -r a5b723c12b30 -r 9c9bb0d1baee tests/net/net/t_tcp.c
--- a/tests/net/net/t_tcp.c     Fri Mar 04 17:49:06 2016 +0000
+++ b/tests/net/net/t_tcp.c     Fri Mar 04 18:52:01 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: t_tcp.c,v 1.3 2013/10/17 12:53:28 christos Exp $       */
+/*     $NetBSD: t_tcp.c,v 1.4 2016/03/04 18:52:01 christos Exp $       */
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
 
 #include <sys/cdefs.h>
 #ifdef __RCSID
-__RCSID("$Id: t_tcp.c,v 1.3 2013/10/17 12:53:28 christos Exp $");
+__RCSID("$Id: t_tcp.c,v 1.4 2016/03/04 18:52:01 christos Exp $");
 #endif
 
 /* Example code. Should block; does with accept not paccept. */
@@ -61,6 +61,10 @@
 #define FAIL(msg, ...)  ATF_CHECK_MSG(0, msg, ## __VA_ARGS__); goto fail
 #endif
 
+#ifdef __linux__
+#define paccept(a, b, c, d, e) accept4((a), (b), (c), (e))
+#endif
+
 static void
 ding(int al)
 {
@@ -70,7 +74,8 @@
 paccept_block(bool pacceptblock, bool fcntlblock)
 {
        int srvr = -1, clnt = -1, as = -1;
-       int ok, fl, n;
+       int ok, fl;
+       ssize_t n;
        char buf[10];
        struct sockaddr_in sin, ba;
        struct sigaction sa;
@@ -105,10 +110,12 @@
 
        /* may not connect first time */
        ok = connect(clnt, (struct sockaddr *) &ba, addrlen);
+       if (ok != -1 || errno != EINPROGRESS)
+               FAIL("expected connect to fail");
        as = paccept(srvr, NULL, NULL, NULL, pacceptblock ? 0 : SOCK_NONBLOCK);
        ok = connect(clnt, (struct sockaddr *) &ba, addrlen);
        if (ok == -1 && errno != EISCONN)
-               FAIL("both connects failed");
+               FAIL("connect failed");
 
 #if 0
        fl = fcntl(srvr, F_GETFL, 0);



Home | Main Index | Thread Index | Old Index