Browse Source

Fixed a bug with scripts failing

If a script fails, TFBReaper should fail out as well
so that the suite doesn't hang forever waiting on a
train that ain't coming.
msmith-techempower 8 years ago
parent
commit
f7976fbf60
2 changed files with 15 additions and 6 deletions
  1. 11 5
      toolset/benchmark/benchmarker.py
  2. 4 1
      toolset/setup/linux/TFBReaper.c

+ 11 - 5
toolset/benchmark/benchmarker.py

@@ -613,13 +613,11 @@ class Benchmarker:
         out.flush()
         out.flush()
         self.__stop_test(out, process)
         self.__stop_test(out, process)
         out.flush()
         out.flush()
-        time.sleep(15)
 
 
         if self.__is_port_bound(test.port):
         if self.__is_port_bound(test.port):
           # This can happen sometimes - let's try again
           # This can happen sometimes - let's try again
           self.__stop_test(out, process)
           self.__stop_test(out, process)
           out.flush()
           out.flush()
-          time.sleep(15)
           if self.__is_port_bound(test.port):
           if self.__is_port_bound(test.port):
             # We gave it our all
             # We gave it our all
             self.__write_intermediate_results(test.name, "port " + str(test.port) + " was not released by stop")
             self.__write_intermediate_results(test.name, "port " + str(test.port) + " was not released by stop")
@@ -629,7 +627,6 @@ class Benchmarker:
 
 
         out.write(header("Stopped %s" % test.name))
         out.write(header("Stopped %s" % test.name))
         out.flush()
         out.flush()
-        time.sleep(5)
 
 
         ##########################################################
         ##########################################################
         # Remove contents of  /tmp folder
         # Remove contents of  /tmp folder
@@ -691,11 +688,20 @@ class Benchmarker:
   # Stops all running tests
   # Stops all running tests
   ############################################################
   ############################################################
   def __stop_test(self, out, process):
   def __stop_test(self, out, process):
-    if process is not None:
+    if process is not None and process.poll() is None:
       pids = self.__find_child_processes(process.pid)
       pids = self.__find_child_processes(process.pid)
       if pids is not None:
       if pids is not None:
-        kill = ['kill','-9'] + pids
+        kill = ['kill'] + pids
         subprocess.call(kill, stderr=out, stdout=out)
         subprocess.call(kill, stderr=out, stdout=out)
+      # Normal SIGTERM exits can take some time
+      time.sleep(5)
+      # Okay, if there are any more PIDs, kill them harder
+      pids = self.__find_child_processes(process.pid)
+      if pids is not None:
+        kill = ['kill', '-9'] + pids
+        subprocess.call(kill, stderr=out, stdout=out)
+      # Again, sometimes defunct procs need a moment
+      time.sleep(5)
       process.terminate()
       process.terminate()
   ############################################################
   ############################################################
   # End __stop_test
   # End __stop_test

+ 4 - 1
toolset/setup/linux/TFBReaper.c

@@ -47,8 +47,11 @@ int main(int argc, char *argv[])
 
 
   // We need to wait forever; the suite will clean this 
   // We need to wait forever; the suite will clean this 
   // process up later.
   // process up later.
-  for(;;){}
+  if (ret == 0) {
+    for(;;) { }
+  }
 
 
+  // If the scripts failed, we should return that code.
   return ret;
   return ret;
 }
 }