1# Copyright 2007 Andy Tompkins. 2# Copyright 2017 - 2018 James E. King III 3# Distributed under the Boost Software License, Version 1.0. (See 4# accompanying file LICENSE_1_0.txt or copy at 5# https://www.boost.org/LICENSE_1_0.txt) 6 7lib bcrypt ; 8 9project libs/uuid/test 10 : requirements 11 12 # boost.jam defines BOOST_ALL_NO_LIB, this makes library management 13 # near-impossible with the platform selection logic in the random_provider 14 <target-os>windows:<define>BOOST_UUID_FORCE_AUTO_LINK 15 <target-os>windows,<toolset>gcc:<library>bcrypt 16 17 # boost::lexical_cast needs this for a warning-free build (CHAR_MAX) 18 <toolset>clang:<cxxflags>-Wno-c99-extensions 19 20 # boost::random needs this setting for a warning free build: 21 <toolset>msvc:<define>_SCL_SECURE_NO_WARNINGS 22 23 # link static for easier debugging 24 <link>static 25 26; 27 28import os ; 29import path ; 30import regex ; 31import testing ; 32 33# this rule enumerates through all the headers and ensures 34# that inclusion of the header by itself is sufficient to 35# compile successfully, proving the header does not depend 36# on any other headers to be included first - adapted from 37# logic in the winapi test bjam script 38rule test_all 39{ 40 local all_rules = ; 41 local file ; 42 local headers_path = [ path.make $(BOOST_ROOT)/libs/uuid/include/boost/uuid ] ; 43 for file in [ path.glob-tree $(headers_path) : *.hpp : uuid ] 44 { 45 local rel_file = [ path.relative-to $(headers_path) $(file) ] ; 46 # Note: The test name starts with '~' in order to group these tests in the test report table, preferably at the end. 47 # All '/' are replaced with '-' because apparently test scripts have a problem with test names containing slashes. 48 local test_name = [ regex.replace $(rel_file) "/" "-" ] ; 49 local decl_test_name = ~hdr-decl-$(test_name) ; 50 # ECHO $(rel_file) ; 51 all_rules += [ compile compile/decl_header.cpp : <define>"BOOST_UUID_TEST_HEADER=$(rel_file)" <dependency>$(file) : $(decl_test_name) ] ; 52 } 53 54 local tests_path = [ path.make $(BOOST_ROOT)/libs/uuid/test/compile-fail ] ; 55 for file in [ path.glob-tree $(tests_path) : *.cpp ] 56 { 57 local rel_file = [ path.relative-to $(tests_path) $(file) ] ; 58 local test_name = [ regex.replace [ regex.replace $(rel_file) "/" "-" ] ".cpp" "" ] ; 59 local decl_test_name = cf-$(test_name) ; 60 # ECHO $(rel_file) ; 61 all_rules += [ compile-fail $(file) : : $(decl_test_name) ] ; 62 } 63 64 # make sure compile time options work in isolation 65 all_rules += [ compile compile/decl_header.cpp : 66 <define>"BOOST_UUID_TEST_HEADER=uuid.hpp" 67 <define>"BOOST_UUID_NO_TYPE_TRAITS" 68 <dependency>$(BOOST_ROOT)/boost/uuid/uuid.hpp : 69 compile_uuid_no_type_traits ] ; 70 all_rules += [ compile compile/decl_header.cpp : 71 <define>"BOOST_UUID_TEST_HEADER=uuid.hpp" 72 <define>"BOOST_UUID_NO_SIMD" 73 <dependency>$(BOOST_ROOT)/boost/uuid/uuid.hpp : 74 compile_uuid_no_simd ] ; 75 76 # ECHO All rules: $(all_rules) ; 77 return $(all_rules) ; 78} 79 80# disabled in UBSAN builds due to issues in Boost.Serialization 81if ! [ os.environ UBSAN_OPTIONS ] 82{ 83test-suite uuid-serialization : 84 # test serializing uuids 85 [ run test_serialization.cpp ../../serialization/build//boost_serialization ] 86 87 # TODO - This test fails to like with boost_wserialization 88 # [ run test_wserialization.cpp 89 # ../../serialization/build//boost_serialization 90 # ../../serialization/build//boost_wserialization 91 # : : : <dependency>../../config/test/all//BOOST_NO_STD_WSTREAMBUF 92 # ] 93 ; 94} 95 96test-suite uuid : 97 [ test_all ] 98 99 # test inclucing all .hpp files in 2 translations units 100 # to look for issues when using multiple translation units 101 # eg. missing inline on a global functionstate is not missing 102 [ run test_include1.cpp test_include2.cpp ] 103 104 # main test 105 [ run test_uuid.cpp ] 106 [ run test_uuid_no_simd.cpp ] 107 108 # test uuid_io.hpp 109 [ run test_io.cpp ] 110 111 # test generators 112 [ run test_nil_generator.cpp ] 113 [ run test_name_generator.cpp ] 114 [ run test_name_generator.cpp : : : <define>BOOST_UUID_COMPAT_PRE_1_71_MD5 : test_name_generator_pre_1_71_compat ] 115 [ run test_string_generator.cpp ] 116 [ run test_random_generator.cpp ] 117 118 # test tagging an object 119 [ run test_tagging.cpp ] 120 121 # test use cases 122 [ run test_uuid_class.cpp ] 123 [ run test_uuid_in_map.cpp ] 124 125 # test hash functions 126 [ run test_hash.cpp ] 127 [ run test_md5.cpp ] 128 [ run test_md5.cpp : : : <define>BOOST_UUID_COMPAT_PRE_1_71_MD5 : test_md5_pre_1_71_compat ] 129 [ run test_sha1.cpp ] 130 131 # test MSVC 12 (VS2013) optimizer bug with SIMD operations. 132 # See https://svn.boost.org/trac/boost/ticket/8509#comment:3 133 # Only happens in Release x64 builds. 134 [ run test_msvc_simd_bug981648_main.cpp 135 test_msvc_simd_bug981648_foo.cpp 136 : : : <build>no <toolset>msvc-12.0:<build>yes <variant>release <debug-symbols>on : test_msvc_simd_bug981648 ] 137 138 # a small benchmark test for random generation 139 [ run test_bench_random.cpp ../../timer/build//boost_timer : : : <toolset>clang-cloudabi:<build>no ] 140 141 [ run test_entropy_error.cpp ] 142 143 # tests for the header-only random provider 144 # there are a number of variations to test all compile-time branches 145 # and to make sure we test all the error handling code paths 146 [ run test_detail_random_provider.cpp 147 : : : 148 <define>_WIN32_WINNT=0x0600 # will force bcrypt over wincrypt (on windows) 149 : test_detail_random_provider_happy ] 150 151 [ run test_detail_random_provider.cpp 152 : : : 153 <define>BOOST_UUID_RANDOM_PROVIDER_NO_LIB # disable any auto-linking 154 <define>BOOST_UUID_TEST_RANDOM_MOCK # mock default provider to force error path testing 155 <define>_WIN32_WINNT=0x0600 # will force bcrypt over wincrypt (on windows) 156 : 157 test_detail_random_provider_sad ] 158 159 # CI builds in appveyor normally select the bcrypt provider, so 160 # force wincrypt to be selected and test both happy and sad paths: 161 [ lib mock_random 162 : mock_random.cpp 163 : <link>shared 164 <build>no # do not build on any target-os 165 <target-os>windows:<build>yes ] # except for windows 166 167 [ run test_detail_random_provider.cpp 168 : : : 169 <define>_WIN32_WINNT=0x0501 # will force wincrypt over bcrypt 170 <build>no # do not build on any target-os 171 <target-os>windows:<build>yes # except for windows 172 : test_detail_random_provider_happy_wincrypt ] 173 174 [ run test_detail_random_provider.cpp 175 mock_random 176 : : : 177 <define>_WIN32_WINNT=0x0501 # will force wincrypt over bcrypt 178 <define>BOOST_UUID_RANDOM_PROVIDER_NO_LIB # disable any auto-linking 179 <define>BOOST_UUID_TEST_RANDOM_MOCK # mock wincrypt to force error path testing 180 <build>no # do not build on any target-os 181 <target-os>windows:<build>yes # except for windows 182 : test_detail_random_provider_sad_wincrypt ] 183 184 # CI builds in travis will eventually select getrandom/getentropy when they move 185 # to a version of ubuntu with glibc-2.25 on it, so when that happens keep 186 # testing the posix provider: 187 [ run test_detail_random_provider.cpp 188 : : : 189 <define>BOOST_UUID_RANDOM_PROVIDER_FORCE_POSIX # will force POSIX over getrandom/getentropy 190 <target-os>windows:<build>no # do not bother running on windows 191 <toolset>clang-cloudabi:<build>no # no need to build under cloudabi 192 : test_detail_random_provider_happy_posix ] 193 194 [ run test_detail_random_provider.cpp 195 : : : 196 <define>BOOST_UUID_RANDOM_PROVIDER_FORCE_POSIX # will force POSIX over getrandom/getentropy 197 <define>BOOST_UUID_TEST_RANDOM_MOCK # redirect code to use mock system calls 198 <target-os>windows:<build>no # do not bother running on windows 199 <toolset>clang-cloudabi:<build>no # no need to build under cloudabi 200 : test_detail_random_provider_sad_posix ] 201 202 # Force running tests for getentropy despite it's not going to be used on Linux. getentropy 203 # may be used on systems other than Linux, which are not part of the CI testers pool. 204 [ run test_detail_random_provider.cpp 205 : : : 206 <define>BOOST_UUID_RANDOM_PROVIDER_DISABLE_GETRANDOM # will force getentropy over getrandom 207 <build>no 208 <target-os>linux:<build>yes # build only on linux (or any other systems that support getentropy) 209 : test_detail_random_provider_happy_getentropy ] 210 211 [ run test_detail_random_provider.cpp 212 : : : 213 <define>BOOST_UUID_RANDOM_PROVIDER_DISABLE_GETRANDOM # will force getentropy over getrandom 214 <define>BOOST_UUID_TEST_RANDOM_MOCK # redirect code to use mock system calls 215 <build>no 216 <target-os>linux:<build>yes # build only on linux (or any other systems that support getentropy) 217 : test_detail_random_provider_sad_getentropy ] 218 219 ; 220