From patchwork Thu Oct 27 03:11:12 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael-Doyle Hudson X-Patchwork-Id: 4841 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 3956323E0C for ; Thu, 27 Oct 2011 03:16:42 +0000 (UTC) Received: from mail-fx0-f52.google.com (mail-fx0-f52.google.com [209.85.161.52]) by fiordland.canonical.com (Postfix) with ESMTP id E688EA183B1 for ; Thu, 27 Oct 2011 03:16:41 +0000 (UTC) Received: by faan26 with SMTP id n26so3220937faa.11 for ; Wed, 26 Oct 2011 20:16:41 -0700 (PDT) Received: by 10.223.36.193 with SMTP id u1mr12817594fad.27.1319685401706; Wed, 26 Oct 2011 20:16:41 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.152.1.71 with SMTP id 7cs31228lak; Wed, 26 Oct 2011 20:16:41 -0700 (PDT) Received: by 10.227.198.203 with SMTP id ep11mr13593446wbb.0.1319685073390; Wed, 26 Oct 2011 20:11:13 -0700 (PDT) Received: from indium.canonical.com (indium.canonical.com. [91.189.90.7]) by mx.google.com with ESMTPS id fn7si2575971wbb.102.2011.10.26.20.11.12 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 26 Oct 2011 20:11:13 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of bounces@canonical.com designates 91.189.90.7 as permitted sender) client-ip=91.189.90.7; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of bounces@canonical.com designates 91.189.90.7 as permitted sender) smtp.mail=bounces@canonical.com Received: from ackee.canonical.com ([91.189.89.26]) by indium.canonical.com with esmtp (Exim 4.71 #1 (Debian)) id 1RJGN6-0004b0-FU for ; Thu, 27 Oct 2011 03:11:12 +0000 Received: from ackee.canonical.com (localhost [127.0.0.1]) by ackee.canonical.com (Postfix) with ESMTP id 6C9F8E04E3 for ; Thu, 27 Oct 2011 03:11:12 +0000 (UTC) MIME-Version: 1.0 X-Launchpad-Project: lava-dispatcher X-Launchpad-Branch: ~linaro-validation/lava-dispatcher/trunk X-Launchpad-Message-Rationale: Subscriber X-Launchpad-Branch-Revision-Number: 151 X-Launchpad-Notification-Type: branch-revision To: Linaro Patch Tracker From: noreply@launchpad.net Subject: [Branch ~linaro-validation/lava-dispatcher/trunk] Rev 151: remove old android tests and LavaAndroidClient Message-Id: <20111027031112.23638.84331.launchpad@ackee.canonical.com> Date: Thu, 27 Oct 2011 03:11:12 -0000 Reply-To: noreply@launchpad.net Sender: bounces@canonical.com Errors-To: bounces@canonical.com Precedence: bulk X-Generated-By: Launchpad (canonical.com); Revision="14197"; Instance="launchpad-lazr.conf" X-Launchpad-Hash: e4be5ee480ac282dd73fa1841d1d2610bb02470b Merge authors: Michael Hudson-Doyle (mwhudson) Related merge proposals: https://code.launchpad.net/~mwhudson/lava-dispatcher/eliminate-LavaAndroidClient/+merge/80526 proposed by: Michael Hudson-Doyle (mwhudson) review: Approve - Spring Zhang (qzhang) https://code.launchpad.net/~mwhudson/lava-dispatcher/eliminate-old-android-tests/+merge/80522 proposed by: Michael Hudson-Doyle (mwhudson) ------------------------------------------------------------ revno: 151 [merge] committer: Michael Hudson-Doyle branch nick: trunk timestamp: Thu 2011-10-27 16:06:57 +1300 message: remove old android tests and LavaAndroidClient removed: doc/android-0xbench-job.json doc/android-basic-job.json doc/android-monkey-job.json lava_dispatcher/actions/android_0xbench.py lava_dispatcher/actions/android_basic.py lava_dispatcher/android_client.py lava_dispatcher/android_util.py modified: doc/android-new-kernel.json doc/jobfile.rst lava_dispatcher/__init__.py lava_dispatcher/actions/launch_control.py lava_dispatcher/actions/lava-android-test.py lava_dispatcher/client.py --- lp:lava-dispatcher https://code.launchpad.net/~linaro-validation/lava-dispatcher/trunk You are subscribed to branch lp:lava-dispatcher. To unsubscribe from this branch go to https://code.launchpad.net/~linaro-validation/lava-dispatcher/trunk/+edit-subscription === removed file 'doc/android-0xbench-job.json' --- doc/android-0xbench-job.json 2011-09-13 09:15:07 +0000 +++ doc/android-0xbench-job.json 1970-01-01 00:00:00 +0000 @@ -1,37 +0,0 @@ -{ - "job_name": "android_0xbench_test", - "image_type": "android", - "target": "panda01", - "timeout": 18000, - "actions": [ - { - "command": "deploy_linaro_android_image", - "parameters": - { - "boot": "https://android-build.linaro.org/jenkins/job/linaro-android_leb-panda/61/artifact/build/out/target/product/pandaboard/boot.tar.bz2", - "system": "https://android-build.linaro.org/jenkins/job/linaro-android_leb-panda/61/artifact/build/out/target/product/pandaboard/system.tar.bz2", - "data": "https://android-build.linaro.org/jenkins/job/linaro-android_leb-panda/61/artifact/build/out/target/product/pandaboard/userdata.tar.bz2" - }, - "metadata": - { - "rootfs.type": "android", - "rootfs.build": "61" - } - }, - { - "command": "boot_linaro_android_image" - }, - { - "command": "test_android_0xbench" - }, - { - "command": "submit_results", - "parameters": - { - "server": "http://validation.linaro.org/lava-server/RPC2/", - "stream": "/anonymous/android-panda01-0xbench/", - "result_disk": "sdcard" - } - } - ] -} === removed file 'doc/android-basic-job.json' --- doc/android-basic-job.json 2011-09-13 09:15:07 +0000 +++ doc/android-basic-job.json 1970-01-01 00:00:00 +0000 @@ -1,36 +0,0 @@ -{ - "job_name": "android_basic_test", - "image_type": "android", - "target": "panda01", - "timeout": 18000, - "actions": [ - { - "command": "deploy_linaro_android_image", - "parameters": - { - "boot": "https://android-build.linaro.org/jenkins/job/linaro-android_leb-panda/61/artifact/build/out/target/product/pandaboard/boot.tar.bz2", - "system": "https://android-build.linaro.org/jenkins/job/linaro-android_leb-panda/61/artifact/build/out/target/product/pandaboard/system.tar.bz2", - "data": "https://android-build.linaro.org/jenkins/job/linaro-android_leb-panda/61/artifact/build/out/target/product/pandaboard/userdata.tar.bz2" - }, - "metadata": - { - "rootfs.type": "android", - "rootfs.build": "61" - } - }, - { - "command": "boot_linaro_android_image" - }, - { - "command": "test_android_basic" - }, - { - "command": "submit_results_on_host", - "parameters": - { - "server": "http://validation.linaro.org/lava-server/RPC2/", - "stream": "/anonymous/android-panda01-basic/" - } - } - ] -} === removed file 'doc/android-monkey-job.json' --- doc/android-monkey-job.json 2011-09-13 09:15:07 +0000 +++ doc/android-monkey-job.json 1970-01-01 00:00:00 +0000 @@ -1,36 +0,0 @@ -{ - "job_name": "android_monkey_test", - "image_type": "android", - "target": "panda01", - "timeout": 18000, - "actions": [ - { - "command": "deploy_linaro_android_image", - "parameters": - { - "boot": "https://android-build.linaro.org/jenkins/job/linaro-android_leb-panda/61/artifact/build/out/target/product/pandaboard/boot.tar.bz2", - "system": "https://android-build.linaro.org/jenkins/job/linaro-android_leb-panda/61/artifact/build/out/target/product/pandaboard/system.tar.bz2", - "data": "https://android-build.linaro.org/jenkins/job/linaro-android_leb-panda/61/artifact/build/out/target/product/pandaboard/userdata.tar.bz2" - }, - "metadata": - { - "rootfs.type": "android", - "rootfs.build": "61" - } - }, - { - "command": "boot_linaro_android_image" - }, - { - "command": "test_android_monkey" - }, - { - "command": "submit_results_on_host", - "parameters": - { - "server": "http://validation.linaro.org/lava-server/RPC2/", - "stream": "/anonymous/android-panda01-monkey/" - } - } - ] -} === modified file 'doc/android-new-kernel.json' --- doc/android-new-kernel.json 2011-10-09 03:11:54 +0000 +++ doc/android-new-kernel.json 2011-10-27 00:21:45 +0000 @@ -23,7 +23,18 @@ "command": "boot_linaro_android_image" }, { - "command": "test_android_basic" + "command": "lava_android_test_install", + "parameters": + { + "tests": ["0xbench"] + } + }, + { + "command": "lava_android_test_run", + "parameters": + { + "test_name": "monkey" + } }, { "command": "submit_results_on_host", === modified file 'doc/jobfile.rst' --- doc/jobfile.rst 2011-10-09 07:17:05 +0000 +++ doc/jobfile.rst 2011-10-27 00:21:45 +0000 @@ -108,7 +108,18 @@ "command": "boot_linaro_android_image" }, { - "command": "test_android_basic" + "command": "lava_android_test_install", + "parameters": + { + "tests": ["0xbench"] + } + }, + { + "command": "lava_android_test_run", + "parameters": + { + "test_name": "0xbench" + } }, { "command": "submit_results_on_host", @@ -128,38 +139,50 @@ Here's an example showing how to run 0xbench on a Linaro Android image:: { - "image_type": "android", + "job_name": "android_monkey_test2", + "image_type": "android", + "target": "panda01", + "timeout": 18000, "actions": [ { - "command": "deploy_linaro_android_image", - "parameters": { - "data": "https://android-build.linaro.org/jenkins/job/linaro-android_leb-panda/98/artifact/build/out/target/product/pandaboard/userdata.tar.bz2", - "boot": "https://android-build.linaro.org/jenkins/job/linaro-android_leb-panda/98/artifact/build/out/target/product/pandaboard/boot.tar.bz2", - "system": "https://android-build.linaro.org/jenkins/job/linaro-android_leb-panda/98/artifact/build/out/target/product/pandaboard/system.tar.bz2" - }, - "metadata": { - "android.name": "linaro-android_leb-panda", - "android.build": "98", - "android.url": "https://android-build.linaro.org/builds/~linaro-android/leb-panda/#build=98" - } - }, + "command": "deploy_linaro_android_image", + "parameters": + { + "boot": "https://android-build.linaro.org/jenkins/job/gerrit-bot_pandaboard/12/artifact/build/out/target/product/pandaboard/boot.tar.bz2", + "system": "https://android-build.linaro.org/jenkins/job/gerrit-bot_pandaboard/12/artifact/build/out/target/product/pandaboard/system.tar.bz2", + "data": "https://android-build.linaro.org/jenkins/job/gerrit-bot_pandaboard/12/artifact/build/out/target/product/pandaboard/userdata.tar.bz2" + }, + "metadata": + { + "rootfs.type": "android", + "rootfs.build": "12" + } + }, { "command": "boot_linaro_android_image" - }, - { - "command": "test_android_0xbench" - }, - { - "command": "submit_results", - "parameters": { - "result_disk": "sdcard", - "stream": "/anonymous/android/", - "server": "http://localhost/lava-server/RPC2/" - } + }, + { + "command": "lava_android_test_install", + "parameters": + { + "tests": ["0xbench"] + } + }, + { + "command": "lava_android_test_run", + "parameters": + { + "test_name": "0xbench" + } + }, + { + "command": "submit_results_on_host", + "parameters": + { + "server": "http://validation.linaro.org/lava-server/RPC2/", + "stream": "/anonymous/lava-android-leb-panda/" + } } - ], - "target": "panda01", - "timeout": 18000, - "name": "test job" + ] } === modified file 'lava_dispatcher/__init__.py' --- lava_dispatcher/__init__.py 2011-10-26 02:46:04 +0000 +++ lava_dispatcher/__init__.py 2011-10-27 02:32:02 +0000 @@ -20,6 +20,7 @@ from datetime import datetime import json +import tempfile import traceback from uuid import uuid1 import base64 @@ -28,7 +29,6 @@ from lava_dispatcher.actions import get_all_cmds from lava_dispatcher.config import get_config, get_device_config from lava_dispatcher.client import LavaClient, CriticalError, GeneralError -from lava_dispatcher.android_client import LavaAndroidClient __version__ = "0.3.4" @@ -117,12 +117,10 @@ self.config = dispatcher_config self.job_data = job_data device_config = get_device_config(target) - if image_type == "android": - self._client = LavaAndroidClient(self, device_config) - else: - self._client = LavaClient(self, device_config) + self._client = LavaClient(self, device_config) self.test_data = LavaTestData() self.oob_file = oob_file + self._host_result_dir = None @property def client(self): @@ -141,9 +139,13 @@ return self.config.get("LAVA_IMAGE_URL") @property + def host_result_dir(self): + if self._host_result_dir is None: + self._host_result_dir = tempfile.mkdtemp() + return self._host_result_dir + + @property def lava_result_dir(self): - if isinstance(self.client, LavaAndroidClient): - return self.client.android_result_dir return self.config.get("LAVA_RESULT_DIR") @property === removed file 'lava_dispatcher/actions/android_0xbench.py' --- lava_dispatcher/actions/android_0xbench.py 2011-10-20 04:36:56 +0000 +++ lava_dispatcher/actions/android_0xbench.py 1970-01-01 00:00:00 +0000 @@ -1,53 +0,0 @@ -#!/usr/bin/python - -# Copyright (C) 2011 Linaro Limited -# -# Author: Linaro Validation Team -# -# This file is part of LAVA Dispatcher. -# -# LAVA Dispatcher is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# LAVA Dispatcher is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, see . - -from lava_dispatcher.actions import BaseAction -import time -import pexpect -import logging - -class cmd_test_android_0xbench(BaseAction): - def run(self): - #Make sure in test image now - self.client.in_test_shell() - time.sleep(30) - if not self.client.check_sys_bootup(): - # TODO: Fetch the logcat message as attached - logging.warning("0xbench Test: sys bootup fail, aborted") - return - - self.client.android_logcat_clear() - - package_name = 'org.zeroxlab.benchmark' - class_name = 'org.zeroxlab.benchmark.Benchmark' - cmd = 'am start -n %s/%s --ez math true --ez 2d true --ez 3d true \ - --ez vm true --ez autorun true' % (package_name, class_name) - self.client.run_shell_command(cmd) - - # Do the logcat and monitor the log to know 0xbench done the test - pattern = "Displayed org.zeroxlab.benchmark/.Report" - try: - self.client.android_logcat_monitor(pattern, timeout = 1200) - except pexpect.TIMEOUT: - logging.warning("0xbench Test: TIMEOUT Fail") - raise - finally: - self.client.android_logcat_stop() === removed file 'lava_dispatcher/actions/android_basic.py' --- lava_dispatcher/actions/android_basic.py 2011-10-26 02:59:28 +0000 +++ lava_dispatcher/actions/android_basic.py 1970-01-01 00:00:00 +0000 @@ -1,150 +0,0 @@ -#!/usr/bin/python - -# Copyright (C) 2011 Linaro Limited -# -# Author: Linaro Validation Team -# -# This file is part of LAVA Dispatcher. -# -# LAVA Dispatcher is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# LAVA Dispatcher is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, see . - -from lava_dispatcher.actions import BaseAction -import time -import pexpect -import logging -from datetime import datetime -from lava_dispatcher.android_util import savebundlefile - -class cmd_test_android_monkey(BaseAction): - def run(self): - #Make sure in test image now - self.client.in_test_shell() - time.sleep(30) - if not self.client.check_sys_bootup(): - # TODO: Fetch the logcat message as attachment - logging.warning("monkey run test skipped: sys bootup fail") - return - - TIMEFORMAT = '%Y-%m-%dT%H:%M:%SZ' - starttime = datetime.utcnow() - timestring = datetime.strftime(starttime, TIMEFORMAT) - results = {'test_results':[]} - - result_pattern = '## Network stats: elapsed time=(?P\d+)ms' - test_case_result = {} - test_case_result['test_case_id'] = "monkey-1" - test_case_result['units'] = "mseconds" - cmd = 'monkey -s 1 --pct-touch 10 --pct-motion 20 --pct-nav 20 --pct-majornav 30 --pct-appswitch 20 --throttle 500 50' - self.client.proc.sendline(cmd) - try: - id = self.client.proc.expect([result_pattern, pexpect.EOF], timeout = 60) - if id == 0: - match_group = self.client.proc.match.groups() - test_case_result['measurement'] = int(match_group[0]) - test_case_result['result'] = "pass" - else: - test_case_result['result'] = "fail" - except pexpect.TIMEOUT: - test_case_result['result'] = "fail" - - results['test_results'].append(test_case_result) - savebundlefile("monkey", results, timestring, self.context.lava_result_dir) - self.client.proc.sendline("") - - -class cmd_test_android_basic(BaseAction): - def run(self): - #Make sure in test image now - self.client.in_test_shell() - - #TODO: Checking if sdcard is mounted by vold to replace sleep idle, or check the Home app status - # Give time for Android system to boot up, then test - time.sleep(60) - TIMEFORMAT = '%Y-%m-%dT%H:%M:%SZ' - starttime = datetime.utcnow() - timestring = datetime.strftime(starttime, TIMEFORMAT) - results = {'test_results':[]} - - # Check booting completeness - # Transfer the result to launch-control json representation - result_pattern = "([0-1])" - test_case_result = {} - test_case_result['test_case_id'] = "dev.bootcomplete" - cmd = "getprop dev.bootcomplete" - self.client.proc.sendline(cmd) - id = self.client.proc.expect([result_pattern, pexpect.EOF], timeout = 5) - if id == 0: - match_group = self.client.proc.match.groups() - test_case_result['measurement'] = int(match_group[0]) - if test_case_result['measurement'] == 1: - test_case_result['result'] = "pass" - else: - test_case_result['result'] = "fail" - else: - test_case_result['measurement'] = "" - test_case_result['result'] = "unknown" - results['test_results'].append(test_case_result) - - test_case_result = {} - test_case_result['test_case_id'] = "sys.boot_completed" - cmd = "getprop sys.boot_completed" - self.client.proc.sendline(cmd) - try: - id = self.client.proc.expect([result_pattern, pexpect.EOF], timeout = 5) - if id == 0: - match_group = self.client.proc.match.groups() - test_case_result['measurement'] = int(match_group[0]) - if test_case_result['measurement'] == 1: - test_case_result['result'] = "pass" - else: - test_case_result['result'] = "fail" - else: - test_case_result['result'] = "unknown" - except: - logging.exception("getprop sys.boot_completed failed") - test_case_result['result'] = "fail" - pass - - results['test_results'].append(test_case_result) - - result_pattern = "(running)" - test_case_result = {} - test_case_result['test_case_id'] = "init.svc.adbd" - cmd = "getprop init.svc.adbd" - self.client.proc.sendline(cmd) - id = self.client.proc.expect([result_pattern, pexpect.EOF], timeout = 5) - if id == 0: - match_group = self.client.proc.match.groups() - test_case_result['message'] = match_group[0] - if test_case_result['message'] == "running": - test_case_result['result'] = "pass" - else: - test_case_result['result'] = "fail" - else: - test_case_result['result'] = "unknown" - results['test_results'].append(test_case_result) - - #TODO: Wait for boot completed, if timeout, do logcat and save as booting fail log - - adb_status = self.client.check_adb_status() - test_case_result = {} - test_case_result['test_case_id'] = "adb connection status" - if adb_status: - test_case_result['result'] = "pass" - else: - test_case_result['result'] = "fail" - - results['test_results'].append(test_case_result) - savebundlefile("basic", results, timestring, self.context.lava_result_dir) - self.client.proc.sendline("") === modified file 'lava_dispatcher/actions/launch_control.py' --- lava_dispatcher/actions/launch_control.py 2011-10-26 02:46:04 +0000 +++ lava_dispatcher/actions/launch_control.py 2011-10-27 02:28:52 +0000 @@ -77,9 +77,9 @@ status = 'pass' err_msg = '' try: - bundle_list = os.listdir(self.context.lava_result_dir) + bundle_list = os.listdir(self.context.host_result_dir) for bundle_name in bundle_list: - bundle = "%s/%s" % (self.context.lava_result_dir, bundle_name) + bundle = "%s/%s" % (self.context.host_result_dir, bundle_name) bundlename_list.append(bundle) f = open(bundle) content = f.read() @@ -94,7 +94,7 @@ for bundle in bundlename_list: os.remove(bundle) - shutil.rmtree(self.context.lava_result_dir) + shutil.rmtree(self.context.host_result_dir) if status == 'fail': raise OperationFailed(err_msg) === modified file 'lava_dispatcher/actions/lava-android-test.py' --- lava_dispatcher/actions/lava-android-test.py 2011-10-13 01:42:17 +0000 +++ lava_dispatcher/actions/lava-android-test.py 2011-10-27 02:28:52 +0000 @@ -72,7 +72,7 @@ dev_name = self.is_ready_for_test() bundle_name = test_name + "-" + datetime.now().strftime("%H%M%S") cmd = 'lava-android-test run %s -s %s -o %s/%s.bundle' % ( - test_name, dev_name, self.context.lava_result_dir, bundle_name) + test_name, dev_name, self.context.host_result_dir, bundle_name) rc = pexpect.run(cmd, timeout=None, logfile=sys.stdout, withexitstatus=True)[1] if rc != 0: === removed file 'lava_dispatcher/android_client.py' --- lava_dispatcher/android_client.py 2011-10-26 02:59:28 +0000 +++ lava_dispatcher/android_client.py 1970-01-01 00:00:00 +0000 @@ -1,186 +0,0 @@ -# Copyright (C) 2011 Linaro Limited -# -# Author: Linaro Validation Team -# -# This file is part of LAVA Dispatcher. -# -# LAVA Dispatcher is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# LAVA Dispatcher is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, see . - -import logging -import os -import pexpect -import sys -from tempfile import mkdtemp -import time - -from lava_dispatcher.client import LavaClient, NetworkError, GeneralError -from lava_dispatcher.utils import string_to_list - - -class LavaAndroidClient(LavaClient): - """ - LavaAndroidClient manipulates the board running Android system, bootup, - reset, power off the board, sends commands to board to execute - """ - def __init__(self, context, config): - LavaClient.__init__(self, context, config) - # use a random result directory on android for they are using same host - self.android_result_dir = mkdtemp() - os.chmod(self.android_result_dir, 0755) - - def run_adb_shell_command(self, dev_id, cmd, response, timeout=-1): - adb_cmd = "adb -s %s shell %s" % (dev_id, cmd) - try: - adb_proc = pexpect.spawn(adb_cmd, logfile=sys.stdout) - match_id = adb_proc.expect([response, pexpect.EOF], timeout=timeout) - if match_id == 0: - return True - except pexpect.TIMEOUT: - pass - return False - - def boot_linaro_android_image(self): - """Reboot the system to the test android image.""" - self._boot(string_to_list(self.config.get('boot_cmds_android'))) - self.in_test_shell() - self.proc.sendline("export PS1=\"root@linaro: \"") - - self.enable_adb_over_tcpip() - self.android_adb_disconnect_over_default_nic_ip() - - def android_logcat_clear(self): - cmd = "logcat -c" - self.proc.sendline(cmd) - - def _android_logcat_start(self): - cmd = "logcat" - self.proc.sendline(cmd) - - def android_logcat_monitor(self, pattern, timeout= -1): - self.android_logcat_stop() - cmd = 'logcat' - self.proc.sendline(cmd) - match_id = self.proc.expect(pattern, timeout=timeout) - if match_id == 0: - return True - else: - return False - - def android_logcat_stop(self): - self.proc.sendcontrol('C') - logging.info("logcat cancelled") - - # adb cound be connected through network - def android_adb_connect(self, dev_ip): - pattern1 = "connected to (\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}:\d{1,5})" - pattern2 = "already connected to (\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}:\d{1,5})" - pattern3 = "unable to connect to" - - cmd = "adb connect %s" % dev_ip - adb_proc = pexpect.spawn(cmd, timeout=300, logfile=sys.stdout) - match_id = adb_proc.expect([pattern1, pattern2, pattern3, pexpect.EOF]) - if match_id == 0 or match_id == 1: - dev_name = adb_proc.match.groups()[0] - return dev_name - else: - return None - - def android_adb_disconnect(self, dev_ip): - cmd = "adb disconnect %s" % dev_ip - pexpect.run(cmd, timeout=300, logfile=sys.stdout) - - def check_adb_status(self): - device_ip = self.get_default_nic_ip() - if device_ip is not None: - dev_name = self.android_adb_connect(device_ip) - if dev_name is not None: - logging.info("dev_name = " + dev_name) - result = self.run_adb_shell_command(dev_name, "echo 1", "1") - self.android_adb_disconnect(device_ip) - return result - return False - - def get_default_nic_ip(self): - # XXX: IP could be assigned in other way in the validation farm - network_interface = self.default_network_interface - ip = None - try: - ip = self._get_default_nic_ip_by_ifconfig(network_interface) - except: - logging.exception("_get_default_nic_ip_by_ifconfig failed") - pass - - if ip is None: - self.get_ip_via_dhcp(network_interface) - ip = self._get_default_nic_ip_by_ifconfig(network_interface) - return ip - - def _get_default_nic_ip_by_ifconfig(self, nic_name): - # Check network ip and setup adb connection - ip_pattern = "%s: ip (\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}) mask" % nic_name - cmd = "ifconfig %s" % nic_name - self.proc.sendline('') - self.proc.sendline(cmd) - match_id = 0 - try: - match_id = self.proc.expect([ip_pattern, pexpect.EOF], timeout=60) - except Exception as e: - raise NetworkError("ifconfig can not match ip pattern for %s:%s" % (nic_name, e)) - - if match_id == 0: - match_group = self.proc.match.groups() - if len(match_group) > 0: - return match_group[0] - return None - - def get_ip_via_dhcp(self, nic): - try: - self.run_cmd_tester('netcfg %s dhcp' % nic, timeout=60) - except: - logging.exception("netcfg %s dhcp failed" % nic) - raise NetworkError("netcfg %s dhcp exception" % nic) - - - def android_adb_connect_over_default_nic_ip(self): - dev_ip = self.get_default_nic_ip() - if dev_ip is not None: - return self.android_adb_connect(dev_ip) - - def android_adb_disconnect_over_default_nic_ip(self): - dev_ip = self.get_default_nic_ip() - if dev_ip is not None: - self.android_adb_disconnect(dev_ip) - - def enable_adb_over_tcpip(self): - self.proc.sendline('echo 0>/sys/class/android_usb/android0/enable') - self.proc.sendline('setprop service.adb.tcp.port 5555') - self.proc.sendline('stop adbd') - self.proc.sendline('start adbd') - - def wait_home_screen(self): - cmd = 'getprop init.svc.bootanim' - for count in range(100): - self.proc.sendline(cmd) - match_id = self.proc.expect('stopped') - if match_id == 0: - return True - time.sleep(1) - raise GeneralError('The home screen does not displayed') - - def check_sys_bootup(self): - result_pattern = "([0-1])" - cmd = "getprop sys.boot_completed" - self.proc.sendline(cmd) - match_id = self.proc.expect([result_pattern], timeout = 60) - return match_id == 0 === removed file 'lava_dispatcher/android_util.py' --- lava_dispatcher/android_util.py 2011-08-10 18:01:25 +0000 +++ lava_dispatcher/android_util.py 1970-01-01 00:00:00 +0000 @@ -1,50 +0,0 @@ -# Copyright (C) 2011 Linaro Limited -# -# Author: Linaro Validation Team -# -# This file is part of LAVA Dispatcher. -# -# LAVA Dispatcher is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# LAVA Dispatcher is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, see . - -import os -from uuid import uuid1 -from datetime import datetime -import json -import subprocess -import time - -# TODO: Result saving could be replaced by linaro_dashboard_bundle probably. -def savebundlefile(testname, results, starttime, lava_result_dir): - """ - Save results as .bundle file under /tmp/LAVA_RESULT_DIR/ - """ - TIMEFORMAT = '%Y-%m-%dT%H:%M:%SZ' - testdata = {} - test_runs = [{}] - testdata['format'] = "Dashboard Bundle Format 1.2" - test_runs[0]['test_id'] = testname - test_runs[0]['analyzer_assigned_uuid'] = str(uuid1()) - test_runs[0]['time_check_performed'] = False - test_runs[0]['analyzer_assigned_date'] = starttime - # TODO: hw_context sw_context for android - testdata['test_runs'] = test_runs - testdata['test_runs'][0].update(results) - bundle = testdata - subprocess.call(["mkdir", "-p", "/tmp/%s" % lava_result_dir]) - # The file name should be unique to be distinguishable from others - filename = "/tmp/%s/" % lava_result_dir + testname + \ - str(time.mktime(datetime.utcnow().timetuple())) + ".bundle" - with open(filename, "wt") as stream: - json.dump(bundle, stream) - === modified file 'lava_dispatcher/client.py' --- lava_dispatcher/client.py 2011-10-26 03:24:05 +0000 +++ lava_dispatcher/client.py 2011-10-27 01:09:17 +0000 @@ -224,6 +224,104 @@ while (index == 0): index = self.proc.expect (['.+', pexpect.EOF, pexpect.TIMEOUT], timeout=1) + # Android stuff + + def boot_linaro_android_image(self): + """Reboot the system to the test android image.""" + self._boot(string_to_list(self.config.get('boot_cmds_android'))) + self.in_test_shell() + self.proc.sendline("export PS1=\"root@linaro: \"") + + self.enable_adb_over_tcpip() + self.android_adb_disconnect_over_default_nic_ip() + + # adb cound be connected through network + def android_adb_connect(self, dev_ip): + pattern1 = "connected to (\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}:\d{1,5})" + pattern2 = "already connected to (\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}:\d{1,5})" + pattern3 = "unable to connect to" + + cmd = "adb connect %s" % dev_ip + adb_proc = pexpect.spawn(cmd, timeout=300, logfile=sys.stdout) + match_id = adb_proc.expect([pattern1, pattern2, pattern3, pexpect.EOF]) + if match_id == 0 or match_id == 1: + dev_name = adb_proc.match.groups()[0] + return dev_name + else: + return None + + def android_adb_disconnect(self, dev_ip): + cmd = "adb disconnect %s" % dev_ip + pexpect.run(cmd, timeout=300, logfile=sys.stdout) + + def get_default_nic_ip(self): + # XXX: IP could be assigned in other way in the validation farm + network_interface = self.default_network_interface + ip = None + try: + ip = self._get_default_nic_ip_by_ifconfig(network_interface) + except: + logging.exception("_get_default_nic_ip_by_ifconfig failed") + pass + + if ip is None: + self.get_ip_via_dhcp(network_interface) + ip = self._get_default_nic_ip_by_ifconfig(network_interface) + return ip + + def _get_default_nic_ip_by_ifconfig(self, nic_name): + # Check network ip and setup adb connection + ip_pattern = "%s: ip (\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}) mask" % nic_name + cmd = "ifconfig %s" % nic_name + self.proc.sendline('') + self.proc.sendline(cmd) + match_id = 0 + try: + match_id = self.proc.expect([ip_pattern, pexpect.EOF], timeout=60) + except Exception as e: + raise NetworkError("ifconfig can not match ip pattern for %s:%s" % (nic_name, e)) + + if match_id == 0: + match_group = self.proc.match.groups() + if len(match_group) > 0: + return match_group[0] + return None + + def get_ip_via_dhcp(self, nic): + try: + self.run_cmd_tester('netcfg %s dhcp' % nic, timeout=60) + except: + logging.exception("netcfg %s dhcp failed" % nic) + raise NetworkError("netcfg %s dhcp exception" % nic) + + + def android_adb_connect_over_default_nic_ip(self): + dev_ip = self.get_default_nic_ip() + if dev_ip is not None: + return self.android_adb_connect(dev_ip) + + def android_adb_disconnect_over_default_nic_ip(self): + dev_ip = self.get_default_nic_ip() + if dev_ip is not None: + self.android_adb_disconnect(dev_ip) + + def enable_adb_over_tcpip(self): + self.proc.sendline('echo 0>/sys/class/android_usb/android0/enable') + self.proc.sendline('setprop service.adb.tcp.port 5555') + self.proc.sendline('stop adbd') + self.proc.sendline('start adbd') + + def wait_home_screen(self): + cmd = 'getprop init.svc.bootanim' + for count in range(100): + self.proc.sendline(cmd) + match_id = self.proc.expect('stopped') + if match_id == 0: + return True + time.sleep(1) + raise GeneralError('The home screen does not displayed') + + class SerialIO(file): def __init__(self, logfile): self.serialio = StringIO()