Re: [ovs-dev] [PATCH] tests: Kill the daemons at cleanup only if pidfile exists.

2017-12-26 Thread Ben Pfaff
On Fri, Dec 22, 2017 at 04:12:52PM +0100, Jakub Sitnicki wrote:
> Remembering the PIDs of started daemon processes and killing them during
> cleanup can interfere with other tests.
> 
> When the tests are running in parallel (i.e., -jX was passed in
> TESTSUITEFLAGS), PIDs of daemons that have terminated before the cleanup
> are subject to reuse by processes, or threads, spawned in another test.
> 
> This means that, while executing its 'cleanup' script, one test can
> accidentally send a SIGTERM to a process running as a part of another
> test and influence its outcome.
> 
> Retrieve the PID of the process we intend to kill at the last possible
> moment to narrow down the window of opportunity for interfering.
> 
> This approach has a downside that if the daemon's pidfile has
> disappeared but the process has not terminated, we will not clean it up
> at the end of the test.
> 
> Signed-off-by: Jakub Sitnicki 

Applied to master, thanks!
___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [PATCH] tests: Kill the daemons at cleanup only if pidfile exists.

2017-12-22 Thread Jakub Sitnicki
Remembering the PIDs of started daemon processes and killing them during
cleanup can interfere with other tests.

When the tests are running in parallel (i.e., -jX was passed in
TESTSUITEFLAGS), PIDs of daemons that have terminated before the cleanup
are subject to reuse by processes, or threads, spawned in another test.

This means that, while executing its 'cleanup' script, one test can
accidentally send a SIGTERM to a process running as a part of another
test and influence its outcome.

Retrieve the PID of the process we intend to kill at the last possible
moment to narrow down the window of opportunity for interfering.

This approach has a downside that if the daemon's pidfile has
disappeared but the process has not terminated, we will not clean it up
at the end of the test.

Signed-off-by: Jakub Sitnicki 
---
 tests/ofproto-macros.at | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tests/ofproto-macros.at b/tests/ofproto-macros.at
index 64cba44..ec5c892 100644
--- a/tests/ofproto-macros.at
+++ b/tests/ofproto-macros.at
@@ -55,8 +55,8 @@ m4_define([PARSE_LISTENING_PORT],
 
 start_daemon () {
 "$@" -vconsole:off --detach --no-chdir --pidfile --log-file
-pid=`cat "$OVS_RUNDIR"/$1.pid`
-on_exit "kill $pid"
+pidfile="$OVS_RUNDIR"/$1.pid
+on_exit "test -e \"$pidfile\" && kill \`cat \"$pidfile\"\`"
 }
 
 # sim_add SANDBOX
-- 
2.9.5

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev