From 0e090f0103c622f43f023a854b96acee9717d70e Mon Sep 17 00:00:00 2001
From: Matt Witherspoon <32485495+spoonincode@users.noreply.github.com>
Date: Wed, 1 Nov 2023 13:42:16 -0400
Subject: [PATCH 1/4] globally --catch_system_errors=no

---
 CMakeLists.txt                                           | 4 ++++
 tests/CMakeLists.txt                                     | 2 +-
 unittests/CMakeLists.txt                                 | 4 ++--
 unittests/wasm-spec-tests/generated-tests/CMakeLists.txt | 2 +-
 4 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index ff2708fadb..08441b0116 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -175,6 +175,10 @@ endif()
 # do not attempt to use an external OpenSSL in any manner
 set(CMAKE_DISABLE_FIND_PACKAGE_OpenSSL On)
 
+# many tests require handling of signals themselves and even when they don't we'd like for them to generate a core dump, this
+# is effectively --catch_system_errors=no broadly across all tests
+add_compile_definitions(BOOST_TEST_DEFAULTS_TO_CORE_DUMP)
+
 add_subdirectory( libraries )
 add_subdirectory( plugins )
 add_subdirectory( programs )
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index fb26b0c350..182c68614f 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -81,7 +81,7 @@ else()
 endif()
 
 #To run plugin_test with all log from blockchain displayed, put --verbose after --, i.e. plugin_test -- --verbose
