1# 2# Copyright Andrey Semashev 2015 - 2018. 3# Distributed under the Boost Software License, Version 1.0. 4# (See accompanying file LICENSE_1_0.txt or copy at 5# http://www.boost.org/LICENSE_1_0.txt) 6 7import testing ; 8import modules ; 9import path ; 10import regex ; 11import project ; 12import configure ; 13 14lib advapi32 ; 15lib bcrypt ; 16lib user32 ; 17 18local here = [ modules.binding $(__name__) ] ; 19 20project.push-current [ project.current ] ; 21project.load [ path.join [ path.make $(here:D) ] config/has-bcrypt ] ; 22project.pop-current ; 23 24project 25 : requirements 26 27 # Disable warnings about using 'insecure' standard C functions 28 <toolset>msvc:<define>_SCL_SECURE_NO_WARNINGS 29 <toolset>msvc:<define>_SCL_SECURE_NO_DEPRECATE 30 <toolset>msvc:<define>_CRT_SECURE_NO_WARNINGS 31 <toolset>msvc:<define>_CRT_SECURE_NO_DEPRECATE 32 <toolset>intel-win:<define>_SCL_SECURE_NO_WARNINGS 33 <toolset>intel-win:<define>_SCL_SECURE_NO_DEPRECATE 34 <toolset>intel-win:<define>_CRT_SECURE_NO_WARNINGS 35 <toolset>intel-win:<define>_CRT_SECURE_NO_DEPRECATE 36 37 : default-build 38 # Testers typically don't specify threading environment and the library can be built and tested for single and multi. I'm more interested in multi though. 39 <threading>multi 40# <link>static 41 ; 42 43# This rule makes sure the tests are run only on Windows 44rule filter-target-os ( properties * ) 45{ 46 local result ; 47 if ! ( <target-os>windows in $(properties) || <target-os>cygwin in $(properties) ) 48 { 49 result = <build>no ; 50 } 51 52 return $(result) ; 53} 54 55# The rule tests if the Windows SDK supports BCrypt API and library 56rule check-has-bcrypt ( properties * ) 57{ 58 local result ; 59 60 local has_bcrypt = [ configure.builds /boost/winapi/test/has-bcrypt//has_bcrypt : $(properties) : windows-sdk-supports-bcrypt ] ; 61 if ! $(has_bcrypt) 62 { 63 result = <build>no ; 64 } 65 66 return $(result) ; 67} 68 69# This rule enumerates through all the sources and invokes 70# the run rule for each source, the result is a list of all 71# the run rules, which we can pass on to the test_suite rule: 72rule test_all 73{ 74 local all_rules ; 75 local file ; 76 local headers_path = [ path.make $(BOOST_ROOT)/libs/winapi/include/boost/winapi ] ; 77 for file in [ path.glob-tree $(headers_path) : *.hpp : detail ] 78 { 79 local rel_file = [ path.relative-to [ path.parent $(headers_path) ] $(file) ] ; 80 # Note: The test name starts with '~' in order to group these tests in the test report table, preferably at the end. 81 # All '/' are replaced with '-' because apparently test scripts have a problem with test names containing slashes. 82 local test_name = [ regex.replace $(rel_file) "/" "-" ] ; 83 local decl_test_name = ~hdr-decl-$(test_name) ; 84 local use_winh_test_name = ~hdr-use-winh-$(test_name) ; 85 local pre_winh_test_name = ~hdr-pre-winh-$(test_name) ; 86 local post_winh_test_name = ~hdr-post-winh-$(test_name) ; 87 #ECHO $(rel_file) ; 88 all_rules += [ compile compile/decl_header.cpp : <conditional>@filter-target-os <define>"BOOST_WINAPI_TEST_HEADER=$(rel_file)" <dependency>$(file) : $(decl_test_name) ] ; 89 all_rules += [ compile compile/decl_header.cpp : <conditional>@filter-target-os <define>"BOOST_WINAPI_TEST_HEADER=$(rel_file)" <define>"BOOST_USE_WINDOWS_H" <dependency>$(file) : $(use_winh_test_name) ] ; 90 all_rules += [ compile compile/windows_h_pre.cpp : <conditional>@filter-target-os <define>"BOOST_WINAPI_TEST_HEADER=$(rel_file)" <dependency>$(file) : $(pre_winh_test_name) ] ; 91 all_rules += [ compile compile/windows_h_post.cpp : <conditional>@filter-target-os <define>"BOOST_WINAPI_TEST_HEADER=$(rel_file)" <dependency>$(file) : $(post_winh_test_name) ] ; 92 } 93 94 headers_path = [ path.make $(BOOST_ROOT)/libs/winapi/include/boost/detail ] ; 95 for file in [ path.glob $(headers_path) : *.hpp : detail ] 96 { 97 local rel_file = [ path.relative-to $(headers_path) $(file) ] ; 98 local test_name = [ regex.replace $(rel_file) "/" "-" ] ; 99 local decl_test_name = ~hdr-decl-$(test_name) ; 100 local use_winh_test_name = ~hdr-use-winh-$(test_name) ; 101 local pre_winh_test_name = ~hdr-pre-winh-$(test_name) ; 102 local post_winh_test_name = ~hdr-post-winh-$(test_name) ; 103 #ECHO $(rel_file) ; 104 all_rules += [ compile compile/decl_header.cpp : <conditional>@filter-target-os <define>"BOOST_WINAPI_TEST_HEADER=detail/$(rel_file)" <dependency>$(file) : $(decl_test_name) ] ; 105 all_rules += [ compile compile/decl_header.cpp : <conditional>@filter-target-os <define>"BOOST_WINAPI_TEST_HEADER=detail/$(rel_file)" <define>"BOOST_USE_WINDOWS_H" <dependency>$(file) : $(use_winh_test_name) ] ; 106 all_rules += [ compile compile/windows_h_pre.cpp : <conditional>@filter-target-os <define>"BOOST_WINAPI_TEST_HEADER=detail/$(rel_file)" <dependency>$(file) : $(pre_winh_test_name) ] ; 107 all_rules += [ compile compile/windows_h_post.cpp : <conditional>@filter-target-os <define>"BOOST_WINAPI_TEST_HEADER=detail/$(rel_file)" <dependency>$(file) : $(post_winh_test_name) ] ; 108 } 109 110 for file in [ glob run/*.cpp ] 111 { 112 local reqs = <conditional>@filter-target-os <define>"BOOST_WINAPI_DEFINE_VERSION_MACROS=1" ; 113 local test_name = [ path.basename $(file) ] ; 114 if $(test_name) = "winapi_info.cpp" 115 { 116 reqs += <test-info>always_show_run_output ; 117 } 118 else if $(test_name) = "bcrypt_abi.cpp" 119 { 120 reqs += <conditional>@check-has-bcrypt ; 121 reqs += <library>bcrypt ; 122 } 123 else if $(test_name) = "crypt_abi.cpp" || $(test_name) = "pipes_abi.cpp" || $(test_name) = "security_abi.cpp" 124 { 125 reqs += <library>advapi32 ; 126 } 127 else if $(test_name) = "show_window_abi.cpp" 128 { 129 reqs += <library>user32 ; 130 } 131 132 all_rules += [ run $(file) : : : $(reqs) ] ; 133 } 134 135 #ECHO All rules: $(all_rules) ; 136 return $(all_rules) ; 137} 138 139test-suite winapi : [ test_all ] ; 140