make test: introduce COREDUMP_COMPRESS option 82/19382/2
authorKlement Sekera <ksekera@cisco.com>
Mon, 6 May 2019 17:11:25 +0000 (19:11 +0200)
committerDave Barach <openvpp@barachs.net>
Wed, 8 May 2019 22:14:44 +0000 (22:14 +0000)
setting COREDUMP_COMPRESS=y (or =1) indicates that any core file
is to be compressed by the test framework unless DEBUG=core is set.

Change-Id: Ib0d6d30a7398dbeb6ab5e5dbb411bf5c641b5206
Signed-off-by: Klement Sekera <ksekera@cisco.com>
test/Makefile
test/run_tests.py

index 724b504..a578822 100644 (file)
@@ -285,6 +285,7 @@ help:
        @echo " COREDUMP_SIZE=<size> - pass <size> as unix { coredump-size <size> } argument to vpp"
        @echo "                        e.g. COREDUMP_SIZE=4g"
        @echo "                             COREDUMP_SIZE=unlimited"
+       @echo " COREDUMP_COMPRESS=1  - compress core files if not debugging them"
        @echo " EXTERN_TESTS=<path>  - path to out-of-tree test_<name>.py files containing test cases"
        @echo " EXTERN_PLUGINS=<path>- path to out-of-tree plugins to be loaded by vpp under test"
        @echo " EXTERN_COV_DIR=<path>- path to out-of-tree prefix, where source, object and .gcda files can be found for coverage report"
index 0c3b3f1..55b8123 100644 (file)
@@ -282,20 +282,23 @@ def handle_failed_suite(logger, last_test_temp_dir, vpp_pid):
 
 def check_and_handle_core(vpp_binary, tempdir, core_crash_test):
     if is_core_present(tempdir):
-        print('VPP core detected in %s. Last test running was %s' %
-              (tempdir, core_crash_test))
-        print(single_line_delim)
-        spawn_gdb(vpp_binary, get_core_path(tempdir))
-        print(single_line_delim)
+        if debug_core:
+            print('VPP core detected in %s. Last test running was %s' %
+                  (tempdir, core_crash_test))
+            print(single_line_delim)
+            spawn_gdb(vpp_binary, get_core_path(tempdir))
+            print(single_line_delim)
+        elif compress_core:
+            print("Compressing core-file in test directory `%s'" % tempdir)
+            os.system("gzip %s" % get_core_path(tempdir))
 
 
 def handle_cores(failed_testcases):
-    if debug_core:
-        for failed_testcase in failed_testcases:
-            tcs_with_core = failed_testcase.testclasess_with_core
-            if tcs_with_core:
-                for test, vpp_binary, tempdir in tcs_with_core.values():
-                    check_and_handle_core(vpp_binary, tempdir, test)
+    for failed_testcase in failed_testcases:
+        tcs_with_core = failed_testcase.testclasess_with_core
+        if tcs_with_core:
+            for test, vpp_binary, tempdir in tcs_with_core.values():
+                check_and_handle_core(vpp_binary, tempdir, test)
 
 
 def process_finished_testsuite(wrapped_testcase_suite,
@@ -726,6 +729,7 @@ if __name__ == '__main__':
     debug = os.getenv("DEBUG", "n").lower() in ["gdb", "gdbserver"]
 
     debug_core = os.getenv("DEBUG", "").lower() == "core"
+    compress_core = os.getenv("CORE_COMPRESS", "").lower() in ("y", "yes", "1")
 
     step = os.getenv("STEP", "n").lower() in ("y", "yes", "1")
 
@@ -813,8 +817,7 @@ if __name__ == '__main__':
                 handle_failed_suite(test_case_info.logger,
                                     test_case_info.tempdir,
                                     test_case_info.vpp_pid)
-                if debug_core and \
-                        test_case_info in result.core_crash_test_cases_info:
+                if test_case_info in result.core_crash_test_cases_info:
                     check_and_handle_core(test_case_info.vpp_bin_path,
                                           test_case_info.tempdir,
                                           test_case_info.core_crash_test)