@@ -51,19 +51,31 @@ def build(self, host_target):
5151 def should_test (self , host_target ):
5252 return self .args .test_toolchainbenchmarks
5353
54+ def _get_test_environment (self , host_target ):
55+ if platform .system () == 'Darwin' :
56+ # the resulting binaries would search first in /usr/lib/swift,
57+ # we need to prefer the libraries we just built
58+ return {'DYLD_LIBRARY_PATH' : os .path .join (
59+ _get_toolchain_path (host_target , self , self .args ),
60+ 'usr' , 'lib' , 'swift' , 'macosx' )}
61+
62+ return None
63+
5464 def test (self , host_target ):
5565 """Just run a single instance of the command for both .debug and
5666 .release.
5767 """
5868 cmdline = ['--num-iters=1' , 'XorLoop' ]
69+ test_environment = self ._get_test_environment (host_target )
70+
5971 bench_Onone = os .path .join (self .build_dir , 'bin' , 'Benchmark_Onone' )
60- shell .call ([bench_Onone ] + cmdline )
72+ shell .call ([bench_Onone ] + cmdline , env = test_environment )
6173
6274 bench_O = os .path .join (self .build_dir , 'bin' , 'Benchmark_O' )
63- shell .call ([bench_O ] + cmdline )
75+ shell .call ([bench_O ] + cmdline , env = test_environment )
6476
6577 bench_Osize = os .path .join (self .build_dir , 'bin' , 'Benchmark_Osize' )
66- shell .call ([bench_Osize ] + cmdline )
78+ shell .call ([bench_Osize ] + cmdline , env = test_environment )
6779
6880 def should_install (self , host_target ):
6981 return False
@@ -85,7 +97,11 @@ def get_dependencies(cls):
8597 swiftpm .SwiftPM ]
8698
8799
88- def run_build_script_helper (host_target , product , args ):
100+ def _get_toolchain_path (host_target , product , args ):
101+ # TODO check if we should prefer using product.install_toolchain_path
102+ # this logic initially was inside run_build_script_helper
103+ # and was factored out so it can be used in testing as well
104+
89105 toolchain_path = swiftpm .SwiftPM .get_install_destdir (args ,
90106 host_target ,
91107 product .build_dir )
@@ -94,6 +110,12 @@ def run_build_script_helper(host_target, product, args):
94110 toolchain_path += \
95111 targets .darwin_toolchain_prefix (args .install_prefix )
96112
113+ return toolchain_path
114+
115+
116+ def run_build_script_helper (host_target , product , args ):
117+ toolchain_path = _get_toolchain_path (host_target , product , args )
118+
97119 # Our source_dir is expected to be './$SOURCE_ROOT/benchmarks'. That is due
98120 # the assumption that each product is in its own build directory. This
99121 # product is not like that and has its package/tools instead in
0 commit comments