ofp-msgs: New approach to encoding and decoding OpenFlow headers.
[sliver-openvswitch.git] / tests / ofproto-macros.at
1 m4_divert_push([PREPARE_TESTS])
2 [
3 # Strips out uninteresting parts of ovs-ofctl output, as well as parts
4 # that vary from one run to another.
5 ofctl_strip () {
6     sed '
7 s/ (xid=0x[0-9a-fA-F]*)//
8 s/ duration=[0-9.]*s,//
9 s/ cookie=0x0,//
10 s/ table=0,//
11 s/ n_packets=0,//
12 s/ n_bytes=0,//
13 s/ idle_age=[0-9]*,//
14 s/ hard_age=[0-9]*,//
15 '
16 }]
17 m4_divert_pop([PREPARE_TESTS])
18
19 m4_define([STRIP_XIDS], [[sed 's/ (xid=0x[0-9a-fA-F]*)//']])
20 m4_define([STRIP_DURATION], [[sed 's/\bduration=[0-9.]*s/duration=?s/']])
21 m4_define([TESTABLE_LOG], [-vPATTERN:ANY:'%c|%p|%m'])
22
23 # OVS_VSWITCHD_START([vsctl-args], [vsctl-output])
24 #
25 # Creates a database and starts ovsdb-server, starts ovs-vswitchd
26 # connected to that database, calls ovs-vsctl to create a bridge named
27 # br0 with predictable settings, passing 'vsctl-args' as additional
28 # commands to ovs-vsctl.  If 'vsctl-args' causes ovs-vsctl to provide
29 # output (e.g. because it includes "create" commands) then 'vsctl-output'
30 # specifies the expected output after filtering through uuidfilt.pl.
31 m4_define([OVS_VSWITCHD_START],
32   [OVS_RUNDIR=`pwd`; export OVS_RUNDIR
33    OVS_LOGDIR=`pwd`; export OVS_LOGDIR
34    OVS_SYSCONFDIR=`pwd`; export OVS_SYSCONFDIR
35    trap 'kill `cat ovsdb-server.pid ovs-vswitchd.pid`' 0
36
37    dnl Create database.
38    mkdir openvswitch
39    touch openvswitch/.conf.db.~lock~
40    AT_CHECK([ovsdb-tool create openvswitch/conf.db $abs_top_srcdir/vswitchd/vswitch.ovsschema])
41
42    dnl Start ovsdb-server.
43    AT_CHECK([ovsdb-server --detach --pidfile --log-file --remote=punix:$OVS_RUNDIR/db.sock], [0], [], [stderr])
44    AT_CHECK([[sed < stderr '
45 /vlog|INFO|opened log file/d
46 /ovsdb_server|INFO|ovsdb-server (Open vSwitch)/d']])
47    AT_CAPTURE_FILE([ovsdb-server.log])
48
49    dnl Initialize database.
50    AT_CHECK([ovs-vsctl --no-wait init])
51
52    dnl Start ovs-vswitchd.
53    AT_CHECK([ovs-vswitchd --detach --pidfile --enable-dummy --disable-system --log-file -vvconn], [0], [], [stderr])
54    AT_CAPTURE_FILE([ovs-vswitchd.log])
55    AT_CHECK([[sed < stderr '
56 /vlog|INFO|opened log file/d
57 /vswitchd|INFO|ovs-vswitchd (Open vSwitch)/d
58 /reconnect|INFO|/d
59 /ofproto|INFO|using datapath ID/d
60 /ofproto|INFO|datapath ID changed to fedcba9876543210/d']])
61
62    dnl Add bridges, ports, etc.
63    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])
64 ])
65
66 m4_define([OVS_VSWITCHD_STOP],
67   [AT_CHECK([ovs-appctl -t ovs-vswitchd exit])
68    AT_CHECK([ovs-appctl -t ovsdb-server exit])
69    trap '' 0])