This is an automated email from the ASF dual-hosted git repository.

jdanek pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/qpid-dispatch.git


The following commit(s) were added to refs/heads/main by this push:
     new db30cb0  DISPATCH-2030 Add additional sanitizer checks and surface 
router output better in tests (#1101)
db30cb0 is described below

commit db30cb043bece740b5273b137057aa67b161ed50
Author: Jiri DanÄ›k <[email protected]>
AuthorDate: Thu Apr 8 18:12:40 2021 +0200

    DISPATCH-2030 Add additional sanitizer checks and surface router output 
better in tests (#1101)
---
 cmake/RuntimeChecks.cmake |  4 +++-
 run.py.in                 |  1 +
 tests/system_test.py      | 59 +++++++++++++++++++++++++----------------------
 3 files changed, 36 insertions(+), 28 deletions(-)

diff --git a/cmake/RuntimeChecks.cmake b/cmake/RuntimeChecks.cmake
index 703996d..9fb6fda 100644
--- a/cmake/RuntimeChecks.cmake
+++ b/cmake/RuntimeChecks.cmake
@@ -140,8 +140,10 @@ elseif(RUNTIME_CHECK STREQUAL "asan" OR RUNTIME_CHECK 
STREQUAL "hwasan")
   else (APPLE)
     set(DETECT_LEAKS true)
   endif()
-  set(RUNTIME_ASAN_ENV_OPTIONS "detect_leaks=${DETECT_LEAKS} 
suppressions=${CMAKE_SOURCE_DIR}/tests/asan.supp")
+  # 
https://github.com/openSUSE/systemd/blob/1270e56526cd5a3f485ae2aba975345c38860d37/docs/TESTING_WITH_SANITIZERS.md
+  set(RUNTIME_ASAN_ENV_OPTIONS "strict_string_checks=1 
detect_stack_use_after_return=1 check_initialization_order=1 
strict_init_order=1 detect_invalid_pointer_pairs=2 detect_leaks=${DETECT_LEAKS} 
suppressions=${CMAKE_SOURCE_DIR}/tests/asan.supp")
   set(RUNTIME_LSAN_ENV_OPTIONS 
"suppressions=${CMAKE_BINARY_DIR}/tests/lsan.supp")
+  set(RUNTIME_UBSAN_ENV_OPTIONS "print_stacktrace=1 print_summary=1")
 
 elseif(RUNTIME_CHECK STREQUAL "tsan")
   assert_has_sanitizers()
diff --git a/run.py.in b/run.py.in
index a10709f..67a8249 100755
--- a/run.py.in
+++ b/run.py.in
@@ -93,6 +93,7 @@ env_vars = {
     'TSAN_OPTIONS': "${RUNTIME_TSAN_ENV_OPTIONS}",
     'ASAN_OPTIONS': "${RUNTIME_ASAN_ENV_OPTIONS}",
     'LSAN_OPTIONS': "${RUNTIME_LSAN_ENV_OPTIONS}",
+    'UBSAN_OPTIONS': "${RUNTIME_UBSAN_ENV_OPTIONS}",
 }
 os.environ.update(env_vars)
 
diff --git a/tests/system_test.py b/tests/system_test.py
index 96b188c..ea81809 100755
--- a/tests/system_test.py
+++ b/tests/system_test.py
@@ -28,26 +28,27 @@ Features:
 - Sundry other tools.
 """
 
-from __future__ import unicode_literals
-from __future__ import division
 from __future__ import absolute_import
+from __future__ import division
 from __future__ import print_function
+from __future__ import unicode_literals
 
 import errno
-import os
+import sys
 import time
-import socket
-import random
-import subprocess
-import shutil
-import unittest
+
 import __main__
-import re
-import sys
 import functools
+import os
+import random
+import re
+import shutil
+import socket
+import subprocess
+from copy import copy
 from datetime import datetime
 from subprocess import PIPE, STDOUT
-from copy import copy
+
 try:
     import queue as Queue  # 3.x
 except ImportError:
@@ -537,28 +538,32 @@ class Qdrouterd(Process):
             # re-raise _after_ dumping all the state we can
             teardown_exc = exc
 
-        # check router's debug dump file for anything interesting (should be
-        # empty) and dump it to stderr for perusal by organic lifeforms
-        try:
-            if os.stat(self.dumpfile).st_size > 0:
-                with open(self.dumpfile) as f:
-                    sys.stderr.write("\nRouter %s debug dump file:\n>>>>\n" %
-                                     self.config.router_id)
-                    sys.stderr.write(f.read())
-                    sys.stderr.write("\n<<<<\n")
-                    sys.stderr.flush()
-        except OSError:
-            # failed to open file.  This can happen when an individual test
-            # spawns a temporary router (i.e. not created as part of the
-            # TestCase setUpClass method) that gets cleaned up by the test.
-            pass
+        def check_output_file(filename, description):
+            """check router's debug dump file for anything interesting (should 
be
+            empty) and dump it to stderr for perusal by organic lifeforms"""
+            try:
+                if os.stat(filename).st_size > 0:
+                    with open(filename) as f:
+                        sys.stderr.write("\nRouter %s %s:\n>>>>\n" %
+                                         (self.config.router_id, description))
+                        sys.stderr.write(f.read())
+                        sys.stderr.write("\n<<<<\n")
+                        sys.stderr.flush()
+            except OSError:
+                # failed to open file.  This can happen when an individual test
+                # spawns a temporary router (i.e. not created as part of the
+                # TestCase setUpClass method) that gets cleaned up by the test.
+                pass
+
+        check_output_file(filename=self.outfile + '.out', description="output 
file")
+        check_output_file(filename=self.dumpfile, description="debug dump 
file")
 
         if teardown_exc:
             # teardown failed - possible router crash?
             # dump extra stuff (command line, output, log)
 
             def tail_file(fname, line_count=50):
-                "Tail a file to a list"
+                """Tail a file to a list"""
                 out = []
                 with open(fname) as f:
                     line = f.readline()

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to