Source-Changes-HG archive

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

[src/trunk]: src/tests/net/icmp Handle errors better.



details:   https://anonhg.NetBSD.org/src/rev/6833336ff34b
branches:  trunk
changeset: 360711:6833336ff34b
user:      roy <roy%NetBSD.org@localhost>
date:      Mon Mar 26 09:11:15 2018 +0000

description:
Handle errors better.
Fix test for checking we sent all the data we asked to.

diffstat:

 tests/net/icmp/t_ping.c |  19 +++++++++++--------
 1 files changed, 11 insertions(+), 8 deletions(-)

diffs (47 lines):

diff -r 5bbfe515e693 -r 6833336ff34b tests/net/icmp/t_ping.c
--- a/tests/net/icmp/t_ping.c   Mon Mar 26 06:40:28 2018 +0000
+++ b/tests/net/icmp/t_ping.c   Mon Mar 26 09:11:15 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: t_ping.c,v 1.22 2018/03/24 15:51:57 roy Exp $  */
+/*     $NetBSD: t_ping.c,v 1.23 2018/03/26 09:11:15 roy Exp $  */
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: t_ping.c,v 1.22 2018/03/24 15:51:57 roy Exp $");
+__RCSID("$NetBSD: t_ping.c,v 1.23 2018/03/26 09:11:15 roy Exp $");
 #endif /* not lint */
 
 #include <sys/types.h>
@@ -334,7 +334,8 @@
        char ifname[IFNAMSIZ];
        pid_t cpid;
        size_t tot, frag;
-       int s, x, loop, error;
+       int s, x, loop;
+       ssize_t error;
 
        cpid = fork();
        rump_init();
@@ -420,11 +421,13 @@
 
                        error = rump_sys_sendto(s, data, frag, 0,
                            (struct sockaddr *)&dst, sizeof(dst));
-                       if (error == sizeof(dst))
-                               continue;
-                       if (error == -1 && errno == ENOBUFS)
-                               continue;
-                       atf_tc_fail_errno("sendto failed");
+                       if (error == -1) {
+                               if (errno == ENOBUFS)
+                                       continue;
+                               atf_tc_fail_errno("sendto failed");
+                       }
+                       if ((size_t)error != frag)
+                               atf_tc_fail("sendto did not write all data");
                }
                if (waitpid(-1, &status, WNOHANG) > 0) {
                        if (WIFEXITED(status) && WEXITSTATUS(status) == 0)



Home | Main Index | Thread Index | Old Index