From: Lance Richardson Date: Fri, 22 Jan 2016 15:12:29 +0000 (-0500) Subject: system-traffic: use appropriate nc options for installed version X-Git-Url: http://git.cascardo.eti.br/?p=cascardo%2Fovs.git;a=commitdiff_plain;h=b54971f72ec6775564f26642f2696e37eabb23be system-traffic: use appropriate nc options for installed version Test cases using netcat ("ICMP related" and "ICMP related with NAT") currently fail on systems using the nmap version of nc because this version does not support the -q command-line option. Fix this by detecting which version of netcat is is in use and using the "--send-only" command-line option when the nmap flavor is detected, and using "-q 1" otherwise (openbsd and traditional versions). Tested via "make check-kernel" on RHEL7 (nmap version of nc), Debian 8.2 (openbsd version of nc), and Ubuntu 14.04 ("traditional" nc). Signed-off-by: Lance Richardson Signed-off-by: Joe Stringer --- diff --git a/tests/atlocal.in b/tests/atlocal.in index 5815c6c8c..2a163dbb8 100644 --- a/tests/atlocal.in +++ b/tests/atlocal.in @@ -117,3 +117,10 @@ if test "$HAVE_PYTHON" = "yes" \ else HAVE_PYFTPDLIB="no" fi + +# Determine correct netcat option to quit on stdin EOF +if nc --version 2>&1 | grep -q nmap.org; then + NC_EOF_OPT="--send-only" +else + NC_EOF_OPT="-q 1" +fi diff --git a/tests/system-traffic.at b/tests/system-traffic.at index 799abc208..3a0d6fa88 100644 --- a/tests/system-traffic.at +++ b/tests/system-traffic.at @@ -876,8 +876,7 @@ priority=100,in_port=2,icmp,ct_state=+trk+rel,ct_mark=1,action=1 AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) dnl UDP packets from ns0->ns1 should solicit "destination unreachable" response. -dnl We pass "-q 1" here to handle openbsd-style nc that can't quit immediately. -NS_CHECK_EXEC([at_ns0], [bash -c "echo a | nc -q 1 -u 10.1.1.2 10000"]) +NS_CHECK_EXEC([at_ns0], [bash -c "echo a | nc $NC_EOF_OPT -u 10.1.1.2 10000"]) AT_CHECK([ovs-appctl revalidator/purge], [0]) AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort | grep -v drop], [0], [dnl @@ -1681,8 +1680,7 @@ table=10 priority=0 action=drop AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) dnl UDP packets from ns0->ns1 should solicit "destination unreachable" response. -dnl We pass "-q 1" here to handle openbsd-style nc that can't quit immediately. -NS_CHECK_EXEC([at_ns0], [bash -c "echo a | nc -q 1 -u 10.1.1.2 10000"]) +NS_CHECK_EXEC([at_ns0], [bash -c "echo a | nc $NC_EOF_OPT -u 10.1.1.2 10000"]) AT_CHECK([ovs-appctl revalidator/purge], [0]) AT_CHECK([ovs-ofctl -O OpenFlow15 dump-flows br0 | ofctl_strip | sort | grep -v drop], [0], [dnl