From 5866fbb2b2574c1fc4b1e9e71523ad9147b6a471 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sun, 21 Jan 2018 17:38:01 +0200 Subject: [PATCH] Do not test boost::throws() under -fsanitize=undefined --- .travis.yml | 2 +- test/error_code_test.cpp | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index d9143d3..e079cfc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -264,7 +264,7 @@ install: script: - |- echo "using $TOOLSET : : $COMPILER ;" > ~/user-config.jam - - ./b2 -j3 libs/system/test toolset=$TOOLSET cxxstd=$CXXSTD ${UBSAN:+cxxflags=-fsanitize=undefined} ${UBSAN:+cxxflags=-fno-sanitize-recover=undefined} ${UBSAN:+linkflags=-fsanitize=undefined} + - ./b2 -j3 libs/system/test toolset=$TOOLSET cxxstd=$CXXSTD ${UBSAN:+cxxflags=-fsanitize=undefined} ${UBSAN:+cxxflags=-fno-sanitize-recover=undefined} ${UBSAN:+linkflags=-fsanitize=undefined} ${UBSAN:+define=UBSAN=1} notifications: email: diff --git a/test/error_code_test.cpp b/test/error_code_test.cpp index 7965541..1f96c59 100644 --- a/test/error_code_test.cpp +++ b/test/error_code_test.cpp @@ -22,6 +22,7 @@ #include #include #include +#include // Although using directives are not the best programming practice, testing // with a boost::system using directive increases use scenario coverage. @@ -246,8 +247,17 @@ int main( int, char ** ) BOOST_TEST( econd.message() != "" ); BOOST_TEST( econd.message().substr( 0, 13) != "Unknown error" ); +#if !defined(UBSAN) + + // the current implementation of boost::throws() relies on undefined behavior test_throws_usage(); +#else + + BOOST_PRAGMA_MESSAGE("Skipping test_throws_usage() due to UBSAN"); + +#endif + #ifdef BOOST_WINDOWS_API std::cout << "Windows tests...\n"; // these tests probe the Windows errc decoder