Skip to content

Commit 1c98109

Browse files
nglevinluispadron
authored andcommitted
Add a check to make sure that the architecture exists before performing commands against the architecture in archive_contents_test and binary_contents_test.
Cherry-pick: 14f67ff
1 parent 332261a commit 1c98109

3 files changed

Lines changed: 71 additions & 40 deletions

File tree

test/starlark_tests/verifier_scripts/archive_contents_test.sh

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,13 +148,13 @@ if [[ -n "${BINARY_TEST_FILE-}" ]]; then
148148
fi
149149

150150
if [[ -n "${BINARY_NOT_CONTAINS_ARCHITECTURES-}" ]]; then
151-
IFS=' ' found_archs=($(lipo -archs "$path"))
151+
arch_found=false
152152
for arch in "${BINARY_NOT_CONTAINS_ARCHITECTURES[@]}"
153153
do
154+
something_tested=true
155+
found_archs=( $(lipo -archs "$path") )
154156
for found_arch in "${found_archs[@]}"
155157
do
156-
something_tested=true
157-
arch_found=false
158158
if [[ "$arch" == "$found_arch" ]]; then
159159
arch_found=true
160160
break
@@ -173,6 +173,20 @@ if [[ -n "${BINARY_TEST_FILE-}" ]]; then
173173
fail "No architecture specified for binary file at \"$path\""
174174
fi
175175

176+
arch_found=false
177+
found_archs=( $(lipo -archs "$path") )
178+
for found_arch in "${found_archs[@]}"
179+
do
180+
if [[ "$arch" == "$found_arch" ]]; then
181+
arch_found=true
182+
break
183+
fi
184+
done
185+
if [[ "$arch_found" = false ]]; then
186+
fail "Could not find architecture \"$arch\". The architectures in the " \
187+
"binary were:$newline${found_archs[@]}"
188+
fi
189+
176190
# Filter out undefined symbols from the objdump mach-o symbol output and
177191
# return the fifth from rightmost values, with the `.hidden` column stripped
178192
# where applicable.

test/starlark_tests/verifier_scripts/binary_contents_test.sh

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,13 @@ if [[ -n "${BINARY_TEST_FILE-}" ]]; then
5050
something_tested=false
5151

5252
if [[ -n "${BINARY_NOT_CONTAINS_ARCHITECTURES-}" ]]; then
53-
IFS=' ' found_archs=($(lipo -archs "$path"))
53+
arch_found=false
5454
for arch in "${BINARY_NOT_CONTAINS_ARCHITECTURES[@]}"
5555
do
56+
something_tested=true
57+
found_archs=( $(lipo -archs "$path") )
5658
for found_arch in "${found_archs[@]}"
5759
do
58-
something_tested=true
59-
arch_found=false
6060
if [[ "$arch" == "$found_arch" ]]; then
6161
arch_found=true
6262
break
@@ -75,6 +75,20 @@ if [[ -n "${BINARY_TEST_FILE-}" ]]; then
7575
fail "No architecture specified for binary file at \"$path\""
7676
fi
7777

78+
arch_found=false
79+
found_archs=( $(lipo -archs "$path") )
80+
for found_arch in "${found_archs[@]}"
81+
do
82+
if [[ "$arch" == "$found_arch" ]]; then
83+
arch_found=true
84+
break
85+
fi
86+
done
87+
if [[ "$arch_found" = false ]]; then
88+
fail "Could not find architecture \"$arch\". The architectures " \
89+
"in the binary were:$newline${found_archs[@]}"
90+
fi
91+
7892
# Filter out undefined symbols from the objdump mach-o symbol output and
7993
# return the fifth from rightmost values, with the `.hidden` column stripped
8094
# where applicable.

test/starlark_tests/watchos_single_target_application_tests.bzl

Lines changed: 37 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -228,41 +228,44 @@ delegate is referenced in the single-target `watchos_application`'s `deps`.
228228
],
229229
)
230230

