From: Waldemar Kozaczuk <jwkozac...@gmail.com>
Committer: Nadav Har'El <n...@scylladb.com>
Branch: master

Fixes failing tracing_smoke_test.

Changed Guest and SupervisedProcess classes in testing.py to allow for conditional detection of 'Failed to load object' error which needs to be handled differently in test_tracing.py.

Closes #788.

Signed-off-by: Waldemar Kozaczuk <jwkozac...@gmail.com>
Message-Id: <1471580939-19147-1-git-send-email-jwkozac...@gmail.com>
Signed-off-by: Nadav Har'El <n...@scylladb.com>

---
diff --git a/scripts/tests/test_tracing.py b/scripts/tests/test_tracing.py
--- a/scripts/tests/test_tracing.py
+++ b/scripts/tests/test_tracing.py
@@ -6,7 +6,7 @@
 def tracing_smoke_test():
     path = '/this/path/does/not/exist'
guest = Guest(['--trace=vfs_*,net_packet*,sched_wait*', '--trace-backtrace', '-e', path],
-        hold_with_poweroff=True, show_output_on_error=False)
+ hold_with_poweroff=True, show_output_on_error=False, scan_for_failed_to_load_object_error=False)
     try:
wait_for_line(guest, 'Failed to load object: %s. Powering off.' % path)

diff --git a/scripts/tests/testing.py b/scripts/tests/testing.py
--- a/scripts/tests/testing.py
+++ b/scripts/tests/testing.py
@@ -42,7 +42,7 @@ def __init__(self, f):
     def run(self):
         self.f()

-def scan_errors(s):
+def scan_errors(s,scan_for_failed_to_load_object_error=True):
     if not s:
         return False
     patterns = [
@@ -59,29 +59,33 @@ def scan_errors(s):
         # A test should indicate it's status by a return value only:
         #   0              - on success
         #   non-zero value - on failure
-        # The below messages are printed by the OSv and are promissed to be
+        # The below messages are printed by the OSv and are promised to be
         # supported in the future.
         "Assertion failed",
         "Aborted",
-       "Error",
-       "\[BUG\]",
-       "Failed looking up symbol",
-       "Failure",
+           "Error",
+           "\[BUG\]",
+           "Failed looking up symbol",
+           "Failure",
         "program exited with status",
         r"program tests/(.*?) returned",
         "Exception was caught while running",
         "at org.junit.runner.JUnitCore.main",
         "ContextFailedException",
-       "\[backtrace\]",
-        "Failed to load object",
+        "AppThreadTerminatedWithUncaughtException",
+           "\[backtrace\]"
     ]
+
+    if scan_for_failed_to_load_object_error:
+        patterns = patterns + ["Failed to load object"]
+
     for pattern in patterns:
         if re.findall(pattern, s):
             return True
     return False

 class SupervisedProcess:
-    def __init__(self, args, show_output=False, show_output_on_error=True):
+ def __init__(self, args, show_output=False, show_output_on_error=True, scan_for_failed_to_load_object_error=True):
         self.process = subprocess.Popen(args, stdout=subprocess.PIPE)
         self.cv = threading.Condition()
         self.lines = []
@@ -92,12 +96,13 @@ def __init__(self, args, show_output=False, show_output_on_error=True):

self.output_collector_thread = threading.Thread(target=self._output_collector)
         self.output_collector_thread.start()
+ self.scan_for_failed_to_load_object_error = scan_for_failed_to_load_object_error

     def _output_collector(self):
         def append_line(line):
             self.cv.acquire()

-            if not self.has_errors and scan_errors(line):
+ if not self.has_errors and scan_errors(line,self.scan_for_failed_to_load_object_error):
                 self.has_errors = True
                 if self.show_output_on_error and not self.show_output:
                     sys.stdout.write(self.output)
@@ -176,7 +181,9 @@ def run_command_in_guest(command, **kwargs):
     return Guest(["-s", "-e", "--power-off-on-abort " + command], **kwargs)

 class Guest(SupervisedProcess):
- def __init__(self, args, forward=[], hold_with_poweroff=False, show_output_on_error=True): + def __init__(self, args, forward=[], hold_with_poweroff=False, show_output_on_error=True,
+                 scan_for_failed_to_load_object_error=True):
+
         run_script = os.path.join(osv_base, "scripts/run.py")

         if hold_with_poweroff:
@@ -192,7 +199,8 @@ def __init__(self, args, forward=[], hold_with_poweroff=False, show_output_on_er

         SupervisedProcess.__init__(self, [run_script] + args,
             show_output=_verbose_output,
-            show_output_on_error=show_output_on_error)
+            show_output_on_error=show_output_on_error,
+ scan_for_failed_to_load_object_error=scan_for_failed_to_load_object_error)

     def kill(self):
         s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)

--
You received this message because you are subscribed to the Google Groups "OSv 
Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to osv-dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to