Skip to content

Commit

Permalink
GHI #32 Fix KilledByAbort to work with both Windows Runtimes
Browse files Browse the repository at this point in the history
  • Loading branch information
doodspav committed Jul 13, 2024
1 parent 8daa971 commit 91d48fa
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 14 deletions.
12 changes: 0 additions & 12 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,7 @@ on:
- cron: "0 0 * * *"

jobs:
check-mingw-version:
runs-on: windows-latest

steps:
- name: Check MinGW Version
run: |
g++ -v
test-native:
if: false # remove me
strategy:
matrix:
# verbose labels make things easier to read in GitHub Actions
Expand Down Expand Up @@ -64,7 +55,6 @@ jobs:
architecture: ${{ matrix.architecture }}

test-qemu:
if: false # remove me
strategy:
matrix:
# architecture gets converted to triple
Expand Down Expand Up @@ -143,7 +133,6 @@ jobs:
skip_llvm: ${{ matrix.skip_llvm == true }}

publish-results:
if: false # remove me
runs-on: ubuntu-latest
needs:
- test-native
Expand Down Expand Up @@ -172,7 +161,6 @@ jobs:
files: test-results/**/*.xml

publish-coverage:
if: false # remove me
runs-on: ubuntu-latest
needs:
- test-native
Expand Down
3 changes: 2 additions & 1 deletion test/include/test/common/death.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ using KilledBySignalType = testing::KilledBySignal;

/// @brief
/// Produces a predicate that checks if an int exit code is what would be
/// expected from a process killed by SIGABRT (or OS equivalent).
/// expected from a process killed by abort() (which may ask the runtime to
/// kill it in a variety of ways).
///
/// @note
/// Predicate is callable with the signature bool()(int).
Expand Down
20 changes: 19 additions & 1 deletion test/src/common/death.cpp
Original file line number Diff line number Diff line change
@@ -1,16 +1,34 @@
#include <test/common/death.hpp>

#include <csignal>
#include <cstdlib>


namespace test
{


KilledBySignalType
testing::ExitedWithCode
KilledByAbort()
{
#if PATOMIC_GTEST_HAS_KILLED_BY_SIGNAL
return testing::KilledBySignal(SIGABRT);
#elif defined(GTEST_OS_WINDOWS)
#if defined(_UCRT)
const static unsigned int old_flags = _set_abort_behavior(0u, 0u);
if (old_flags & _CALL_REPORTFAULT)
{
constexpr int status_stack_buffer_overflow = -1073740791;
return testing::ExitedWithCode(status_stack_buffer_overflow);
}
else
{
#endif
constexpr int abort_exit_code = 3;
return testing::ExitedWithCode(abort_exit_code);
#if defined(_UCRT)
}
#endif
#else
return testing::ExitedWithCode(3);
#endif
Expand Down

0 comments on commit 91d48fa

Please sign in to comment.