OVS_LOGDIR=`pwd`; export OVS_LOGDIR
OVS_DBDIR=`pwd`; export OVS_DBDIR
OVS_SYSCONFDIR=`pwd`; export OVS_SYSCONFDIR
- trap 'kill `cat ovsdb-server.pid ovs-vswitchd.pid`' 0
+ ON_EXIT([kill `cat ovsdb-server.pid ovs-vswitchd.pid`])
dnl Create database.
touch .conf.db.~lock~
m4_define([OVS_VSWITCHD_STOP],
[AT_CHECK([ovs-appctl -t ovs-vswitchd exit])
- AT_CHECK([ovs-appctl -t ovsdb-server exit])
- trap '' 0])
+ AT_CHECK([ovs-appctl -t ovsdb-server exit])])
OVS_VSWITCHD_START
# Start a monitor watching the flow table, then make it block.
-trap 'kill `cat ovsdb-server.pid ovs-vswitchd.pid ovs-ofctl.pid`' 0
+ON_EXIT([kill `cat ovs-ofctl.pid`])
ovs-ofctl monitor br0 watch: --detach --no-chdir --pidfile >monitor.log 2>&1
AT_CAPTURE_FILE([monitor.log])
ovs-appctl -t ovs-ofctl ofctl/block
OVS_PKGDATADIR=`pwd`; export OVS_PKGDATADIR
cp "$top_srcdir/vswitchd/vswitch.ovsschema" .
-trap 'kill `cat pid ovs-monitor-ipsec.pid`' 0
+ON_EXIT([kill `cat pid ovs-monitor-ipsec.pid`])
mkdir etc etc/init.d etc/racoon etc/racoon/certs
mkdir usr usr/sbin
AT_SETUP([database commands -- conditions])
AT_KEYWORDS([ovs-vsctl])
-trap 'kill `cat pid`' 0
+ON_EXIT([kill `cat pid`])
OVS_VSCTL_SETUP
AT_CHECK(
[RUN_OVS_VSCTL_TOGETHER(
cp "$top_srcdir/xenserver/usr_share_openvswitch_scripts_ovs-xapi-sync" \
ovs-xapi-sync
-trap 'kill `cat pid ovs-xapi-sync.pid`' 0
+ON_EXIT([kill `cat pid ovs-xapi-sync.pid`])
mkdir var var/run
touch var/run/xapi_init_complete.cookie
m4_define([OVS_WAIT_WHILE],
[OVS_WAIT([if $1; then return 1; else return 0; fi], [$2])])
+dnl ON_EXIT([COMMANDS])
+dnl
+dnl Adds the shell COMMANDS to a collection executed when the current test
+dnl completes, as a cleanup action. (The most common use is to kill a
+dnl daemon started by the test. This is important to prevent tests that
+dnl start daemons from hanging at exit.)
+m4_define([ON_EXIT], [trap '. ./cleanup' 0; cat >>cleanup <<'EOF'
+$1
+EOF
+])
+
m4_include([tests/ovsdb-macros.at])
m4_include([tests/ofproto-macros.at])
OVS_LOGDIR=`pwd`; export OVS_LOGDIR
OVS_DBDIR=`pwd`; export OVS_DBDIR
OVS_SYSCONFDIR=`pwd`; export OVS_SYSCONFDIR
-trap 'kill `cat test-unixctl.py.pid`' 0
+ON_EXIT([kill `cat test-unixctl.py.pid`])
AT_CAPTURE_FILE([`pwd`/test-unixctl.py.log])
AT_CHECK([$PYTHON $srcdir/test-unixctl.py --log-file --pidfile --detach])
AT_CHECK([PYAPPCTL -t test-unixctl.py bogus], [2], [], [experr])
AT_CHECK([APPCTL -t test-unixctl.py exit])
-trap '' 0]
AT_CLEANUP
OVS_LOGDIR=`pwd`; export OVS_LOGDIR
OVS_DBDIR=`pwd`; export OVS_DBDIR
OVS_SYSCONFDIR=`pwd`; export OVS_SYSCONFDIR
-trap 'kill `cat test-unixctl.py.pid`' 0
+ON_EXIT([kill `cat test-unixctl.py.pid`])
AT_CAPTURE_FILE([log])
AT_CAPTURE_FILE([log.old])
AT_CHECK([APPCTL -t test-unixctl.py vlog/reopen])
AT_CHECK([APPCTL -t test-unixctl.py log message3])
AT_CHECK([APPCTL -t test-unixctl.py exit])
-trap '' 0
AT_CHECK([sed 's/.*|//' log.old], [0], [dnl
Entering run loop.
OVS_LOGDIR=`pwd`; export OVS_LOGDIR
OVS_DBDIR=`pwd`; export OVS_DBDIR
OVS_SYSCONFDIR=`pwd`; export OVS_SYSCONFDIR
-trap 'kill `cat test-unixctl.py.pid`' 0
+ON_EXIT([kill `cat test-unixctl.py.pid`])
AT_CHECK([$PYTHON $srcdir/test-unixctl.py --pidfile --detach])
OVS_LOGDIR=`pwd`; export OVS_LOGDIR
OVS_DBDIR=`pwd`; export OVS_DBDIR
OVS_SYSCONFDIR=`pwd`; export OVS_SYSCONFDIR
-trap 'kill `cat test-unixctl.py.pid`' 0
+ON_EXIT([kill `cat test-unixctl.py.pid`])
AT_CHECK([$PYTHON $srcdir/test-unixctl.py --log-file=`pwd`/log --pidfile --detach])
AT_CHECK([APPCTL -t test-unixctl.py log message])
OVS_LOGDIR=`pwd`; export OVS_LOGDIR
OVS_DBDIR=`pwd`; export OVS_DBDIR
OVS_SYSCONFDIR=`pwd`; export OVS_SYSCONFDIR
-trap 'kill `cat test-unixctl.py.pid`' 0
+ON_EXIT([kill `cat test-unixctl.py.pid`])
AT_CAPTURE_FILE([log])
AT_CHECK([$PYTHON $srcdir/test-unixctl.py --log-file=`pwd`/log --pidfile --detach])