OVS_LOGDIR=`pwd`; export OVS_LOGDIR
OVS_DBDIR=`pwd`; export OVS_DBDIR
OVS_SYSCONFDIR=`pwd`; export OVS_SYSCONFDIR
- ON_EXIT([kill `cat ovsdb-server.pid ovs-vswitchd.pid`])
dnl Create database.
touch .conf.db.~lock~
dnl Start ovsdb-server.
AT_CHECK([ovsdb-server --detach --no-chdir --pidfile --log-file --remote=punix:$OVS_RUNDIR/db.sock], [0], [], [stderr])
+ ON_EXIT_UNQUOTED([kill `cat ovsdb-server.pid`])
AT_CHECK([[sed < stderr '
/vlog|INFO|opened log file/d
/ovsdb_server|INFO|ovsdb-server (Open vSwitch)/d']])
dnl Start ovs-vswitchd.
AT_CHECK([ovs-vswitchd $1 --detach --no-chdir --pidfile --log-file -vvconn -vofproto_dpif], [0], [], [stderr])
AT_CAPTURE_FILE([ovs-vswitchd.log])
+ ON_EXIT_UNQUOTED([kill `cat ovs-vswitchd.pid`])
AT_CHECK([[sed < stderr '
/ovs_numa|INFO|Discovered /d
/vlog|INFO|opened log file/d
-[1-9]*)
shift
for i in $*; do
- taskkill //F //PID $i >/dev/null
+ if tasklist //fi "PID eq $i" | grep $i >/dev/null; then
+ tskill $i
+ fi
done
;;
[1-9][0-9]*)
for i in $*; do
- taskkill //F //PID $i >/dev/null
+ if tasklist //fi "PID eq $i" | grep $i >/dev/null; then
+ tskill $i
+ fi
done
;;
esac
[ovs-appctl -t $1 exit
OVS_WAIT_WHILE([test -e $1.pid])])
+m4_define([ON_EXIT__], [trap '. ./cleanup' 0; cat - cleanup << $2 > __cleanup
+$1
+EOF
+mv __cleanup cleanup
+])
+
dnl ON_EXIT([COMMANDS])
+dnl ON_EXIT_UNQUOTED([COMMANDS])
dnl
-dnl Adds the shell COMMANDS to a collection executed when the current test
+dnl Add 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.)
-dnl The commands will be added will be tht first one to excute.
-m4_define([ON_EXIT], [trap '. ./cleanup' 0; cat - cleanup << 'EOF' > __cleanup
-$1
-EOF
-mv __cleanup cleanup
-])
+dnl
+dnl The only difference between ON_EXIT and ON_EXIT_UNQUOTED is that only the
+dnl latter performs shell variable (e.g. $var) substitution, command
+dnl substitution (e.g. `command`), and backslash escaping (e.g. \\ becomes \)
+dnl in COMMANDS at the time that ON_EXIT_UNQUOTED is encountered. ON_EXIT,
+dnl in contrast, copies the literal COMMANDS and only executes shell expansion
+dnl at cleanup time.
+dnl
+dnl Cleanup commands are executed in the reverse order of execution of
+dnl these macros.
+m4_define([ON_EXIT], [ON_EXIT__([$1], ['EOF'])])
+m4_define([ON_EXIT_UNQUOTED], [ON_EXIT__([$1], [EOF])])