make test: print a warning in case a core_pattern contains a filter program 37/11437/4
authorAndrew Yourtchenko <ayourtch@gmail.com>
Wed, 28 Mar 2018 13:32:10 +0000 (15:32 +0200)
committerChris Luke <chris_luke@comcast.com>
Sat, 31 Mar 2018 12:49:40 +0000 (12:49 +0000)
The default config on Ubuntu 16.04.4 desktop results in truncated cores
when running make test which coredumps. Uninstalling the filter program
(apport) makes the corefiles normal size. Print a warning about that fact,
so the others potentially affected didn't have to wonder.

Change-Id: Iba4b0a2765a25100d6e24fd7f4de0e0339efd835
Signed-off-by: Andrew Yourtchenko <ayourtch@gmail.com>
test/hook.py
test/run_tests.py
test/util.py

index f4bafa1..0e94dcd 100644 (file)
@@ -5,6 +5,7 @@ import traceback
 from log import RED, single_line_delim, double_line_delim
 from debug import spawn_gdb
 from subprocess import check_output, CalledProcessError
+from util import check_core_path
 
 
 class Hook(object):
@@ -70,6 +71,7 @@ class PollHook(Hook):
         else:
             self.logger.error("Core file present, debug with: gdb %s %s" %
                               (self.testcase.vpp_bin, core_path))
+            check_core_path(self.logger, core_path)
             self.logger.error("Running `file %s':" % core_path)
             try:
                 info = check_output(["file", core_path])
index 158494a..3476ef0 100644 (file)
@@ -13,6 +13,7 @@ from debug import spawn_gdb
 from log import global_logger
 from discover_tests import discover_tests
 from subprocess import check_output, CalledProcessError
+from util import check_core_path
 
 # timeout which controls how long the child has to finish after seeing
 # a core dump in test temporary directory. If this is exceeded, parent assumes
@@ -136,6 +137,7 @@ def run_forked(suite):
                 if os.path.isfile(core_path):
                     global_logger.error("Core-file exists in test temporary "
                                         "directory: %s!" % core_path)
+                    check_core_path(global_logger, core_path)
                     global_logger.debug("Running `file %s':" % core_path)
                     try:
                         info = check_output(["file", core_path])
index 7d973bd..65e25f7 100644 (file)
@@ -70,6 +70,21 @@ def ip6_normalize(ip6):
                             socket.inet_pton(socket.AF_INET6, ip6))
 
 
+def check_core_path(logger, core_path):
+    with open("/proc/sys/kernel/core_pattern", "r") as f:
+        corefmt = f.read()
+        if corefmt.startswith("|"):
+            logger.error(
+                "WARNING: redirecting the core dump through a"
+                " filter may result in truncated dumps.")
+            logger.error(
+                "   You may want to check the filter settings"
+                " or uninstall it and edit the"
+                " /proc/sys/kernel/core_pattern accordingly.")
+            logger.error(
+                "   current core pattern is: %s" % corefmt)
+
+
 class NumericConstant(object):
     __metaclass__ = ABCMeta