diff options
| author | 2017-05-09 11:30:47 -0700 | |
|---|---|---|
| committer | 2017-05-09 21:59:46 +0000 | |
| commit | 8fd2694aa1103911baf32eb05813cc11ab00ef4b (patch) | |
| tree | dc4676ee04c436286b3f8dc1046b8c0ec7062e14 | |
| parent | 1a9a9e363b37dd9ff008a0664e7f54431b670e0b (diff) | |
Testrunner: Fix concurrecy for --target
Popen was returning bytes instead of string which was causing the
logic of extracting out concurrency for the target device to break.
Now, the output of the Popen will be converted to string and regex
matching is used instead of string split to better handle the case
when the input string doesn't follow the pattern.
Test: ./art/test/testrunner/testrunner.py --target
Bug: 38130322
Change-Id: I6c2f3070e88e0cbd80a61380f6c4f714e8886b3c
| -rwxr-xr-x | test/testrunner/testrunner.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/test/testrunner/testrunner.py b/test/testrunner/testrunner.py index 9a437cc822..c99159f1ae 100755 --- a/test/testrunner/testrunner.py +++ b/test/testrunner/testrunner.py @@ -828,7 +828,15 @@ def get_default_threads(target): adb_command = 'adb shell cat /sys/devices/system/cpu/present' cpu_info_proc = subprocess.Popen(adb_command.split(), stdout=subprocess.PIPE) cpu_info = cpu_info_proc.stdout.read() - return int(cpu_info.split('-')[1]) + if type(cpu_info) is bytes: + cpu_info = cpu_info.decode('utf-8') + cpu_info_regex = '\d*-(\d*)' + match = re.match(cpu_info_regex, cpu_info) + if match: + return int(match.group(1)) + else: + raise ValueError('Unable to predict the concurrency for the target. ' + 'Is device connected?') else: return multiprocessing.cpu_count() |