Merge branch 'release/0.10' into feature/library_intermediate

This commit is contained in:
Sebastian Messmer 2019-01-24 00:43:21 -08:00
commit 1eba529a47
4 changed files with 63 additions and 6 deletions

View File

@ -1,13 +1,11 @@
image: image:
#- Visual Studio 2013
#- Visual Studio 2015
- Visual Studio 2017 - Visual Studio 2017
#- Visual Studio 2017 Preview #- Visual Studio 2017 Preview
platform: platform:
- x64 - x64
- x86 - x86
- Any CPU #- Any CPU
configuration: configuration:
- Debug - Debug
@ -33,7 +31,8 @@ install:
build_script: build_script:
- cmd: mkdir build - cmd: mkdir build
- cmd: cd build - cmd: cd build
- cmd: cmake .. -G "Ninja" -DBUILD_TESTING=on -DBOOST_ROOT="C:/Libraries/boost_1_65_1" -DDOKAN_PATH="C:/Program Files/Dokan/DokanLibrary-1.1.0" # note: The cmake+ninja workflow requires us to set build type in both cmake commands ('cmake' and 'cmake --build'), otherwise the cryfs.exe will depend on debug versions of the visual studio c++ runtime (i.e. msvcp140d.dll)
- cmd: cmake .. -G "Ninja" -DCMAKE_BUILD_TYPE=%CONFIGURATION% -DBUILD_TESTING=on -DBOOST_ROOT="C:/Libraries/boost_1_65_1" -DDOKAN_PATH="C:/Program Files/Dokan/DokanLibrary-1.1.0"
- cmd: cmake --build . --config %CONFIGURATION% - cmd: cmake --build . --config %CONFIGURATION%
- cmd: .\test\gitversion\gitversion-test.exe - cmd: .\test\gitversion\gitversion-test.exe
# cpp-utils-test disables ThreadDebuggingTest_ThreadName.*_thenIsCorrect because the appveyor image is too old to support the API needed for that # cpp-utils-test disables ThreadDebuggingTest_ThreadName.*_thenIsCorrect because the appveyor image is too old to support the API needed for that

View File

@ -1,6 +1,10 @@
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include <gmock/gmock.h> #include <gmock/gmock.h>
#ifdef NDEBUG
#define _REAL_NDEBUG
#endif
//Include the ASSERT macro for a debug build //Include the ASSERT macro for a debug build
#undef NDEBUG #undef NDEBUG
#include "cpp-utils/assert/assert.h" #include "cpp-utils/assert/assert.h"
@ -29,9 +33,18 @@ constexpr const char* EXPECTED = R"(Assertion \[2==5\] failed in .*assert_debug_
); );
} }
#if !(defined(_MSC_VER) && defined(_REAL_NDEBUG))
TEST(AssertTest_DebugBuild, AssertMessageContainsBacktrace) { TEST(AssertTest_DebugBuild, AssertMessageContainsBacktrace) {
EXPECT_DEATH( EXPECT_DEATH(
ASSERT(2==5, "my message"), ASSERT(2==5, "my message"),
"cpputils::" "cpputils::"
); );
} }
#else
TEST(AssertTest_DebugBuild, AssertMessageContainsBacktrace) {
EXPECT_DEATH(
ASSERT(2==5, "my message"),
"#1"
);
}
#endif

View File

@ -2,6 +2,10 @@
#include <gmock/gmock.h> #include <gmock/gmock.h>
#include <regex> #include <regex>
#ifdef NDEBUG
#define _REAL_NDEBUG
#endif
//Include the ASSERT macro for a release build //Include the ASSERT macro for a release build
#ifndef NDEBUG #ifndef NDEBUG
#define NDEBUG #define NDEBUG
@ -31,10 +35,11 @@ TEST(AssertTest_ReleaseBuild, AssertMessage) {
/*EXPECT_THAT(e.what(), MatchesRegex( /*EXPECT_THAT(e.what(), MatchesRegex(
R"(Assertion \[2==5\] failed in .*assert_release_test.cpp:27: my message)" R"(Assertion \[2==5\] failed in .*assert_release_test.cpp:27: my message)"
));*/ ));*/
EXPECT_TRUE(std::regex_search(e.what(), std::regex(R"(Assertion \[2==5\] failed in .*assert_release_test.cpp:26: my message)"))); EXPECT_TRUE(std::regex_search(e.what(), std::regex(R"(Assertion \[2==5\] failed in .*assert_release_test.cpp:30: my message)")));
} }
} }
#if !(defined(_MSC_VER) && defined(_REAL_NDEBUG))
TEST(AssertTest_ReleaseBuild, AssertMessageContainsBacktrace) { TEST(AssertTest_ReleaseBuild, AssertMessageContainsBacktrace) {
try { try {
ASSERT(2==5, "my message"); ASSERT(2==5, "my message");
@ -45,3 +50,15 @@ TEST(AssertTest_ReleaseBuild, AssertMessageContainsBacktrace) {
)); ));
} }
} }
#else
TEST(AssertTest_ReleaseBuild, AssertMessageContainsBacktrace) {
try {
ASSERT(2==5, "my message");
FAIL();
} catch (const cpputils::AssertFailed &e) {
EXPECT_THAT(e.what(), HasSubstr(
"#1"
));
}
}
#endif

