[ovs-dev] [PATCH 3/3] tests/ofproto: add basic test for OFPT_GET_ASYNC_REQUEST/REPLY

Ben Pfaff blp at nicira.com
Sat Sep 7 17:16:09 UTC 2013


On Sat, Sep 07, 2013 at 03:36:23PM +0300, Alexandru Copot wrote:
> This only checks the default settings.
> 
> Signed-off-by: Alexandru Copot <alex.mihai.c at gmail.com>
> Cc: Daniel Baluta <dbaluta at ixiacom.com>

I had never seen this use of
        read -r -d '' expected <<'EOF'
        ...
        EOF
before.  It is clever.  I learned something.

But I think that:
        expected='...
        ...
        '
would work just as well, although the first line of $expected is a
little harder to see since it is indented.

Either way, I think that the use of "fgrep" here, with the output
ignored, will not have the desired effect, because (f)grep treats each
new-line separated pattern string as a separate pattern to search for,
and returns success if any pattern is matched in the input.  Thus, if
any of the lines in $expected (even a blank line!) is present in the
output, then the test will pass.  That's much looser than I'd like.

I think that we can just test the entire output, passing it through
ofctl_strip to remove xids.

Also, these commands weren't needed because OVS_VSWITCHD_START adds a
bridge br0 and enables OpenFlow 1.3 on it:
> +ovs-vsctl add-br br0
> +ovs-vsctl set bridge br0 protocols=OpenFlow13

So here's what I changed this commit to:

--8<--------------------------cut here-------------------------->8--

From: Alexandru Copot <alex.mihai.c at gmail.com>
Date: Sat, 7 Sep 2013 15:36:23 +0300
Subject: [PATCH] tests/ofproto: add basic test for
 OFPT_GET_ASYNC_REQUEST/REPLY

This only checks the default settings.

Signed-off-by: Alexandru Copot <alex.mihai.c at gmail.com>
Cc: Daniel Baluta <dbaluta at ixiacom.com>
Signed-off-by: Ben Pfaff <blp at nicira.com>
---
 tests/ofproto.at |   34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)

diff --git a/tests/ofproto.at b/tests/ofproto.at
index 38bfb02..91ee85a 100644
--- a/tests/ofproto.at
+++ b/tests/ofproto.at
@@ -1878,3 +1878,37 @@ NXT_FLOW_MONITOR_RESUMED:
 
 OVS_VSWITCHD_STOP
 AT_CLEANUP
+
+AT_SETUP([ofproto - event filtering (OpenFlow 1.3)])
+AT_KEYWORDS([monitor])
+OVS_VSWITCHD_START
+
+# Start a monitor, use the required protocol version
+ovs-ofctl -O OpenFlow13 monitor br0 --detach --no-chdir --pidfile >monitor.log 2>&1
+AT_CAPTURE_FILE([monitor.log])
+
+# Send an OpenFlow13 message (04), OFPT_GET_ASYNC_REQUEST (1a), length (8), xid (0a)
+ovs-appctl -t ovs-ofctl ofctl/send 041a00080000000a
+ovs-appctl -t ovs-ofctl ofctl/barrier
+
+# Check default setting
+read -r -d '' expected <<'EOF'
+EOF
+
+AT_CHECK([ofctl_strip < monitor.log], [], [dnl
+send: OFPT_GET_ASYNC_REQUEST (OF1.3):
+OFPT_GET_ASYNC_REPLY (OF1.3):
+ master:
+       PACKET_IN: no_match action
+     PORT_STATUS: add delete modify
+    FLOW_REMOVED: idle hard delete
+
+ slave:
+       PACKET_IN: (off)
+     PORT_STATUS: add delete modify
+    FLOW_REMOVED: (off)
+OFPT_BARRIER_REPLY (OF1.3):
+])
+
+OVS_VSWITCHD_STOP
+AT_CLEANUP
-- 
1.7.10.4




More information about the dev mailing list