# Boost.AFIO Library test Jamfile # # Copyright (c) 2013 Paul Kirth and Niall Douglas # # Distributed under the Boost Software License, Version 1.0. # (See accompanying file LICENSE_1_0.txt or copy at # http://www.boost.org/LICENSE_1_0.txt) import modules ; import ../../config/checks/config : requires ; .argv = [ modules.peek : ARGV ] ; #local boost-path = [ modules.peek : BOOST_ROOT ] ; #can probably get rid of this import os ; import testing ; import pch ; # If we're running in a CI, reduce the length of the unit tests considerably rule running-in-ci ( properties * ) { local result ; if "--running-in-ci" in $(.argv) { result += BOOST_AFIO_RUNNING_IN_CI ; } return $(result) ; } # If we're on Niall's Atom 220 netbook, make it so Niall isn't waiting an hour # or more just to compile AFIO every time I change a single character. rule fast-build ( properties * ) { local result ; if "--fast-build" in $(.argv) { result += BOOST_AFIO_HEADERS_ONLY=0 BOOST_ASIO_SEPARATE_COMPILATION BOOST_ASIO_DYN_LINK ../build//boost_afio_dyn_asio ; } return $(result) ; } # Turn on LTO rule lto ( properties * ) { local result ; if "--lto" in $(.argv) { if gcc in $(properties) { result += "-flto" "-flto -O3 -fuse-linker-plugin" ; } if msvc in $(properties) { result += "/GL" "/LTCG" ; } } return $(result) ; } # Turn on the thread and undefined behaviour sanitisers rule sanitize ( properties * ) { local result ; if "--sanitize" in $(.argv) { # clang only for now as we need the blacklist to remove Boost noise if clang in $(properties) { result += BOOST_AFIO_THREAD_SANITIZING "-fsanitize=thread -fsanitize=undefined -fsanitize-blacklist=libs/afio/test/blacklist.supp -g -fno-omit-frame-pointer -fno-optimize-sibling-calls" "-fsanitize=thread -fsanitize=undefined" TSAN_OPTIONS="suppressions=libs/afio/test/tsan.supp history_size=7 external_symbolizer_path=/usr/bin/llvm-symbolizer-3.4" ; } } return $(result) ; } # Some compilers can do enhanced static analysis rule analyse ( properties * ) { local result ; if "--analyse" in $(.argv) { if clang in $(properties) { result += "--analyze" ; } if msvc in $(properties) { result += "/analyze /wd6246 /wd6993 /wd4603 /analyze:stacksize 131072" ; } } return $(result) ; } project boost/afio/test : requirements [ requires cxx11_variadic_templates cxx11_template_aliases cxx11_noexcept cxx11_constexpr ] multi . # /boost/afio//boost_afio gcc:"-fvisibility-inlines-hidden -fstrict-aliasing -Wstrict-aliasing -Wno-unused -fargument-noalias -fvisibility=hidden -fopenmp -fasynchronous-unwind-tables" gcc-mingw:"-DWIN32 -D_UNICODE -DUNICODE -Wno-missing-braces" gcc-mingw:/boost/afio//boost_afio gcc-mingw:"-lws2_32" gcc:"-lgomp" clang:"-fvisibility-inlines-hidden -fstrict-aliasing -Wstrict-aliasing -Wno-unused -Wno-mismatched-tags -Wno-unknown-pragmas -fvisibility=hidden -fopenmp -fasynchronous-unwind-tables" msvc:"/openmp /GF /Gy /bigobj /wd4456" msvc:"/LARGEADDRESSAWARE /DYNAMICBASE /NXCOMPAT" # /VERSION:1.00.0" msvc:WIN32 msvc:_WINDOWS msvc:UNICODE msvc:_UNICODE linux:"-lpthread -ldl -lrt" freebsd:"-lpthread -lexecinfo" shared:BOOST_AFIO_DYN_LINK=1 ../../system/build//boost_system ../../filesystem/build//boost_filesystem ../../atomic/build//boost_atomic ../../thread/build//boost_thread BOOST_AFIO_USE_BOOST_UNIT_TEST=1 ../../test/build//boost_unit_test_framework @running-in-ci @fast-build @lto @sanitize @analyse ; cpp-pch test_functions : test_functions.hpp : . ; explicit test_functions ; cpp-pch afio_pch : afio_pch.hpp : . ; explicit afio_pch ; obj spooky : ../detail/SpookyV2.cpp ; # look in the commandline args for "--valgrind=" and capture its contents in VALGRIND_ARGS local VALGRIND_ARGS = [ MATCH --valgrind=(.*) : $(.argv) ] ; # if we're doing a valgrind build, set up the test launcher if $(VALGRIND_ARGS) { launcher = valgrind ; } #auto generate the test_all.cpp if [ os.name ] = "NT" { local str = "for /f \"delims=\" %i in ('dir /b /a-d /s test_file_glob.bat') do \"%~fi\"" ; SHELL $(str) ; } else { SHELL [ SHELL "find -L libs/afio -name test_file_glob.sh" ] ; } # Let user limit test_files local test_files = [ MATCH ^--test=(.*)$ : $(.argv) ] ; local example_files = [ glob ../example/*.cpp ] ; if $(test_files) { test_files_all = $(test_files) ; single_test = true ; } else { # Don't do any of the fsyncing tests on the CI, as it murders the poor hard drive if "--running-in-ci" in $(.argv) { test_files = [ glob tests/*.cpp : tests/*sync_test.cpp tests/*autoflush_test.cpp ] ; } else { test_files = [ glob tests/*.cpp ] ; } test_files_all = $(test_files) test_all.cpp ; single_test = false ; } # link tests (just compile and links targets) if "--link-test" in $(.argv) { if $(single_test) != true { # Test that inline linkage works with variadic templates turned off exe test_inline_linkage_master : test_inline_linkage_master.cpp test_inline_linkage1.cpp test_inline_linkage2.cpp : BOOST_NO_CXX11_VARIADIC_TEMPLATES ; } for local x in $(test_files_all) { link $(x) test_functions spooky ; } if $(single_test) != true { for local x in $(example_files) { link $(x) afio_pch spooky ; } } } else # run actual tests { if [ os.name ] = "NT" { SHELL "rmdir /S /Q results_tests" ; SHELL "mkdir results_tests" ; } else { SHELL "rm -rf results_tests" ; SHELL "mkdir results_tests" ; } if "--test-all" in $(.argv) # run the whole test suite at once { test-suite afio : [ run test_all.cpp test_functions spooky : $(VALGRIND_ARGS) --log_format=XML --log_sink=results_all.xml --log_level=all --report_level=no : : $(launcher) ] ; PRECIOUS test_all ; } else if "--test-each" in $(.argv) # run just the individual tests { for local file in $(test_files) { run $(file) test_functions spooky : $(VALGRIND_ARGS) --log_format=XML --log_sink=results_$(file).xml --log_level=all --report_level=no : : $(launcher) ; PRECIOUS $(file) ; } } else # otherwise run individual tests and the whole lot at once as a separate test { for local file in $(test_files_all) { run $(file) test_functions spooky : $(VALGRIND_ARGS) --log_format=XML --log_sink=results_$(file).xml --log_level=all --report_level=no : : $(launcher) ; PRECIOUS $(file) ; } } }