From 5f9b5d70d11821f92b6ce7b06aa893b90a559d10 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Fri, 19 Jan 2018 19:51:03 +0200 Subject: [PATCH 1/5] Add clang-3.3, 3.4 to Travis --- .travis.yml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/.travis.yml b/.travis.yml index df47660..0978080 100644 --- a/.travis.yml +++ b/.travis.yml @@ -112,6 +112,22 @@ matrix: compiler: clang++ env: TOOLSET=clang COMPILER=clang++ CXXSTD=03,11 + - os: linux + compiler: /usr/bin/clang++ + env: TOOLSET=clang COMPILER=/usr/bin/clang++ CXXSTD=03,11 + addons: + apt: + packages: + - clang-3.3 + + - os: linux + compiler: /usr/bin/clang++ + env: TOOLSET=clang COMPILER=/usr/bin/clang++ CXXSTD=03,11 + addons: + apt: + packages: + - clang-3.4 + - os: linux compiler: clang++-3.5 env: TOOLSET=clang COMPILER=clang++-3.5 CXXSTD=03,11,14,1z From f5f3652f303ff8388edc26c38967b63b7a553be5 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sat, 20 Jan 2018 18:54:38 +0200 Subject: [PATCH 2/5] Add -fsanitize=undefined to Travis --- .travis.yml | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 0978080..d9143d3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -98,7 +98,6 @@ matrix: - ubuntu-toolchain-r-test - os: linux - dist: trusty compiler: g++-7 env: TOOLSET=gcc COMPILER=g++-7 CXXSTD=03,11,14,17 addons: @@ -108,6 +107,16 @@ matrix: sources: - ubuntu-toolchain-r-test + - os: linux + compiler: g++-7 + env: UBSAN=1 TOOLSET=gcc COMPILER=g++-7 CXXSTD=03,11,14,17 + addons: + apt: + packages: + - g++-7 + sources: + - ubuntu-toolchain-r-test + - os: linux compiler: clang++ env: TOOLSET=clang COMPILER=clang++ CXXSTD=03,11 @@ -208,6 +217,17 @@ matrix: - ubuntu-toolchain-r-test - llvm-toolchain-trusty-5.0 + - os: linux + compiler: clang++-5.0 + env: UBSAN=1 TOOLSET=clang COMPILER=clang++-5.0 CXXSTD=03,11,14,1z + addons: + apt: + packages: + - clang-5.0 + sources: + - ubuntu-toolchain-r-test + - llvm-toolchain-trusty-5.0 + - os: linux compiler: clang++-libc++ env: TOOLSET=clang COMPILER=clang++-libc++ CXXSTD=03,11,14,1z @@ -216,6 +236,14 @@ matrix: packages: - libc++-dev + - os: linux + compiler: clang++-libc++ + env: UBSAN=1 TOOLSET=clang COMPILER=clang++-libc++ CXXSTD=03,11,14,1z + addons: + apt: + packages: + - libc++-dev + - os: osx compiler: clang++ env: TOOLSET=clang COMPILER=clang++ CXXSTD=03,11,14,1z @@ -236,7 +264,7 @@ install: script: - |- echo "using $TOOLSET : : $COMPILER ;" > ~/user-config.jam - - ./b2 -j3 libs/system/test toolset=$TOOLSET cxxstd=$CXXSTD + - ./b2 -j3 libs/system/test toolset=$TOOLSET cxxstd=$CXXSTD ${UBSAN:+cxxflags=-fsanitize=undefined} ${UBSAN:+cxxflags=-fno-sanitize-recover=undefined} ${UBSAN:+linkflags=-fsanitize=undefined} notifications: email: From 5866fbb2b2574c1fc4b1e9e71523ad9147b6a471 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sun, 21 Jan 2018 17:38:01 +0200 Subject: [PATCH 3/5] 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 From 7f98fa58eb2f6b2d39b628326628347acc4427a2 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sun, 21 Jan 2018 18:21:34 +0200 Subject: [PATCH 4/5] Refactor test/Jamfile --- test/Jamfile.v2 | 110 ++++++++++++++++-------------------------------- 1 file changed, 36 insertions(+), 74 deletions(-) diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 006a309..00038dc 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -61,91 +61,53 @@ project return $(result) ; } + rule system-run- ( sources + ) + { + local result ; + + result += [ run $(sources) : : : static : $(sources[1]:B)_static ] ; + result += [ run $(sources) : : : shared : $(source:B)_shared ] ; + result += [ run $(sources) : : : -/boost/system//boost_system BOOST_ERROR_CODE_HEADER_ONLY : $(sources[1]:B)_header ] ; + + return $(result) ; + } + + rule system-run ( sources + ) + { + local result = [ system-run- $(sources) ] ; + + # Test a source file built with -std=c++03 linked with a System library built without -std=c++03 + result += [ run $(sources) : : : static @cxx03 : $(sources[1]:B)_static_03 ] ; + result += [ run $(sources) : : : shared @cxx03 : $(sources[1]:B)_shared_03 ] ; + + # Test a source file built with -std=c++11 linked with a System library built without -std=c++11 + result += [ run $(sources) : : : static @cxx11 : $(sources[1]:B)_static_11 ] ; + result += [ run $(sources) : : : shared @cxx11 : $(sources[1]:B)_shared_11 ] ; + + return $(result) ; + } + test-suite "system" - : [ run error_code_test.cpp - : # command line - : # input files - : # requirements - static - ] - [ run error_code_test.cpp - : : : shared : error_code_test_shared - ] - [ run error_code_test.cpp - : : : static @cxx03 : error_code_test_03 - ] - [ run error_code_test.cpp - : : : shared @cxx03 : error_code_test_shared_03 - ] - [ run error_code_test.cpp - : : : static @cxx11 : error_code_test_11 - ] - [ run error_code_test.cpp - : : : shared @cxx11 : error_code_test_shared_11 - ] - [ run error_code_user_test.cpp - : : : static - ] - [ run error_code_user_test.cpp - : : : shared : error_code_user_test_shared - ] - [ run system_error_test.cpp - : : : static - ] - [ run system_error_test.cpp - : : : shared : system_error_test_shared - ] + : [ system-run error_code_test.cpp ] + [ system-run error_code_user_test.cpp ] + [ system-run system_error_test.cpp ] [ run dynamic_link_test.cpp throw_test : : : shared : throw_test_shared ] - [ run initialization_test.cpp - : : : shared : initialization_test_shared - ] + [ system-run initialization_test.cpp ] [ run header_only_test.cpp : : : -/boost/system//boost_system ] - [ run config_test.cpp - : : : always_show_run_output - ] - [ run std_interop_test.cpp - : : : static - ] - [ run std_interop_test.cpp - : : : shared : std_interop_test_shared - ] - [ run std_mismatch_test.cpp - : : : static @cxx03 : std_mismatch_test_03 - ] - [ run std_mismatch_test.cpp - : : : shared @cxx03 : std_mismatch_test_shared_03 - ] - [ run std_mismatch_test.cpp - : : : static @cxx11 : std_mismatch_test_11 - ] - [ run std_mismatch_test.cpp - : : : shared @cxx11 : std_mismatch_test_shared_11 - ] [ run header_only_test.cpp : : : -/boost/system//boost_system BOOST_NO_ANSI_APIS : header_only_test_no_ansi ] - [ run single_instance_test.cpp single_instance_1.cpp single_instance_2.cpp - : : : static : single_instance_test_static - ] - [ run single_instance_test.cpp single_instance_1.cpp single_instance_2.cpp - : : : shared : single_instance_test_shared - ] - [ run single_instance_test.cpp single_instance_1.cpp single_instance_2.cpp - : : : -/boost/system//boost_system BOOST_ERROR_CODE_HEADER_ONLY : single_instance_test_header - ] - [ run before_main_test.cpp - : : : static : before_main_test_static - ] - [ run before_main_test.cpp - : : : shared : before_main_test_shared - ] - [ run before_main_test.cpp - : : : -/boost/system//boost_system BOOST_ERROR_CODE_HEADER_ONLY : before_main_test_header + [ run config_test.cpp + : : : always_show_run_output ] + [ system-run- std_interop_test.cpp ] + [ system-run std_mismatch_test.cpp ] + [ system-run single_instance_test.cpp single_instance_1.cpp single_instance_2.cpp ] + [ system-run before_main_test.cpp ] ; # Quick (CI) test From 8e631c9afdc5c6b7e0cc3055b4540a54a7a8b1d3 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sun, 21 Jan 2018 18:22:49 +0200 Subject: [PATCH 5/5] Add variant=debug,release to Travis --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index e079cfc..fc9ef29 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} ${UBSAN:+define=UBSAN=1} + - ./b2 -j3 libs/system/test toolset=$TOOLSET cxxstd=$CXXSTD variant=debug,release ${UBSAN:+cxxflags=-fsanitize=undefined} ${UBSAN:+cxxflags=-fno-sanitize-recover=undefined} ${UBSAN:+linkflags=-fsanitize=undefined} ${UBSAN:+define=UBSAN=1} notifications: email: