+m4_divert_push([PREPARE_TESTS])
+[
+# Strips out uninteresting parts of ovs-ofctl output, as well as parts
+# that vary from one run to another.
+ofctl_strip () {
+ sed '
+s/ (xid=0x[0-9a-fA-F]*)//
+s/ duration=[0-9.]*s,//
+s/ cookie=0x0,//
+s/ table=0,//
+s/ n_packets=0,//
+s/ n_bytes=0,//
+s/ idle_age=[0-9]*,//
+s/ hard_age=[0-9]*,//
+'
+}
+
+# parse_listening_port [SERVER]
+#
+# Parses the TCP or SSL port on which a server is listening from the
+# log, given that the server was told to listen on a kernel-chosen
+# port, file provided on stdin, and prints the port number on stdout.
+# You should specify the listening remote as ptcp:0:127.0.0.1 or
+# pssl:0:127.0.0.1, or the equivalent with [::1] instead of 127.0.0.1.
+#
+# Here's an example of how to use this with ovsdb-server:
+#
+# OVS_LOGDIR=`pwd`; export OVS_LOGDIR
+# ovsdb-server --log-file --remote=ptcp:0:127.0.0.1 ...
+# TCP_PORT=`parse_listening_port < ovsdb-server.log`
+parse_listening_port () {
+ sed -n 's/.*0:.*: listening on port \([0-9]*\)$/\1/p'
+}]
+m4_divert_pop([PREPARE_TESTS])
+