[ios_runner]Fixed xcodebuild_runner for real devices.
Current update prevent creating/deleting simulators
if test runs on real devices.
Some bots don't have preinstalled sim-runtimes that match
version of connected real devices, it was a reason of failure like
https://chrome-swarming.appspot.com/task?id=49c31b4eab008710
To determine whether device with UDID is simulator
used `xcrun simctl` command because `idevice_id`
is not installed properly on some bots without real devices, e.g.
https://chromium-swarm.appspot.com/task?id=49c9a229b161d210
Bug: 1042380
Change-Id: I3771af295dadf32068343bdc2691bedf0a5f72a3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2002895
Reviewed-by: Rohit Rao <rohitrao@chromium.org>
Commit-Queue: Maksym Onufriienko <monufriienko@chromium.org>
Cr-Commit-Position: refs/heads/master@{#735099}
diff --git a/ios/build/bots/scripts/iossim_util.py b/ios/build/bots/scripts/iossim_util.py
index 7a3ab55..2bd8e00 100644
--- a/ios/build/bots/scripts/iossim_util.py
+++ b/ios/build/bots/scripts/iossim_util.py
@@ -148,3 +148,17 @@
return subprocess.check_output(
['xcrun', 'simctl', 'getenv',
get_simulator(platform, version), 'HOME']).rstrip()
+
+
+def is_device_with_udid_simulator(device_udid):
+ """Checks whether a device with udid is simulator or not.
+
+ Args:
+ device_udid: (str) UDID of a device.
+ """
+ simulator_list = get_simulator_list()['devices']
+ for _, simulators in simulator_list.items():
+ for device in simulators:
+ if device_udid == device['udid']:
+ return True
+ return False
diff --git a/ios/build/bots/scripts/xcodebuild_runner.py b/ios/build/bots/scripts/xcodebuild_runner.py
index eda2349..76aea1b 100644
--- a/ios/build/bots/scripts/xcodebuild_runner.py
+++ b/ios/build/bots/scripts/xcodebuild_runner.py
@@ -351,8 +351,7 @@
# total number of attempts is self.retries+1
for attempt in range(self.retries + 1):
# Erase all simulators per each attempt
- if 'simulator' in iossim_util.get_simulator_runtime_by_device_udid(
- self.udid).lower():
+ if iossim_util.is_device_with_udid_simulator(self.udid):
# kill all running simulators to prevent possible memory leaks
test_runner.SimulatorTestRunner.kill_simulators()
shutdown_all_simulators()
@@ -542,7 +541,7 @@
self.sharding_data = [{
'app': self.app_path,
'host': self.host_app_path,
- 'udid': iossim_util.get_simulator(self.platform, self.version),
+ 'udid': self.udid,
'shards': self.shards,
'test_cases': self.test_cases
}]
@@ -711,9 +710,6 @@
self.homedir = ''
self.set_up()
self._init_sharding_data()
- # Destination is required to run tests via xcodebuild on real devices
- # and it looks like id=%ID%
- self.sharding_data[0]['destination'] = 'id=%s' % self.udid
self.start_time = time.strftime('%Y-%m-%d-%H%M%S', time.localtime())
self.test_results['path_delimiter'] = '/'