Add support for "wait" option
authorClifford Wolf <clifford@clifford.at>
Mon, 6 Feb 2017 20:35:37 +0000 (21:35 +0100)
committerClifford Wolf <clifford@clifford.at>
Mon, 6 Feb 2017 20:35:37 +0000 (21:35 +0100)
sbysrc/sby_core.py

index fc630ba6f5835b33e44e26a870d3fecf0c0a5987..b82234333c74e1566183065129a037a7421a80aa 100644 (file)
@@ -66,7 +66,9 @@ class SbyTask:
         if self.exit_callback is not None:
             self.exit_callback(retcode)
 
-    def terminate(self):
+    def terminate(self, timeout=False):
+        if self.job.waitmode and not timeout:
+            return
         if self.running:
             self.job.log("%s: terminating process" % self.info)
             self.p.terminate()
@@ -241,7 +243,7 @@ class SbyJob:
                 if total_clock_time > int(self.options["timeout"]):
                     self.log("Reached TIMEOUT (%d seconds). Terminating all tasks." % int(self.options["timeout"]))
                     self.status = "TIMEOUT"
-                    self.terminate()
+                    self.terminate(timeout=True)
 
     def log(self, logmessage):
         print("%s %s" % (self.logprefix, logmessage))
@@ -332,9 +334,9 @@ class SbyJob:
             self.models[model_name] = self.make_model(model_name)
         return self.models[model_name]
 
-    def terminate(self):
+    def terminate(self, timeout=False):
         for task in self.tasks_running:
-            task.terminate()
+            task.terminate(timeout=timeout)
 
     def update_status(self, new_status):
         assert new_status in ["PASS", "FAIL", "UNKNOWN", "ERROR"]
@@ -365,6 +367,10 @@ class SbyJob:
         if "expect" in self.options:
             self.expect = self.options["expect"].upper().split(",")
 
+        self.waitmode = False
+        if "wait" in self.options:
+            self.waitmode = self.options["wait"] == "on"
+
         self.copy_src()
 
         if self.options["mode"] == "bmc":