@@ -47,19 +47,31 @@ def build(self, host_target):
47
47
def should_test (self , host_target ):
48
48
return self .args .test_toolchainbenchmarks
49
49
50
+ def _get_test_environment (self , host_target ):
51
+ if platform .system () == 'Darwin' :
52
+ # the resulting binaries would search first in /usr/lib/swift,
53
+ # we need to prefer the libraries we just built
54
+ return {'DYLD_LIBRARY_PATH' : os .path .join (
55
+ _get_toolchain_path (host_target , self , self .args ),
56
+ 'usr' , 'lib' , 'swift' , 'macosx' )}
57
+
58
+ return None
59
+
50
60
def test (self , host_target ):
51
61
"""Just run a single instance of the command for both .debug and
52
62
.release.
53
63
"""
54
64
cmdline = ['--num-iters=1' , 'XorLoop' ]
65
+ test_environment = self ._get_test_environment (host_target )
66
+
55
67
bench_Onone = os .path .join (self .build_dir , 'bin' , 'Benchmark_Onone' )
56
- shell .call ([bench_Onone ] + cmdline )
68
+ shell .call ([bench_Onone ] + cmdline , env = test_environment )
57
69
58
70
bench_O = os .path .join (self .build_dir , 'bin' , 'Benchmark_O' )
59
- shell .call ([bench_O ] + cmdline )
71
+ shell .call ([bench_O ] + cmdline , env = test_environment )
60
72
61
73
bench_Osize = os .path .join (self .build_dir , 'bin' , 'Benchmark_Osize' )
62
- shell .call ([bench_Osize ] + cmdline )
74
+ shell .call ([bench_Osize ] + cmdline , env = test_environment )
63
75
64
76
def should_install (self , host_target ):
65
77
return False
@@ -81,7 +93,11 @@ def get_dependencies(cls):
81
93
swiftpm .SwiftPM ]
82
94
83
95
84
- def run_build_script_helper (host_target , product , args ):
96
+ def _get_toolchain_path (host_target , product , args ):
97
+ # TODO check if we should prefer using product.install_toolchain_path
98
+ # this logic initially was inside run_build_script_helper
99
+ # and was factored out so it can be used in testing as well
100
+
85
101
toolchain_path = swiftpm .SwiftPM .get_install_destdir (args ,
86
102
host_target ,
87
103
product .build_dir )
@@ -90,6 +106,12 @@ def run_build_script_helper(host_target, product, args):
90
106
toolchain_path += \
91
107
targets .darwin_toolchain_prefix (args .install_prefix )
92
108
109
+ return toolchain_path
110
+
111
+
112
+ def run_build_script_helper (host_target , product , args ):
113
+ toolchain_path = _get_toolchain_path (host_target , product , args )
114
+
93
115
# Our source_dir is expected to be './$SOURCE_ROOT/benchmarks'. That is due
94
116
# the assumption that each product is in its own build directory. This
95
117
# product is not like that and has its package/tools instead in
0 commit comments