From: Ben Pfaff Date: Thu, 8 Dec 2011 21:22:50 +0000 (-0800) Subject: tests: Add expected output parameter to OVS_VSWITCHD_START. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9da5b93abce74a41cce2bcba2d17c7b781123f7b;p=openvswitch tests: Add expected output parameter to OVS_VSWITCHD_START. It's convenient to pass commands for ovs-vsctl directly to OVS_VSWITCHD_START, but until now those commands could have no output because that would cause a test failure. This commit adds an optional argument to supply ovs-vsctl expected output, and adjusts some test cases to use it instead of calling ovs-vsctl a second time. Signed-off-by: Ben Pfaff --- diff --git a/tests/ofproto-dpif.at b/tests/ofproto-dpif.at index a6558742..d733f9b5 100644 --- a/tests/ofproto-dpif.at +++ b/tests/ofproto-dpif.at @@ -379,17 +379,14 @@ AT_CLEANUP AT_SETUP([ofproto-dpif - mirroring, select_all]) -OVS_VSWITCHD_START -AT_CHECK([ovs-vsctl \ - add-port br0 p1 -- set Interface p1 type=dummy --\ +OVS_VSWITCHD_START( + [add-port br0 p1 -- set Interface p1 type=dummy --\ add-port br0 p2 -- set Interface p2 type=dummy --\ add-port br0 p3 -- set Interface p3 type=dummy --\ set Bridge br0 mirrors=@m --\ --id=@p3 get Port p3 --\ --id=@m create Mirror name=mymirror \ - select_all=true output_port=@p3 ], [0], [stdout]) -AT_CHECK([perl $srcdir/uuidfilt.pl stdout], [0], [dnl -<0> + select_all=true output_port=@p3], [<0> ]) AT_CHECK( @@ -424,17 +421,14 @@ AT_CLEANUP AT_SETUP([ofproto-dpif - mirroring, select_src]) -OVS_VSWITCHD_START -AT_CHECK([ovs-vsctl \ - add-port br0 p1 -- set Interface p1 type=dummy --\ +OVS_VSWITCHD_START( + [add-port br0 p1 -- set Interface p1 type=dummy --\ add-port br0 p2 -- set Interface p2 type=dummy --\ add-port br0 p3 -- set Interface p3 type=dummy --\ set Bridge br0 mirrors=@m --\ --id=@p1 get Port p1 -- --id=@p3 get Port p3 --\ --id=@m create Mirror name=mymirror \ - select_src_port=@p1 output_port=@p3 ], [0], [stdout]) -AT_CHECK([perl $srcdir/uuidfilt.pl stdout], [0], [dnl -<0> + select_src_port=@p1 output_port=@p3], [<0> ]) AT_CHECK( @@ -468,17 +462,14 @@ AT_CLEANUP AT_SETUP([ofproto-dpif - mirroring, select_dst]) -OVS_VSWITCHD_START -AT_CHECK([ovs-vsctl \ - add-port br0 p1 -- set Interface p1 type=dummy --\ +OVS_VSWITCHD_START( + [add-port br0 p1 -- set Interface p1 type=dummy --\ add-port br0 p2 -- set Interface p2 type=dummy --\ add-port br0 p3 -- set Interface p3 type=dummy --\ set Bridge br0 mirrors=@m --\ --id=@p2 get Port p2 -- --id=@p3 get Port p3 --\ --id=@m create Mirror name=mymirror \ - select_dst_port=@p2 output_port=@p3 ], [0], [stdout]) -AT_CHECK([perl $srcdir/uuidfilt.pl stdout], [0], [dnl -<0> + select_dst_port=@p2 output_port=@p3], [<0> ]) AT_CHECK( @@ -513,17 +504,14 @@ AT_CLEANUP AT_SETUP([ofproto-dpif - mirroring, select_vlan]) -OVS_VSWITCHD_START -AT_CHECK([ovs-vsctl \ - add-port br0 p1 -- set Interface p1 type=dummy --\ +OVS_VSWITCHD_START( + [add-port br0 p1 -- set Interface p1 type=dummy --\ add-port br0 p2 -- set Interface p2 type=dummy --\ add-port br0 p3 -- set Interface p3 type=dummy --\ set Bridge br0 mirrors=@m --\ --id=@p2 get Port p2 -- --id=@p3 get Port p3 --\ --id=@m create Mirror name=mymirror \ - select_all=true select_vlan=11 output_port=@p3 ], [0], [stdout]) -AT_CHECK([perl $srcdir/uuidfilt.pl stdout], [0], [dnl -<0> + select_all=true select_vlan=11 output_port=@p3], [<0> ]) AT_CHECK( @@ -563,17 +551,14 @@ AT_CLEANUP AT_SETUP([ofproto-dpif - mirroring, output_port]) -OVS_VSWITCHD_START -AT_CHECK([ovs-vsctl \ - add-port br0 p1 -- set Interface p1 type=dummy --\ +OVS_VSWITCHD_START( + [add-port br0 p1 -- set Interface p1 type=dummy --\ add-port br0 p2 -- set Interface p2 type=dummy --\ add-port br0 p3 -- set Interface p3 type=dummy --\ set Bridge br0 mirrors=@m --\ --id=@p3 get Port p3 --\ --id=@m create Mirror name=mymirror \ - select_all=true output_port=@p3 ], [0], [stdout]) -AT_CHECK([perl $srcdir/uuidfilt.pl stdout], [0], [dnl -<0> + select_all=true output_port=@p3], [<0> ]) AT_CHECK( @@ -606,17 +591,13 @@ AT_CHECK_UNQUOTED([tail -1 stdout], [0], OVS_VSWITCHD_STOP AT_CLEANUP - AT_SETUP([ofproto-dpif - mirroring, output_vlan]) -OVS_VSWITCHD_START -AT_CHECK([ovs-vsctl \ - add-port br0 p1 -- set Interface p1 type=dummy --\ +OVS_VSWITCHD_START( + [add-port br0 p1 -- set Interface p1 type=dummy --\ add-port br0 p2 -- set Interface p2 type=dummy --\ set Bridge br0 mirrors=@m --\ --id=@m create Mirror name=mymirror \ - select_all=true output_vlan=12 ], [0], [stdout]) -AT_CHECK([perl $srcdir/uuidfilt.pl stdout], [0], [dnl -<0> + select_all=true output_vlan=12], [<0> ]) AT_CHECK( diff --git a/tests/ofproto-macros.at b/tests/ofproto-macros.at index 64e99f38..13586c36 100644 --- a/tests/ofproto-macros.at +++ b/tests/ofproto-macros.at @@ -2,6 +2,14 @@ m4_define([STRIP_XIDS], [[sed 's/ (xid=0x[0-9a-fA-F]*)//']]) m4_define([STRIP_DURATION], [[sed 's/\bduration=[0-9.]*s/duration=?s/']]) m4_define([TESTABLE_LOG], [-vPATTERN:ANY:'%c|%p|%m']) +# OVS_VSWITCHD_START([vsctl-args], [vsctl-output]) +# +# Creates a database and starts ovsdb-server, starts ovs-vswitchd +# connected to that database, calls ovs-vsctl to create a bridge named +# br0 with predictable settings, passing 'vsctl-args' as additional +# commands to ovs-vsctl. If 'vsctl-args' causes ovs-vsctl to provide +# output (e.g. because it includes "create" commands) then 'vsctl-output' +# specifies the expected output after filtering through uuidfilt.pl. m4_define([OVS_VSWITCHD_START], [OVS_RUNDIR=$PWD; export OVS_RUNDIR OVS_LOGDIR=$PWD; export OVS_LOGDIR @@ -31,7 +39,7 @@ m4_define([OVS_VSWITCHD_START], /ofproto|INFO|datapath ID changed to fedcba9876543210/d']]) dnl Add bridges, ports, etc. - AT_CHECK([ovs-vsctl -- add-br br0 -- set bridge br0 datapath-type=dummy other-config:datapath-id=fedcba9876543210 other-config:hwaddr=aa:55:aa:55:00:00 fail-mode=secure -- $1]) + AT_CHECK([ovs-vsctl -- add-br br0 -- set bridge br0 datapath-type=dummy other-config:datapath-id=fedcba9876543210 other-config:hwaddr=aa:55:aa:55:00:00 fail-mode=secure -- $1 m4_if([$2], [], [], [| perl $srcdir/uuidfilt.pl])], [0], [$2]) ]) m4_define([OVS_VSWITCHD_STOP],