1 m4_divert_push([PREPARE_TESTS])
3 # Strips out uninteresting parts of ovs-ofctl output, as well as parts
4 # that vary from one run to another.
7 s/ (xid=0x[0-9a-fA-F]*)//
8 s/ duration=[0-9.]*s,//
18 # parse_listening_port [SERVER]
20 # Parses the TCP or SSL port on which a server is listening from the
21 # log, given that the server was told to listen on a kernel-chosen
22 # port, file provided on stdin, and prints the port number on stdout.
23 # You should specify the listening remote as ptcp:0:127.0.0.1 or
24 # pssl:0:127.0.0.1, or the equivalent with [::1] instead of 127.0.0.1.
26 # Here's an example of how to use this with ovsdb-server:
28 # OVS_LOGDIR=`pwd`; export OVS_LOGDIR
29 # ovsdb-server --log-file --remote=ptcp:0:127.0.0.1 ...
30 # TCP_PORT=`parse_listening_port < ovsdb-server.log`
31 parse_listening_port () {
32 sed -n 's/.*0:.*: listening on port \([0-9]*\)$/\1/p'
34 m4_divert_pop([PREPARE_TESTS])
36 m4_define([STRIP_XIDS], [[sed 's/ (xid=0x[0-9a-fA-F]*)//']])
37 m4_define([STRIP_DURATION], [[sed 's/\bduration=[0-9.]*s/duration=?s/']])
38 m4_define([STRIP_USED], [[sed 's/used:[0-9]\.[0-9]*/used:0.0/']])
39 m4_define([TESTABLE_LOG], [-vPATTERN:ANY:'%c|%p|%m'])
41 # OVS_VSWITCHD_START([vsctl-args], [vsctl-output], [=override])
43 # Creates a database and starts ovsdb-server, starts ovs-vswitchd
44 # connected to that database, calls ovs-vsctl to create a bridge named
45 # br0 with predictable settings, passing 'vsctl-args' as additional
46 # commands to ovs-vsctl. If 'vsctl-args' causes ovs-vsctl to provide
47 # output (e.g. because it includes "create" commands) then 'vsctl-output'
48 # specifies the expected output after filtering through uuidfilt.pl.
50 # If a test needs to use "system" devices (as dummies), then specify
51 # =override (literally) as the third argument. Otherwise, system devices
52 # won't work at all (which makes sense because tests should not access a
53 # system's real Ethernet devices).
54 m4_define([OVS_VSWITCHD_START],
55 [OVS_RUNDIR=`pwd`; export OVS_RUNDIR
56 OVS_LOGDIR=`pwd`; export OVS_LOGDIR
57 OVS_DBDIR=`pwd`; export OVS_DBDIR
58 OVS_SYSCONFDIR=`pwd`; export OVS_SYSCONFDIR
59 ON_EXIT([kill `cat ovsdb-server.pid ovs-vswitchd.pid`])
63 AT_CHECK([ovsdb-tool create conf.db $abs_top_srcdir/vswitchd/vswitch.ovsschema])
65 dnl Start ovsdb-server.
66 AT_CHECK([ovsdb-server --detach --no-chdir --pidfile --log-file --remote=punix:$OVS_RUNDIR/db.sock], [0], [], [stderr])
67 AT_CHECK([[sed < stderr '
68 /vlog|INFO|opened log file/d
69 /ovsdb_server|INFO|ovsdb-server (Open vSwitch)/d']])
70 AT_CAPTURE_FILE([ovsdb-server.log])
72 dnl Initialize database.
73 AT_CHECK([ovs-vsctl --no-wait init])
75 dnl Start ovs-vswitchd.
76 AT_CHECK([ovs-vswitchd --detach --no-chdir --pidfile --enable-dummy$3 --disable-system --log-file -vvconn -vofproto_dpif], [0], [], [stderr])
77 AT_CAPTURE_FILE([ovs-vswitchd.log])
78 AT_CHECK([[sed < stderr '
79 /vlog|INFO|opened log file/d
80 /vswitchd|INFO|ovs-vswitchd (Open vSwitch)/d
82 /ofproto|INFO|using datapath ID/d
83 /ofproto|INFO|datapath ID changed to fedcba9876543210/d']])
85 dnl Add bridges, ports, etc.
86 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 protocols=[[OpenFlow10,OpenFlow11,OpenFlow12,OpenFlow13]] fail-mode=secure -- $1 m4_if([$2], [], [], [| ${PERL} $srcdir/uuidfilt.pl])], [0], [$2])
89 m4_divert_push([PREPARE_TESTS])
92 /timeval.*Unreasonably long [[0-9]]*ms poll interval/d
93 /timeval.*faults: [[0-9]]* minor, [[0-9]]* major/d
94 /timeval.*disk: [[0-9]]* reads, [[0-9]]* writes/d
95 /timeval.*context switches: [[0-9]]* voluntary, [[0-9]]* involuntary/d
98 /|EMER|/p" ovs-vswitchd.log ovsdb-server.log
100 m4_divert_pop([PREPARE_TESTS])
102 # OVS_VSWITCHD_STOP([WHITELIST])
104 # Gracefully stops ovs-vswitchd and ovsdb-server, checking their log files
105 # for messages with severity WARN or higher and signaling an error if any
106 # is present. The optional WHITELIST may contain shell-quoted "sed"
107 # commands to delete any warnings that are actually expected, e.g.:
109 # OVS_VSWITCHD_STOP(["/expected error/d"])
110 m4_define([OVS_VSWITCHD_STOP],
111 [AT_CHECK([check_logs $1])
112 AT_CHECK([ovs-appctl -t ovs-vswitchd exit])
113 AT_CHECK([ovs-appctl -t ovsdb-server exit])])
115 # ADD_OF_PORTS(BRIDGE, OF_PORT[, OF_PORT...])
117 # Creates a dummy interface with an OpenFlow port number of OF_PORT and
118 # name of p{OF_PORT}. The dummy implementation will treat the OF_PORT
119 # as the datapath port number, which as the effect of making the
120 # OpenFlow and datapath numbers the same.
121 m4_define([ADD_OF_PORTS],
122 [ovs-vsctl m4_foreach([of_port], m4_cdr($@),
124 -- add-port $1 p[]of_port -- set Interface p[]of_port type=dummy ofport_request=of_port])])