IPsec: refactor out some code in OVS_MONITOR_IPSEC_START macro
[cascardo/ovs.git] / tests / ofproto-macros.at
index da49eb2..2d65f28 100644 (file)
@@ -465,3 +465,47 @@ m4_define([WAIT_FOR_DUMMY_PORTS], \
       [  \
         OVS_WAIT_WHILE([ovs-appctl netdev-dummy/conn-state dummy_port \
                   | grep 'unknown\|disconnected'])])])
+
+# OVS_MONITOR_IPSEC_START()
+#
+# Starts ovs-monitor-ipsec daemon.  Use this macro only after testing
+# that python is present on the system.
+m4_define([OVS_MONITOR_IPSEC_START],
+[
+cp "$top_srcdir/vswitchd/vswitch.ovsschema" .
+
+on_exit 'kill `cat pid ovs-monitor-ipsec.pid`'
+
+mkdir etc etc/init.d etc/racoon etc/racoon/certs
+mkdir usr usr/sbin
+
+AT_DATA([etc/init.d/racoon], [dnl
+#! /bin/sh
+echo "racoon: @S|@@" >&3
+exit 0
+])
+chmod +x etc/init.d/racoon
+
+AT_DATA([usr/sbin/setkey], [dnl
+#! /bin/sh
+exec >&3
+echo "setkey:"
+while read line; do
+      echo "> $line"
+done
+])
+chmod +x usr/sbin/setkey
+
+touch etc/racoon/certs/ovs-stale.pem
+
+###
+### Start ovs-monitor-ipsec and wait for it to delete the stale cert.
+###
+AT_CHECK(
+  [$PYTHON $top_srcdir/debian/ovs-monitor-ipsec "--root-prefix=`pwd`" \
+        "--pidfile=`pwd`/ovs-monitor-ipsec.pid" \
+        unix:$OVS_RUNDIR/db.sock 2>log 3>actions &])
+AT_CAPTURE_FILE([log])
+AT_CAPTURE_FILE([actions])
+OVS_WAIT_UNTIL([test ! -f etc/racoon/certs/ovs-stale.pem])
+])