@@ -51,19 +51,31 @@ def build(self, host_target):
51
51
def should_test (self , host_target ):
52
52
return self .args .test_toolchainbenchmarks
53
53
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
+
54
64
def test (self , host_target ):
55
65
"""Just run a single instance of the command for both .debug and
56
66
.release.
57
67
"""
58
68
cmdline = ['--num-iters=1' , 'XorLoop' ]
69
+ test_environment = self ._get_test_environment (host_target )
70
+
59
71
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 )
61
73
62
74
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 )
64
76
65
77
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 )
67
79
68
80
def should_install (self , host_target ):
69
81
return False
@@ -85,7 +97,11 @@ def get_dependencies(cls):
85
97
swiftpm .SwiftPM ]
86
98
87
99
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
+
89
105
toolchain_path = swiftpm .SwiftPM .get_install_destdir (args ,
90
106
host_target ,
91
107
product .build_dir )
@@ -94,6 +110,12 @@ def run_build_script_helper(host_target, product, args):
94
110
toolchain_path += \
95
111
targets .darwin_toolchain_prefix (args .install_prefix )
96
112
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
+
97
119
# Our source_dir is expected to be './$SOURCE_ROOT/benchmarks'. That is due
98
120
# the assumption that each product is in its own build directory. This
99
121
# product is not like that and has its package/tools instead in
0 commit comments