Browse Source

Moved the CHUTNEY_CONTROLLING_PID logic

If the user sets the CHUTNEY_CONTROLLING_PID, then the Python
code should respect that. The logic for choosing this value has
been moved to the 'test-network.sh' script.
Steven Engler 2 years ago
parent
commit
25f60b2e07
2 changed files with 11 additions and 7 deletions
  1. 1 4
      lib/chutney/TorNet.py
  2. 10 3
      tools/test-network.sh

+ 1 - 4
lib/chutney/TorNet.py

@@ -1210,10 +1210,7 @@ class TorEnviron(chutney.Templating.Environ):
         ocp_line = ('__OwningControllerProcess %d' % (cpid))
         # if we want to leave the network running, or controlling_pid is 1
         # (or invalid)
-        if (getenv_int('CHUTNEY_START_TIME', 0) < 0 or
-            getenv_int('CHUTNEY_BOOTSTRAP_TIME', 0) < 0 or
-            getenv_int('CHUTNEY_STOP_TIME', 0) < 0 or
-            cpid <= 1):
+        if cpid <= 1:
             return '#' + ocp_line
         else:
             return ocp_line

+ 10 - 3
tools/test-network.sh

@@ -12,9 +12,6 @@ export CHUTNEY_ROUNDS=${CHUTNEY_ROUNDS:-1}
 export CHUTNEY_WARNINGS_IGNORE_EXPECTED=${CHUTNEY_WARNINGS_IGNORE_EXPECTED:-true}
 export CHUTNEY_WARNINGS_SUMMARY=${CHUTNEY_WARNINGS_SUMMARY:-true}
 
-# default to exiting when this script exits
-export CHUTNEY_CONTROLLING_PID=${CHUTNEY_CONTROLLING_PID:-$$}
-
 # default to allowing zero failures
 export CHUTNEY_ALLOW_FAILURES=${CHUTNEY_ALLOW_FAILURES:-0}
 
@@ -192,6 +189,16 @@ do
     shift
 done
 
+if [ -z "$CHUTNEY_CONTROLLING_PID" ]; then
+    # if not set, default to exiting when this script exits
+    CHUTNEY_CONTROLLING_PID=$$
+    if { [ "$CHUTNEY_START_TIME" ] && [ "$CHUTNEY_START_TIME" -lt 0 ]]; } ||
+       { [ "$CHUTNEY_BOOTSTRAP_TIME" ] && [ "$CHUTNEY_BOOTSTRAP_TIME" -lt 0 ]; } ||
+       { [ "$CHUTNEY_STOP_TIME" ] && [ "$CHUTNEY_STOP_TIME" -lt 0 ];} ; then
+        CHUTNEY_CONTROLLING_PID=0
+    fi
+fi
+
 # If the DNS server doesn't work, tor exits may reject all exit traffic, and
 # chutney may fail
 if [ "$CHUTNEY_WARNINGS_ONLY" != true ]; then