-add_test(NAME plugin_test COMMAND plugin_test --report_level=detailed --color_output --catch_system_errors=no)
+add_test(NAME plugin_test COMMAND plugin_test --report_level=detailed --color_output)
 
 add_test(NAME nodeos_sanity_test COMMAND tests/nodeos_run_test.py -v --sanity-test ${UNSHARE} WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
 set_property(TEST nodeos_sanity_test PROPERTY LABELS nonparallelizable_tests)
diff --git a/unittests/CMakeLists.txt b/unittests/CMakeLists.txt
index f85ff7cdeb..c1e3eed7a2 100644
--- a/unittests/CMakeLists.txt
+++ b/unittests/CMakeLists.txt
@@ -85,7 +85,7 @@ target_include_directories( unit_test PUBLIC
                             ${CMAKE_SOURCE_DIR}/plugins/chain_interface/include)
 
 ### MARK TEST SUITES FOR EXECUTION ###
-add_test(NAME protocol_feature_digest_unit_test COMMAND unit_test --run_test=protocol_feature_digest_tests --report_level=detailed --color_output --catch_system_errors=no)
+add_test(NAME protocol_feature_digest_unit_test COMMAND unit_test --run_test=protocol_feature_digest_tests --report_level=detailed --color_output)
 set(ctest_tests "protocol_feature_digest_tests")
 foreach(TEST_SUITE ${UNIT_TESTS}) # create an independent target for each test suite
   execute_process(COMMAND sh -c "grep -E 'BOOST_AUTO_TEST_SUITE\\s*[(]' '${TEST_SUITE}' | grep -vE '//.*BOOST_AUTO_TEST_SUITE\\s*[(]' | cut -d ')' -f 1 | cut -d '(' -f 2" OUTPUT_VARIABLE SUITE_NAME OUTPUT_STRIP_TRAILING_WHITESPACE) # get the test suite name from the *.cpp file
@@ -93,7 +93,7 @@ foreach(TEST_SUITE ${UNIT_TESTS}) # create an independent target for each test s
     execute_process(COMMAND sh -c "echo ${SUITE_NAME} | sed -e 's/s$//' | sed -e 's/_test$//'" OUTPUT_VARIABLE TRIMMED_SUITE_NAME OUTPUT_STRIP_TRAILING_WHITESPACE) # trim "_test" or "_tests" from the end of ${SUITE_NAME}
     # to run unit_test with all log from blockchain displayed, put "--verbose" after "--", i.e. "unit_test -- --verbose"
     foreach(RUNTIME ${EOSIO_WASM_RUNTIMES})
-      add_test(NAME ${TRIMMED_SUITE_NAME}_unit_test_${RUNTIME} COMMAND unit_test --run_test=${SUITE_NAME} --report_level=detailed --color_output --catch_system_errors=no -- --${RUNTIME})
+      add_test(NAME ${TRIMMED_SUITE_NAME}_unit_test_${RUNTIME} COMMAND unit_test --run_test=${SUITE_NAME} --report_level=detailed --color_output -- --${RUNTIME})
       # build list of tests to run during coverage testing
       if(ctest_tests)
          string(APPEND ctest_tests "|")
diff --git a/unittests/wasm-spec-tests/generated-tests/CMakeLists.txt b/unittests/wasm-spec-tests/generated-tests/CMakeLists.txt
index 87225c902c..25169702fb 100644
--- a/unittests/wasm-spec-tests/generated-tests/CMakeLists.txt
+++ b/unittests/wasm-spec-tests/generated-tests/CMakeLists.txt
@@ -24,7 +24,7 @@ foreach(TEST_SUITE ${WASM_TESTS}) # create an independent target for each test s
       foreach(RUNTIME ${EOSIO_WASM_RUNTIMES})
           get_test_property(${SN}_unit_test_${RUNTIME} LABELS TEST_LABEL)
           if ("NOTFOUND" STREQUAL "${TEST_LABEL}") # prevent duplicates
-            add_test(NAME ${SN}_unit_test_${RUNTIME} COMMAND wasm_spec_test --run_test=${SN} --report_level=detailed --color_output --catch_system_errors=no -- --${RUNTIME})
+            add_test(NAME ${SN}_unit_test_${RUNTIME} COMMAND wasm_spec_test --run_test=${SN} --report_level=detailed --color_output -- --${RUNTIME})
             set_property(TEST ${SN}_unit_test_${RUNTIME} PROPERTY LABELS wasm_spec_tests)
             # build list of tests to run during coverage testing
             if(ctest_tests)

From 6286f84bd5bc2cf56e0a507a72e1fc0c315bdcbb Mon Sep 17 00:00:00 2001
From: Matt Witherspoon <32485495+spoonincode@users.noreply.github.com>
Date: Thu, 26 Oct 2023 10:02:20 -0400
Subject: [PATCH 2/4] upgrade to actions/checkout@v4

---
 .github/workflows/build.yaml                     | 12 ++++++------
 .github/workflows/build_base.yaml                |  2 +-
 .github/workflows/ph_backward_compatibility.yaml |  2 +-
 3 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml
index 4dccdddd5b..45ab9e057b 100644
--- a/.github/workflows/build.yaml
+++ b/.github/workflows/build.yaml
@@ -89,7 +89,7 @@ jobs:
     runs-on: ubuntu-latest
     container: ${{fromJSON(needs.platform-cache.outputs.platforms)[matrix.platform].image}}
     steps:
-      - uses: actions/checkout@v3
+      - uses: actions/checkout@v4
         with:
           submodules: recursive
       - name: Download builddir
@@ -140,7 +140,7 @@ jobs:
       image: ${{fromJSON(needs.platform-cache.outputs.platforms)[matrix.cfg.base].image}}
       options: --security-opt seccomp=unconfined
     steps:
-      - uses: actions/checkout@v3
+      - uses: actions/checkout@v4
       - name: Download builddir
         uses: actions/download-artifact@v3
         with:
@@ -168,7 +168,7 @@ jobs:
           - cfg: {name: 'ubuntu22repro', base: 'ubuntu22', builddir: 'reproducible'}
     runs-on: ["self-hosted", "enf-x86-midtier"]
     steps:
-      - uses: actions/checkout@v3
+      - uses: actions/checkout@v4
       - name: Download builddir
         uses: actions/download-artifact@v3
         with:
@@ -201,7 +201,7 @@ jobs:
           - cfg: {name: 'ubuntu22repro', base: 'ubuntu22', builddir: 'reproducible'}
     runs-on: ["self-hosted", "enf-x86-lowtier"]
     steps:
-      - uses: actions/checkout@v3
+      - uses: actions/checkout@v4
       - name: Download builddir
         uses: actions/download-artifact@v3
         with:
@@ -243,7 +243,7 @@ jobs:
       # LEAP
       - if: ${{ matrix.test != 'deb-install' }}
         name: Clone leap
-        uses: actions/checkout@v3
+        uses: actions/checkout@v4
         with:
           submodules: recursive
       - if: ${{ matrix.test != 'deb-install' }}
@@ -296,7 +296,7 @@ jobs:
 
       # Reference Contracts
       - name: checkout eos-system-contracts
-        uses: actions/checkout@v3
+        uses: actions/checkout@v4
         with:
           repository: eosnetworkfoundation/eos-system-contracts
           path: eos-system-contracts
diff --git a/.github/workflows/build_base.yaml b/.github/workflows/build_base.yaml
index 5e6639f968..ec0b70f95b 100644
--- a/.github/workflows/build_base.yaml
+++ b/.github/workflows/build_base.yaml
@@ -30,7 +30,7 @@ jobs:
     runs-on: ["self-hosted", "enf-x86-beefy"]
     container: ${{fromJSON(inputs.platforms)[matrix.platform].image}}
     steps:
-        - uses: actions/checkout@v3
+        - uses: actions/checkout@v4
           with:
             submodules: recursive
         - name: Build
diff --git a/.github/workflows/ph_backward_compatibility.yaml b/.github/workflows/ph_backward_compatibility.yaml
index 4633108821..26564792f2 100644
--- a/.github/workflows/ph_backward_compatibility.yaml
+++ b/.github/workflows/ph_backward_compatibility.yaml
@@ -46,7 +46,7 @@ jobs:
       image: ${{fromJSON(needs.platform-cache.outputs.platforms)[matrix.platform].image}}
       options: --security-opt seccomp=unconfined
     steps:
-      - uses: actions/checkout@v3
+      - uses: actions/checkout@v4
       - name: Download builddir
         uses: actions/download-artifact@v3
         with:

From f2ba2481a7345de7cf564ac56245fe69a4b9ecdb Mon Sep 17 00:00:00 2001
From: Matt Witherspoon <32485495+spoonincode@users.noreply.github.com>
Date: Thu, 26 Oct 2023 10:03:36 -0400
Subject: [PATCH 3/4] upgrade parallel-ctest-containers action to node20

---
 .github/actions/parallel-ctest-containers/action.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.github/actions/parallel-ctest-containers/action.yml b/.github/actions/parallel-ctest-containers/action.yml
index c5e58db6eb..c4a8573e11 100644
--- a/.github/actions/parallel-ctest-containers/action.yml
+++ b/.github/actions/parallel-ctest-containers/action.yml
@@ -12,5 +12,5 @@ inputs:
   test-timeout:
     required: true
 runs:
-  using: 'node16'
+  using: 'node20'
   main: 'dist/index.mjs'

From 492c7bd22b0ee1414a027c3ace290ac8d57b7b7c Mon Sep 17 00:00:00 2001
From: Matt Witherspoon <32485495+spoonincode@users.noreply.github.com>
Date: Thu, 26 Oct 2023 10:12:06 -0400
Subject: [PATCH 4/4] upload core files from failed tests

---
 .github/workflows/build.yaml | 23 ++++++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)

diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml
index 45ab9e057b..8c42f6dc30 100644
--- a/.github/workflows/build.yaml
+++ b/.github/workflows/build.yaml
@@ -138,7 +138,7 @@ jobs:
     runs-on: ["self-hosted", "enf-x86-hightier"]
     container:
       image: ${{fromJSON(needs.platform-cache.outputs.platforms)[matrix.cfg.base].image}}
-      options: --security-opt seccomp=unconfined
+      options: --security-opt seccomp=unconfined --mount type=bind,source=/var/lib/systemd/coredump,target=/cores
     steps:
       - uses: actions/checkout@v4
       - name: Download builddir
@@ -152,6 +152,13 @@ jobs:
           zstdcat build.tar.zst | tar x
           cd build
           ctest --output-on-failure -j $(nproc) -LE "(nonparallelizable_tests|long_running_tests)" --timeout 420
+      - name: Upload core files from failed tests
+        uses: actions/upload-artifact@v3
+        if: failure()
+        with:
+          name: ${{matrix.cfg.name}}-tests-logs
+          if-no-files-found: ignore
+          path: /cores
       - name: Check CPU Features
         run: awk 'BEGIN {err = 1} /bmi2/ && /adx/ {err = 0} END {exit err}' /proc/cpuinfo
 
@@ -181,12 +188,17 @@ jobs:
           log-tarball-prefix: ${{matrix.cfg.name}}
           tests-label: nonparallelizable_tests
           test-timeout: 420
+      - name: Export core dumps
+        run: docker run --mount type=bind,source=/var/lib/systemd/coredump,target=/cores alpine sh -c 'tar -C /cores/ -c .' | tar x
+        if: failure()
       - name: Upload logs from failed tests
         uses: actions/upload-artifact@v3
         if: failure()
         with:
           name: ${{matrix.cfg.name}}-np-logs
-          path: '*-logs.tar.gz'
+          path: |
+            *-logs.tar.gz
+            core*.zst
 
   lr-tests:
     name: LR Tests (${{matrix.cfg.name}})
@@ -214,12 +226,17 @@ jobs:
           log-tarball-prefix: ${{matrix.cfg.name}}
           tests-label: long_running_tests
           test-timeout: 1800
+      - name: Export core dumps
+        run: docker run --mount type=bind,source=/var/lib/systemd/coredump,target=/cores alpine sh -c 'tar -C /cores/ -c .' | tar x
+        if: failure()
       - name: Upload logs from failed tests
         uses: actions/upload-artifact@v3
         if: failure()
         with:
           name: ${{matrix.cfg.name}}-lr-logs
-          path: '*-logs.tar.gz'
+          path: |
+            *-logs.tar.gz
+            core*.zst
 
   libtester-tests:
     name: libtester tests