Source-Changes-HG archive

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

[src/trunk]: src/tests/net/arp Clean up the arp_rtm subtest...



details:   https://anonhg.NetBSD.org/src/rev/7294e81915d3
branches:  trunk
changeset: 828024:7294e81915d3
user:      kre <kre%NetBSD.org@localhost>
date:      Thu Nov 23 06:22:12 2017 +0000

description:
Clean up the arp_rtm subtest...

1. Be assertive when claiming the pid of the background route monitor command,
   not polite...  (ie: $! will give you the pid, $? is just 0 there).
2. Since "wait 0" simply (always) exits with status 127, immediately (we
   know without thinking that we have no child with pid 0) the waits were
   ineffective - now (after fix #1) they work .. which requires the
   route monitor that watches the arp -d to exit after 1 message, not 2,
   as 1 is all it gets.   (If there really should be 2, someone needs to
   find out why the kernel is sending only 1 - I am not that someone).
3. The file contents need to be read only once, no matter how many patterns
   we need to look for, save some work, and do it that way (this is not
   really a bug,m but saving time for the ATF tests is always a good thing.)

Not sure if this will stop it randomly failing on bablyon5, but it might.
(The likely cause is that the "route.monitor" has not flushed its stdout
buffers at the time the "grep -A 3"  [aside: why that way to read the file??]
is performed, so fails to find its expected output ... the route monitor would
get an extra message once interfaces start being destroyed, I assume, and
would exit then, flushing its buffer, but by then it is too late.
If that is/was the cause, then it should be fixed now.)

diffstat:

 tests/net/arp/t_arp.sh |  32 +++++++++++++++-----------------
 1 files changed, 15 insertions(+), 17 deletions(-)

diffs (65 lines):

diff -r d937a403c55b -r 7294e81915d3 tests/net/arp/t_arp.sh
--- a/tests/net/arp/t_arp.sh    Thu Nov 23 04:59:49 2017 +0000
+++ b/tests/net/arp/t_arp.sh    Thu Nov 23 06:22:12 2017 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: t_arp.sh,v 1.33 2017/06/28 08:17:50 ozaki-r Exp $
+#      $NetBSD: t_arp.sh,v 1.34 2017/11/23 06:22:12 kre Exp $
 #
 # Copyright (c) 2015 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -626,7 +626,7 @@
 {
        local macaddr_src= macaddr_dst=
        local file=./tmp
-       local pid= str=
+       local pid= hdr= what= addr=
 
        rump_server_start $SOCKSRC
        rump_server_start $SOCKDST
@@ -641,33 +641,31 @@
 
        # Test ping and a resulting routing message (RTM_ADD)
        rump.route -n monitor -c 1 > $file &
-       pid=$?
+       pid=$!
        sleep 1
        atf_check -s exit:0 -o ignore rump.ping -n -w 1 -c 1 $IP4DST
        wait $pid
        $DEBUG && cat $file
 
-       str="RTM_ADD.+<UP,HOST,DONE,LLINFO,CLONED>"
-       atf_check -s exit:0 -o match:"$str" cat $file
-       str="<DST,GATEWAY>"
-       atf_check -s exit:0 -o match:"$str" cat $file
-       str="$IP4DST link#2"
-       atf_check -s exit:0 -o match:"$str" cat $file
+       hdr="RTM_ADD.+<UP,HOST,DONE,LLINFO,CLONED>"
+       what="<DST,GATEWAY>"
+       addr="$IP4DST link#2"
+       atf_check -s exit:0 -o match:"$hdr" -o match:"$what" -o match:"$addr" \
+               cat $file
 
        # Test arp -d and resulting routing messages (RTM_DELETE)
-       rump.route -n monitor -c 2 > $file &
-       pid=$?
+       rump.route -n monitor -c 1 > $file &
+       pid=$!
        sleep 1
        atf_check -s exit:0 -o ignore rump.arp -d $IP4DST
        wait $pid
        $DEBUG && cat $file
 
-       str="RTM_DELETE.+<HOST,DONE,LLINFO,CLONED>"
-       atf_check -s exit:0 -o match:"$str" grep -A 3 RTM_DELETE $file
-       str="<DST,GATEWAY>"
-       atf_check -s exit:0 -o match:"$str" grep -A 3 RTM_DELETE $file
-       str="$IP4DST $macaddr_dst"
-       atf_check -s exit:0 -o match:"$str" grep -A 3 RTM_DELETE $file
+       hdr="RTM_DELETE.+<HOST,DONE,LLINFO,CLONED>"
+       what="<DST,GATEWAY>"
+       addr="$IP4DST $macaddr_dst"
+       atf_check -s exit:0 -o match:"$hdr" -o match:"$what" -o match:"$addr" \
+               grep -A 3 RTM_DELETE $file
 
        rump_server_destroy_ifaces
 }



Home | Main Index | Thread Index | Old Index