[Unit tests] Handle segmentation faults 34/26234/1
authorPiotr Bartosiewicz <p.bartosiewi@partner.samsung.com>
Tue, 19 Aug 2014 12:34:01 +0000 (14:34 +0200)
committerPiotr Bartosiewicz <p.bartosiewi@partner.samsung.com>
Tue, 19 Aug 2014 12:34:01 +0000 (14:34 +0200)
[Bug/Feature]   No message was printed when unit tests was terminated by
                some signal.
[Cause]         N/A
[Solution]      N/A
[Verification]  Build, install, run good and crashing tests.

Change-Id: Ib8a8abae09e3dfa2d2badd8c78f87440eb834c4c

tests/scripts/sc_launch_test.py
tests/scripts/sc_test_parser.py

index 81d6d62..6bdbcfe 100755 (executable)
@@ -42,7 +42,9 @@ def launchTest(cmd=[], externalToolCmd=[], parsing=True):
 
     if parsing:
         parser = Parser()
-        p = subprocess.Popen(" ".join(externalToolCmd + cmd + _defLaunchArgs),
+        command = " ".join(externalToolCmd + cmd + _defLaunchArgs)
+        log.info("Invoking `" + command + "`")
+        p = subprocess.Popen(command,
                          shell=True,
                          stdout=subprocess.PIPE,
                          stderr=subprocess.STDOUT)
@@ -51,10 +53,14 @@ def launchTest(cmd=[], externalToolCmd=[], parsing=True):
             domResult = minidom.parseString(testResult)
             log.XMLSummary(domResult)
             log.failedTestSummary(cmd[0])
+        if p.returncode < 0:
+            log.terminatedBySignal(" ".join(cmd), -p.returncode)
     else:
         # Launching process without coloring does not require report in XML form
         # Avoid providing --report_format=XML, redirect std* by default to system's std*
-        p = subprocess.Popen(" ".join(externalToolCmd + cmd + _defLaunchArgs[1:]),
+        command = " ".join(externalToolCmd + cmd + _defLaunchArgs[1:])
+        log.info("Invoking `" + command + "`")
+        p = subprocess.Popen(command,
                              shell=True)
         p.wait()
 
index 8d4b289..5299814 100644 (file)
@@ -82,6 +82,14 @@ class Logger(object):
         for test in self.__failedTests:
             self.error(self.__indentChar + commandPrefix + test)
 
+    def terminatedBySignal(self, bin, signum):
+        self.error("\n=========== FAILED ===========\n")
+        signame = {2:"SIGINT", 9:"SIGKILL", 11:"SIGSEGV", 15:"SIGTERM"}
+        siginfo = signame.get(signum, 'signal ' + str(signum))
+        self.error('Terminated by ' + siginfo)
+        if signum == 11: # SIGSEGV
+            self.error("\nUse following command to launch debugger:")
+            self.error(self.__indentChar + "sc_launch_test.py --gdb " + bin)
 
 
 class Parser(object):