-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Configuration file, minimal handler support (#17)
* Documentation updates * implement configuration file inclusion and inline handler, * Fix emscripten; use minimal trap on all GCCs
- Loading branch information
Showing
8 changed files
with
122 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// This file merely ensures that the handler was defined inline by including the file that defines | ||
// it in a second translation unit. The program should fail to link if the handler was defined | ||
// out-of-line. | ||
#include "adobe/contract_checks.hpp"// NOLINT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
ADOBE_MINIMAL_INLINE_CONTRACT_VIOLATION_HANDLER() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#include "adobe/contract_checks.hpp" | ||
#include "portable_death_tests.hpp" | ||
#include <gtest/gtest.h> | ||
|
||
TEST(MinimalConfigurationDeathTests, FailedChecksDie) | ||
{ | ||
EXPECT_PORTABLE_DEATH(ADOBE_PRECONDITION(false), ""); | ||
EXPECT_PORTABLE_DEATH(ADOBE_POSTCONDITION(false), ""); | ||
EXPECT_PORTABLE_DEATH(ADOBE_INVARIANT(false), ""); | ||
} | ||
|
||
// ****** This should be the last test in the file. ********* | ||
// | ||
// For unknown reasons if the last test is a death test, under | ||
// emscripten, the test fails even if the executable aborts. | ||
#if defined(__EMSCRIPTEN__) | ||
TEST(MinimalConfiguration, EmscriptenDummy) {} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#include <gtest/gtest.h> | ||
#if !defined(GTEST_OS_WINDOWS) && !defined(__EMSCRIPTEN__) | ||
#include <csignal> | ||
#endif | ||
|
||
// gtest-style test macros that, given the use of handle_emscripten_death_tests in CMakeLists.txt, | ||
// portably detect various kinds of abnormal exits. | ||
// | ||
// EXPECT_ABORT: succeeds when the test case aborts. | ||
// EXPECT_PORTABLE_DEATH: succeeds when the test case exits abnormally. | ||
|
||
#if defined(__EMSCRIPTEN__) | ||
|
||
// GoogleTest doesn't support death tests under emscripten, so instead | ||
// we handle death by setting the test's WILL_FAIL property in CMake. | ||
// Therefore the test simply executes the code that aborts with no | ||
// wrapper. There's currently no facility for checking test output. | ||
|
||
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage) | ||
#define EXPECT_ABORT(code, expected_output_regex) code | ||
|
||
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage) | ||
#define EXPECT_PORTABLE_DEATH(code, expected_output_regex) code | ||
|
||
#elif defined(GTEST_OS_WINDOWS) | ||
// GoogleTest doesn't support checking for the abort signal on | ||
// Windows, so we use an auxilliary file, win32_abort_detection.cpp, | ||
// to ensure that an unusual string is printed, which we can check for | ||
// with the EXPECT_DEATH macro. | ||
|
||
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage) | ||
#define EXPECT_ABORT(code, expected_output_regex) \ | ||
EXPECT_DEATH(code, expected_output_regex ".*\n*##ABORTED##"); | ||
|
||
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage) | ||
#define EXPECT_PORTABLE_DEATH(code, expected_output_regex) EXPECT_DEATH(code, expected_output_regex) | ||
|
||
#else | ||
|
||
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage) | ||
#define EXPECT_ABORT(code, expected_output_regex) \ | ||
EXPECT_EXIT(code, testing::KilledBySignal(SIGABRT), expected_output_regex); | ||
|
||
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage) | ||
#define EXPECT_PORTABLE_DEATH(code, expected_output_regex) EXPECT_DEATH(code, expected_output_regex) | ||
|
||
#endif |