231-
# Test that the output application binary is identified as watchOS simulator via the Mach-O
232-
# load command LC_BUILD_VERSION for the arm64 binary slice when only iOS cpus are defined, and
233-
# that 32-bit archs are eliminated.
234-
binary_contents_test(
235-
name = "{}_simulator_ios_cpus_intel_platform_test".format(name),
236-
build_type = "simulator",
237-
target_under_test = "//test/starlark_tests/targets_under_test/watchos:app_companion_arm64_support",
238-
cpus = {
239-
"ios_multi_cpus": ["x86_64", "sim_arm64"],
240-
"watchos_cpus": [""],
241-
},
242-
binary_test_file = "$BUNDLE_ROOT/Watch/app_arm64_support.app/app_arm64_support",
243-
binary_test_architecture = "x86_64",
244-
binary_not_contains_architectures = ["i386", "arm64e"],
245-
macho_load_commands_contain = ["cmd LC_BUILD_VERSION", "platform WATCHOSSIMULATOR"],
246-
tags = [name],
247-
)
231+
# TODO: b/440323872 - Re-enable these tests when the logic to derive watchOS platforms from
232+
# multiple iOS platforms is resolved.
233+
#
234+
# # Test that the output application binary is identified as watchOS simulator via the Mach-O
235+
# # load command LC_BUILD_VERSION for the arm64 binary slice when only iOS cpus are defined, and
236+
# # that 32-bit archs are eliminated.
237+
# binary_contents_test(
238+
# name = "{}_simulator_ios_cpus_intel_platform_test".format(name),
239+
# build_type = "simulator",
240+
# target_under_test = "//test/starlark_tests/targets_under_test/watchos:app_companion_arm64_support",
241+
# cpus = {
242+
# "ios_multi_cpus": ["x86_64", "sim_arm64"],
243+
# "watchos_cpus": [""],
244+
# },
245+
# binary_test_file = "$BUNDLE_ROOT/Watch/app_arm64_support.app/app_arm64_support",
246+
# binary_test_architecture = "x86_64",
247+
# binary_not_contains_architectures = ["i386", "arm64e"],
248+
# macho_load_commands_contain = ["cmd LC_BUILD_VERSION", "platform WATCHOSSIMULATOR"],
249+
# tags = [name],
250+
# )
248251

249-
# Test that the output application binary is identified as watchOS simulator via the Mach-O
250-
# load command LC_BUILD_VERSION for the arm64 binary slice when only iOS cpus are defined, and
251-
# that 32-bit archs are eliminated.
252-
binary_contents_test(
253-
name = "{}_simulator_ios_cpus_arm_platform_test".format(name),
254-
build_type = "simulator",
255-
target_under_test = "//test/starlark_tests/targets_under_test/watchos:app_companion_arm64_support",
256-
cpus = {
257-
"ios_multi_cpus": ["x86_64", "sim_arm64"],
258-
"watchos_cpus": [""],
259-
},
260-
binary_test_file = "$BUNDLE_ROOT/Watch/app_arm64_support.app/app_arm64_support",
261-
binary_test_architecture = "arm64",
262-
binary_not_contains_architectures = ["i386", "arm64e"],
263-
macho_load_commands_contain = ["cmd LC_BUILD_VERSION", "platform WATCHOSSIMULATOR"],
264-
tags = [name],
265-
)
252+
# # Test that the output application binary is identified as watchOS simulator via the Mach-O
253+
# # load command LC_BUILD_VERSION for the arm64 binary slice when only iOS cpus are defined, and
254+
# # that 32-bit archs are eliminated.
255+
# binary_contents_test(
256+
# name = "{}_simulator_ios_cpus_arm_platform_test".format(name),
257+
# build_type = "simulator",
258+
# target_under_test = "//test/starlark_tests/targets_under_test/watchos:app_companion_arm64_support",
259+
# cpus = {
260+
# "ios_multi_cpus": ["x86_64", "sim_arm64"],
261+
# "watchos_cpus": [""],
262+
# },
263+
# binary_test_file = "$BUNDLE_ROOT/Watch/app_arm64_support.app/app_arm64_support",
264+
# binary_test_architecture = "arm64",
265+
# binary_not_contains_architectures = ["i386", "arm64e"],
266+
# macho_load_commands_contain = ["cmd LC_BUILD_VERSION", "platform WATCHOSSIMULATOR"],
267+
# tags = [name],
268+
# )
266269

267270
# Test that the output application binary is identified as watchOS device via the Mach-O
268271
# load command LC_BUILD_VERSION for the arm64 binary slice when only iOS cpus are defined, and

0 commit comments

Comments
 (0)