summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYongqin Liu <yongqin.liu@linaro.org>2017-08-27 20:18:55 +0800
committerYongqin Liu <yongqin.liu@linaro.org>2017-08-27 20:18:55 +0800
commit21d4bc8775498e68df8b59bbbaad9d48d17d3a45 (patch)
tree565a97cf85f1cb2a76bb729cc8886f84ddbf7118
parent8ca8c5b907d7730e541d0aefbeabfc47223ca8b2 (diff)
fix error for running javawhetstone test
Change-Id: Idd6dc4b3423f018e158f4804a7b471f4cc6174e4 Signed-off-by: Yongqin Liu <yongqin.liu@linaro.org>
-rwxr-xr-xautomated/android/apk-automation/apk-automation.sh2
-rwxr-xr-xautomated/android/apk-automation/common/__init__.py39
-rwxr-xr-xautomated/android/apk-automation/javawhetstone.py8
3 files changed, 38 insertions, 11 deletions
diff --git a/automated/android/apk-automation/apk-automation.sh b/automated/android/apk-automation/apk-automation.sh
index 5c4368a..6ea943d 100755
--- a/automated/android/apk-automation/apk-automation.sh
+++ b/automated/android/apk-automation/apk-automation.sh
@@ -39,7 +39,7 @@ if [ "${SKIP_INSTALL}" = "true" ] || [ "${SKIP_INSTALL}" = "True" ]; then
info_msg "Package installation skipped"
else
! check_root && error_msg "Please run this script as superuser!"
- install_deps "git python python-lxml python-pil python-setuptools curl tar xz-utils ca-certificates requests" "${SKIP_INSTALL}"
+ install_deps "git python python-lxml python-pil python-setuptools python-requests ca-certificates curl tar xz-utils" "${SKIP_INSTALL}"
git clone https://github.com/dtmilano/AndroidViewClient
(
cd AndroidViewClient/ || exit
diff --git a/automated/android/apk-automation/common/__init__.py b/automated/android/apk-automation/common/__init__.py
index 963463e..9948c5b 100755
--- a/automated/android/apk-automation/common/__init__.py
+++ b/automated/android/apk-automation/common/__init__.py
@@ -191,19 +191,38 @@ class ApkTestRunner(object):
sys.exit(1)
def download_apk(self, apk_name):
- # create directory for downloaded files
- if not os.path.isdir(os.path.abspath(self.config['apk_dir'])):
- os.makedirs(os.path.abspath(self.config['apk_dir']))
-
# download APK if not already downloaded
apk_path = os.path.join(os.path.abspath(self.config['apk_dir']), apk_name)
if not os.path.isfile(apk_path):
- apk_url = urlparse.urljoin(self.config['base_url'], apk_name)
- r = requests.get(apk_url, stream=True)
- if r.status_code == 200:
- with open(apk_path, 'wb') as f:
- r.raw.decode_content = True
- shutil.copyfileobj(r.raw, f)
+ # create directory for downloaded files
+ if not os.path.exists(os.path.dirname(apk_path)):
+ os.makedirs(os.path.dirname(apk_path))
+
+ if self.config['base_url'].startswith("scp://"):
+ # like scp://user@host:/abs_path
+ base_url = self.config['base_url']
+
+ remote_dir = base_url.split(":")[2]
+ user_host = base_url.split(":")[1].replace("/", "")
+ host = user_host.split("@")[1]
+ user = user_host.split("@")[0]
+
+ remote_path = "%s/%s" %(remote_dir, apk_name)
+ scp_cmdline = "scp %s@%s:%s %s" %(user, host, remote_path, apk_path)
+ ret = os.system(scp_cmdline)
+ if ret != 0:
+ self.logger.info('Failed to run scp command: %s' % scp_cmdline)
+ sys.exit(1)
+ else:
+ apk_url = urlparse.urljoin(self.config['base_url'], apk_name)
+ r = requests.get(apk_url, stream=True)
+ if r.status_code == 200:
+ with open(apk_path, 'wb') as f:
+ r.raw.decode_content = True
+ shutil.copyfileobj(r.raw, f)
+ else:
+ self.logger.info('Failed to download file: %s' % apk_url)
+ sys.exit(1)
def install_apk(self, apk_name):
apk_path = os.path.join(os.path.abspath(self.config['apk_dir']), apk_name)
diff --git a/automated/android/apk-automation/javawhetstone.py b/automated/android/apk-automation/javawhetstone.py
index a5d974d..2702b24 100755
--- a/automated/android/apk-automation/javawhetstone.py
+++ b/automated/android/apk-automation/javawhetstone.py
@@ -12,6 +12,14 @@ class ApkRunnerImpl(ApkTestRunner):
self.config['activity'] = 'com.roywhet/.JavaWhetstoneActivity'
super(ApkRunnerImpl, self).__init__(self.config)
+ def setUp(self):
+ self.call_adb('shell setenforce 0')
+ super(ApkRunnerImpl, self).setUp()
+
+ def tearDown(self):
+ self.call_adb('shell setenforce 1')
+ super(ApkRunnerImpl, self).tearDown()
+
def execute(self):
self.dump_always()
btn_run = self.vc.findViewByIdOrRaise("com.roywhet:id/startButton")