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
diff --git a/test/testrunner/testrunner.py b/test/testrunner/testrunner.py
index 9a437cc..c99159f 100755
--- a/test/testrunner/testrunner.py
+++ b/test/testrunner/testrunner.py
@@ -828,7 +828,15 @@
     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()