summaryrefslogtreecommitdiff
path: root/emu_test
diff options
context:
space:
mode:
authorYing Chen <chying@google.com>2015-12-02 17:05:48 -0800
committerYing Chen <chying@google.com>2015-12-04 10:25:07 -0800
commit53a2da82e531082e1624bbdc206699396be580a9 (patch)
treec0dcf274711fef200252f45e39d23e23361522cf /emu_test
parentd35a2511bd441de9e406ff11f2cfccd2e50426d5 (diff)
downloadadt-infra-53a2da82e531082e1624bbdc206699396be580a9.tar.gz
Add support for top of tree system images
- Add column ranchu to test config file to indicate qemu2 test lines - Create gs change source to monitor multiple gs locations - Include mnc/lmp tests in recipe - Update recipe test and expected files Change-Id: I229e908fb005bfb19e7e2c8a8a74d1eedb0bac61
Diffstat (limited to 'emu_test')
-rw-r--r--emu_test/config/boot_cfg.csv97
-rw-r--r--emu_test/test_boot/test_boot.py39
-rw-r--r--emu_test/utils/download_unzip_image.py62
-rw-r--r--emu_test/utils/emu_argparser.py6
-rw-r--r--emu_test/utils/emu_error.py81
-rw-r--r--emu_test/utils/emu_testcase.py9
6 files changed, 195 insertions, 99 deletions
diff --git a/emu_test/config/boot_cfg.csv b/emu_test/config/boot_cfg.csv
index 20bafded..3a40bb23 100644
--- a/emu_test/config/boot_cfg.csv
+++ b/emu_test/config/boot_cfg.csv
@@ -1,49 +1,48 @@
-Device Config,,,,,,Linux,,,,Windows,,,,,MacOSX,,,
-API*,Tag*,ABI*,Device,RAM,GPU,Ubuntu 12.04 HD Graphics 4000,Ubuntu 14.04 HD 4400,Ubuntu 14.04 Quadro 600,Ubuntu 15.04 Quadro K600,Win 7 32-bit HD 4400,Win 7 64-bit HD 4400,Win 8 64-bit Quadro 600,Win 8.1 64-bit Quadro 600,Win 10 64-bit Quadro 600,Mac 10.10.5 Intel HD 5000,Mac 10.10.5 Iris Pro,Mac 10.8.5 Intel HD 5000,Mac 10.11.1 Iris Pro
-API 23,android-tv,armeabi-v7a,,,,,,P,,,,,,,,,,
-,,x86,,,,,,P,,,,,,,,,,
-,default,armeabi-v7a,Nexus 6,2048,yes,P,P,P,P,P,P,P,P,P,P,P,P,P
-,,x86,Nexus 6,2048,yes,P,P,P,P,P,P,P,P,P,P,P,P,P
-,,x86,Nexus 5,2048,yes,P,P,P,P,P,P,P,P,P,P,P,P,P
-,,x86_64,Nexus 5,2048,yes,P,P,P,P,S,P,P,P,P,X,X,X,X
-,google_apis,armeabi-v7a,Galaxy Nexus,2048,yes,,,P,,,,,,,,,,
-,,x86,,,,,,P,,,,,,,,,,
-,,x86_64,,,,,,P,,,,,,,,,,
-API 22,android-tv,armeabi-v7a,Android TV (1080p),2048,yes,,,P,,,,,,,,,,
-,,x86,Android TV (1080p),2048,yes,,,P,,,,,,,,,,
-,android-wear,armeabi-v7a,wear_square_320,1024,yes,,,P,,,,,,,,,,
-,,x86,,,,,,P,,,,,,,,,,
-,default,armeabi-v7a,,,,,,P,,,,,,,,,,
-,,x86,,,,,,P,,,,,,,,,,
-,,x86_64,,,,,,P,,,,,,,,,,
-,google_apis,armeabi-v7a,,,,,,P,,,,,,,,,,
-,,x86,,,,,,P,,,,,,,,,,
-,,x86_64,,,,,,P,,,,,,,,,,
-API 21,android-tv,armeabi-v7a,,,,,,P,,,,,,,,,,
-,,x86,,,,,,P,,,,,,,,,,
-,android-wear,armeabi-v7a,,,,,,P,,,,,,,,,,
-,,x86,,,,,,P,,,,,,,,,,
-,default,armeabi-v7a,,,,P,P,P,P,P,,P,P,P,P,P,P,P
-,,x86,,,,P,P,P,P,P,P,P,P,P,P,P,P,P
-,,x86_64,,,,P,P,P,P,S,,P,P,P,X,X,X,X
-,google_apis,armeabi-v7a,,,,,,P,,,,,,,,,,
-,,x86,,,,,,P,,,,,,,,,,
-,,x86_64,,,,,,P,,,,,,,,,,
-API 20,android-wear,armeabi-v7a,,,,,,P,,,,,,,,,,
-,,x86,,,,,,P,,,,,,,,,,
-API 19,default,armeabi-v7a,,,,,,P,,,,,,,,,,
-,,x86,,,,,,P,,,,,,,,,,
-,google_apis,armeabi-v7a,,,,,,,,,,,,,,,,
-,,x86,,,,,,,,,,,,,,,,
-API 18,default,armeabi-v7a,,,,,,P,,,,,,,,,,
-,,x86,,,,,,P,,,,,,,,,,
-API 17,default,armeabi-v7a,,,,,,P,,,,,,,,,,
-,,mips,,,,,,P,,,,,,,,,,
-,,x86,,,,,,P,,,,,,,,,,
-API 16,default,armeabi-v7a,Nexus 4,1024,yes,P,P,P,P,,,P,P,P,P,P,P,P
-,,mips,Nexus 4,1024,yes,P,P,P,P,,,P,P,P,P,P,P,P
-,,x86,Nexus 4,1024,yes,P,P,P,P,,,P,P,P,X,X,X,X
-API 15,default,armeabi-v7a,,,no,,,P,,,,,,,,,,
-,,mips,,,no,,,P,,,,,,,,,,
-,,x86,,,no,,,P,,,,,,,,,,
-API 10,default,x86,,,no,P,P,P,P,,,P,P,P,P,P,P,P \ No newline at end of file
+Device Config,,,,,,,Linux,,,,Windows,,,,,MacOSX,,,
+API*,TAG*,ABI*,DEVICE,RAM,GPU,TOT IMAGE,Ubuntu 12.04 HD Graphics 4000,Ubuntu 14.04 HD 4400,Ubuntu 14.04 Quadro 600,Ubuntu 15.04 Quadro K600,Win 7 32-bit HD 4400,Win 7 64-bit HD 4400,Win 8 64-bit Quadro 600,Win 8.1 64-bit Quadro 600,Win 10 64-bit Quadro 600,Mac 10.10.5 Intel HD 5000,Mac 10.10.5 Iris Pro,Mac 10.8.5 Intel HD 5000,Mac 10.11.1 Iris Pro
+API 23,android-tv,armeabi-v7a,,,,,,,P,,,,,,,,,,
+,,x86,,,,,,,P,,,,,,,,,,
+,default,armeabi-v7a,Nexus 6,2048,yes,,P,P,P,P,P,,P,P,P,P,P,P,P
+,,x86,Nexus 5,2048,yes,yes,P,P,P,P,P,P,P,P,P,P,P,P,P
+,,x86_64,Nexus 5,2048,yes,yes,P,P,P,P,S,P,P,P,P,P,P,P,P
+,google_apis,armeabi-v7a,Galaxy Nexus,2048,yes,,,,P,,,,,,,,,,
+,,x86,Nexus 5,2048,yes,yes,P,P,P,P,P,P,P,P,P,P,P,P,P
+,,x86_64,Nexus 5,2048,yes,yes,P,P,P,P,S,P,P,P,P,P,P,P,P
+API 22,android-tv,armeabi-v7a,Android TV (1080p),2048,yes,,,,P,,,,,,,,,,
+,,x86,Android TV (1080p),2048,yes,,,,P,,,,,,,,,,
+,android-wear,armeabi-v7a,wear_square_320,1024,yes,,,,P,,,,,,,,,,
+,,x86,,,,,,,P,,,,,,,,,,
+,default,armeabi-v7a,,,,,,,P,,,,,,,,,,
+,,x86,Nexus 5,2048,yes,yes,P,P,P,P,P,P,P,P,P,P,P,P,P
+,,x86_64,Nexus 5,2048,yes,yes,P,P,P,P,S,P,P,P,P,P,P,P,P
+,google_apis,armeabi-v7a,,,,,,,P,,,,,,,,,,
+,,x86,Nexus 5,2048,yes,yes,P,P,P,P,P,P,P,P,P,P,P,P,P
+,,x86_64,Nexus 5,2048,yes,yes,P,P,P,P,S,P,P,P,P,P,P,P,P
+API 21,android-tv,armeabi-v7a,,,,,,,P,,,,,,,,,,
+,,x86,,,,,,,P,,,,,,,,,,
+,android-wear,armeabi-v7a,,,,,,,P,,,,,,,,,,
+,,x86,,,,,,,P,,,,,,,,,,
+,default,armeabi-v7a,,,,,P,P,P,P,P,,P,P,P,P,P,P,P
+,,x86,,,,,P,P,P,P,P,P,P,P,P,P,P,P,P
+,,x86_64,,,,,P,P,P,P,S,,P,P,P,X,X,X,X
+,google_apis,armeabi-v7a,,,,,,,P,,,,,,,,,,
+,,x86,,,,,,,P,,,,,,,,,,
+,,x86_64,,,,,,,P,,,,,,,,,,
+API 20,android-wear,armeabi-v7a,,,,,,,P,,,,,,,,,,
+,,x86,,,,,,,P,,,,,,,,,,
+API 19,default,armeabi-v7a,,,,,,,P,,,,,,,,,,
+,,x86,,,,,,,P,,,,,,,,,,
+,google_apis,armeabi-v7a,,,,,,,,,,,,,,,,,
+,,x86,,,,,,,,,,,,,,,,,
+API 18,default,armeabi-v7a,,,,,,,P,,,,,,,,,,
+,,x86,,,,,,,P,,,,,,,,,,
+API 17,default,armeabi-v7a,,,,,,,P,,,,,,,,,,
+,,mips,,,,,,,P,,,,,,,,,,
+,,x86,,,,,,,P,,,,,,,,,,
+API 16,default,armeabi-v7a,Nexus 4,1024,yes,,P,P,P,P,,,P,P,P,P,P,P,P
+,,mips,Nexus 4,1024,yes,,P,P,P,P,,,P,P,P,P,P,P,P
+,,x86,Nexus 4,1024,yes,,P,P,P,P,,,P,P,P,X,X,X,X
+API 15,default,armeabi-v7a,,,no,,,,P,,,,,,,,,,
+,,mips,,,no,,,,P,,,,,,,,,,
+,,x86,,,no,,,,P,,,,,,,,,,
+API 10,default,x86,,,no,,P,P,P,P,,,P,P,P,P,P,P,P \ No newline at end of file
diff --git a/emu_test/test_boot/test_boot.py b/emu_test/test_boot/test_boot.py
index 0542a77e..4b4bf715 100644
--- a/emu_test/test_boot/test_boot.py
+++ b/emu_test/test_boot/test_boot.py
@@ -53,12 +53,30 @@ class BootTestCase(EmuBaseTestCase):
def run_boot_test(self, avd_config):
self.avd_config = avd_config
self.assertEqual(self.create_avd(avd_config), 0)
- self.boot_check(str(avd_config))
+ self.boot_check(avd_config)
def create_test_case_from_file():
+ """ Create test case based on test configuration file. """
- def create_test_case(avd_config):
- return lambda self: self.run_boot_test(avd_config)
+ def valid_case(avd_config):
+ if emu_args.filter_dict is not None:
+ for key, value in emu_args.filter_dict.iteritems():
+ if getattr(avd_config, key) != value:
+ return False
+ return True
+
+ def create_test_case(avd_config, op):
+ if op == "S" or op == "" or not valid_case(avd_config):
+ return
+
+ func = lambda self: self.run_boot_test(avd_config)
+ if op == "X":
+ func = unittest.expectedFailure(func)
+ # TODO: handle flakey tests
+ elif op == "F":
+ func = func
+ qemu_str = "_qemu2" if avd_config.ranchu == "yes" else ""
+ setattr(BootTestCase, "test_boot_%s%s" % (str(avd_config), qemu_str), func)
with open(emu_args.config_file, "rb") as file:
reader = csv.reader(file)
@@ -93,12 +111,15 @@ def create_test_case_from_file():
# For 32 bit machine, ram should be less than 768MB
if not platform.machine().endswith('64'):
ram = str(min([int(ram), 768]))
- avd_config = AVDConfig(api, tag, abi, device, ram, gpu)
- if op == "X":
- setattr(BootTestCase, "test_boot_%s" % str(avd_config),
- unittest.expectedFailure(create_test_case(avd_config)))
- else:
- setattr(BootTestCase, "test_boot_%s" % str(avd_config), create_test_case(avd_config))
+ if api < "22" and row[6] == "yes":
+ raise ConfigError()
+ tot_image = row[6] if row[6] == "yes" else "no"
+ avd_config = AVDConfig(api, tag, abi, device, ram, gpu, tot_image, ranchu="no")
+ create_test_case(avd_config, op)
+ # for unreleased images, test with qemu2 in addition
+ if tot_image == "yes":
+ avd_config = AVDConfig(api, tag, abi, device, ram, gpu, tot_image, ranchu="yes")
+ create_test_case(avd_config, op)
def create_test_case_for_avds():
avd_list = emu_args.avd_list
diff --git a/emu_test/utils/download_unzip_image.py b/emu_test/utils/download_unzip_image.py
new file mode 100644
index 00000000..37d10718
--- /dev/null
+++ b/emu_test/utils/download_unzip_image.py
@@ -0,0 +1,62 @@
+import os
+import argparse
+import subprocess
+
+parser = argparse.ArgumentParser(description='Download and unzip a list of files separated by comma')
+parser.add_argument('--file', dest='remote_file_list', action='store',
+ help='string contains a list of remote files separated by comma')
+parser.add_argument('--dst', dest='dst', action='store',
+ help='local location to store images')
+parser.add_argument('--user', dest='remote_user', action='store',
+ help='remote user name')
+parser.add_argument('--ip', dest='remote_ip', action='store',
+ help='remote ip')
+
+args = parser.parse_args()
+
+
+def get_dst_dir(remote_path):
+ file_name = os.path.basename(remote_path)
+ if file_name.startswith('sdk-repo-linux-system-images'):
+ branch_name = remote_path.split('/')[-2]
+ if 'google_phone' in branch_name:
+ tag = 'google_apis'
+ else:
+ tag = 'default'
+ if 'lmp' in branch_name:
+ api = '22'
+ elif 'mnc' in branch_name:
+ api = '23'
+ else:
+ raise ValueError("unsupported image %s", branch_name)
+ return os.path.join(os.environ['ANDROID_SDK_ROOT'],
+ "system-images", "android-%s" % api, tag)
+ else:
+ return None
+
+def download_and_unzip():
+ file_list = args.remote_file_list.split(',')
+ dst_dir = get_dst_dir(file_list[0])
+ if dst_dir is not None:
+ subprocess.call(['rm', '-rf', os.path.dirname(dst_dir)])
+
+ for file_path in file_list:
+ file_path = file_path.strip('\n')
+ if file_path == '':
+ continue
+ dst_dir = get_dst_dir(file_path)
+ remote_path = '%s@%s:%s' % (args.remote_user, args.remote_ip, file_path)
+ file_name = os.path.basename(remote_path)
+ subprocess.call(['scp', remote_path, '.'])
+ if dst_dir is not None:
+ subprocess.call(['mkdir', '-p', dst_dir])
+ if 'x86_64' in file_path:
+ subprocess.call(['rm', '-rf', os.path.join(dst_dir,'x86_64')])
+ else:
+ subprocess.call(['rm', '-rf', os.path.join(dst_dir,'x86')])
+ subprocess.call(['unzip', '-o', file_name, '-d', dst_dir])
+ else:
+ subprocess.call(['unzip', '-o', file_name])
+
+if __name__ == "__main__":
+ download_and_unzip()
diff --git a/emu_test/utils/emu_argparser.py b/emu_test/utils/emu_argparser.py
index f5432c95..35da26ad 100644
--- a/emu_test/utils/emu_argparser.py
+++ b/emu_test/utils/emu_argparser.py
@@ -1,6 +1,7 @@
import argparse
+import json
+
emu_args = None
-import re
def get_parser():
parser = argparse.ArgumentParser(description='Argument parser for emu test')
@@ -32,5 +33,8 @@ def get_parser():
parser.add_argument('-n', type=str, dest='builder_name', action='store',
default=None,
help='builder name as appeared in config_file')
+ parser.add_argument('-f', type=json.loads, dest='filter_dict', action='store',
+ default=None,
+ help='json style pattern to filter config_file')
parser.add_argument('unittest_args', nargs='*')
return parser
diff --git a/emu_test/utils/emu_error.py b/emu_test/utils/emu_error.py
index 9ed1f5e2..083ab72c 100644
--- a/emu_test/utils/emu_error.py
+++ b/emu_test/utils/emu_error.py
@@ -1,37 +1,44 @@
-class Error(Exception):
- """Base class for exceptions in this module."""
- pass
-
-class LaunchError(Error):
- """Exception raised for errors in launching emulator
-
- Attributes:
- avd -- avd which failed to launch
- """
-
- def __init__(self, avd):
- self.avd = avd
-
-class TimeoutError(Error):
- """Exception raised for timeout
-
- Attributes:
- cmd -- cmd which timed out
- timeout -- value of timeout
- """
-
- def __init__(self, cmd, timeout):
- self.cmd = cmd
- self.timeout = timeout
-
-class SlowBootError(Error):
- """Exception raised for boot time exceeds expected range
-
- Attributes:
- cmd -- cmd which timed out
- expected_time -- value of expected boot time
- """
-
- def __init__(self, cmd, expected_time):
- self.cmd = cmd
- self.expected_time = expected_time \ No newline at end of file
+class Error(Exception):
+ """Base class for exceptions in this module."""
+ pass
+
+class LaunchError(Error):
+ """Exception raised for errors in launching emulator
+
+ Attributes:
+ avd -- avd which failed to launch
+ """
+
+ def __init__(self, avd):
+ self.avd = avd
+
+class TimeoutError(Error):
+ """Exception raised for timeout
+
+ Attributes:
+ cmd -- cmd which timed out
+ timeout -- value of timeout
+ """
+
+ def __init__(self, cmd, timeout):
+ self.cmd = cmd
+ self.timeout = timeout
+
+class SlowBootError(Error):
+ """Exception raised for boot time exceeds expected range
+
+ Attributes:
+ cmd -- cmd which timed out
+ expected_time -- value of expected boot time
+ """
+
+ def __init__(self, cmd, expected_time):
+ self.cmd = cmd
+ self.expected_time = expected_time
+
+class ConfigError(Error):
+ """Exception raised when configuration file is not valid
+
+ Attributes:
+ """
+ pass
diff --git a/emu_test/utils/emu_testcase.py b/emu_test/utils/emu_testcase.py
index 01ded7b0..673039ea 100644
--- a/emu_test/utils/emu_testcase.py
+++ b/emu_test/utils/emu_testcase.py
@@ -15,7 +15,7 @@ from subprocess import PIPE
from collections import namedtuple
from ConfigParser import ConfigParser
-class AVDConfig(namedtuple('AVDConfig', 'api, tag, abi, device, ram, gpu')):
+class AVDConfig(namedtuple('AVDConfig', 'api, tag, abi, device, ram, gpu, tot_image, ranchu')):
__slots__ = ()
def __str__(self):
device = self.device if self.device != '' else 'defdev'
@@ -106,13 +106,16 @@ class EmuBaseTestCase(LoggedTestCase):
def launch_emu(self, avd):
"""Launch given avd and return immediately"""
exec_path = emu_args.emulator_exec
- launch_cmd = [exec_path, "-avd", avd, "-wipe-data"]
+ launch_cmd = [exec_path, "-avd", str(avd), "-wipe-data"]
+ if avd.ranchu == "yes":
+ launch_cmd += ["-ranchu"]
+
self.m_logger.info('Launching AVD, cmd: %s', ' '.join(launch_cmd))
start_proc = psutil.Popen(launch_cmd, stdout=PIPE, stderr=PIPE)
time.sleep(5)
if start_proc.poll() is not None and start_proc.poll() is not 0:
self.m_logger.error(start_proc.communicate()[1])
- raise LaunchError(avd)
+ raise LaunchError(str(avd))
def launch_emu_and_wait(self, avd):
"""Launch given avd and wait for boot completion, return boot time"""