View File

@ -19,6 +19,12 @@ namespace {
} }
} }
TEST(BacktraceTest, ContainsBacktrace) {
string backtrace = cpputils::backtrace();
EXPECT_THAT(backtrace, HasSubstr("#1"));
}
#if !(defined(_MSC_VER) && defined(NDEBUG))
TEST(BacktraceTest, ContainsExecutableName) { TEST(BacktraceTest, ContainsExecutableName) {
string backtrace = cpputils::backtrace(); string backtrace = cpputils::backtrace();
EXPECT_THAT(backtrace, HasSubstr("cpp-utils-test")); EXPECT_THAT(backtrace, HasSubstr("cpp-utils-test"));
@ -29,7 +35,7 @@ TEST(BacktraceTest, ContainsTopLevelLine) {
EXPECT_THAT(backtrace, HasSubstr("BacktraceTest")); EXPECT_THAT(backtrace, HasSubstr("BacktraceTest"));
EXPECT_THAT(backtrace, HasSubstr("ContainsTopLevelLine")); EXPECT_THAT(backtrace, HasSubstr("ContainsTopLevelLine"));
} }
#endif
namespace { namespace {
std::string call_process_exiting_with_nullptr_violation() { std::string call_process_exiting_with_nullptr_violation() {
@ -77,6 +83,7 @@ TEST(BacktraceTest, DoesntCrashOnCaughtException) {
} }
} }
#if !(defined(_MSC_VER) && defined(NDEBUG))
TEST(BacktraceTest, ShowBacktraceOnNullptrAccess) { TEST(BacktraceTest, ShowBacktraceOnNullptrAccess) {
auto output = call_process_exiting_with_nullptr_violation(); auto output = call_process_exiting_with_nullptr_violation();
EXPECT_THAT(output, HasSubstr("cpp-utils-test_exit_signal")); EXPECT_THAT(output, HasSubstr("cpp-utils-test_exit_signal"));
@ -96,6 +103,27 @@ TEST(BacktraceTest, ShowBacktraceOnSigIll) {
auto output = call_process_exiting_with_sigill(); auto output = call_process_exiting_with_sigill();
EXPECT_THAT(output, HasSubstr("cpp-utils-test_exit_signal")); EXPECT_THAT(output, HasSubstr("cpp-utils-test_exit_signal"));
} }
#else
TEST(BacktraceTest, ShowBacktraceOnNullptrAccess) {
auto output = call_process_exiting_with_nullptr_violation();
EXPECT_THAT(output, HasSubstr("#1"));
}
TEST(BacktraceTest, ShowBacktraceOnSigSegv) {
auto output = call_process_exiting_with_sigsegv();
EXPECT_THAT(output, HasSubstr("#1"));
}
TEST(BacktraceTest, ShowBacktraceOnUnhandledException) {
auto output = call_process_exiting_with_exception("my_exception_message");
EXPECT_THAT(output, HasSubstr("#1"));
}
TEST(BacktraceTest, ShowBacktraceOnSigIll) {
auto output = call_process_exiting_with_sigill();
EXPECT_THAT(output, HasSubstr("#1"));
}
#endif
#if !defined(_MSC_VER) #if !defined(_MSC_VER)
TEST(BacktraceTest, ShowBacktraceOnSigAbrt) { TEST(BacktraceTest, ShowBacktraceOnSigAbrt) {