From patchwork Fri Sep 13 13:53:33 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tyler Baker X-Patchwork-Id: 20283 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qc0-f197.google.com (mail-qc0-f197.google.com [209.85.216.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 2313020358 for ; Fri, 13 Sep 2013 13:53:37 +0000 (UTC) Received: by mail-qc0-f197.google.com with SMTP id r5sf1251168qcx.8 for ; Fri, 13 Sep 2013 06:53:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:mime-version:to:from:subject :message-id:date:reply-to:sender:errors-to:precedence :x-original-sender:x-original-authentication-results:mailing-list :list-id:list-post:list-help:list-archive:list-unsubscribe :content-type; bh=j5vvMhyicNQbl4cZCc4LvHSPUd3wY64iTK1LCqFShkU=; b=FSrRZmzUf4auwMeseG7CrjfQwRUf5R5PbpIenooq4p4+PfwugKcMmmKxT7hFzmvjJn +gtGzZcQ+m7Z8Dh/QLCP5mz/KjQ1HHQEfl3x0YkN7tN939BqmqlQE1HoLsfhAfJX4kTd E21b0MH8pZrCPY4QIKJU+JL6/8ovwun8vU9Wi1EfvSJ1RVipbjQRBVjpcUQv/3HDKQym OL4uFu4UAx/ickQFArc7hTPJxotjTqfefKLOdGGzzePmJeOnQ787VfdKvIaGnVb+C/Z3 rFIa/EiYLwUpGGr4HtglLNl2rIo+N8gtyCAajRrHF0u3JnZzxnwW2UCAQr0FsVmyKVvf +02w== X-Gm-Message-State: ALoCoQlXJ5JujKrKFmpCpARBS8Y0gTX9Da8pS26vA2lEaSSXObjevvkv5r7/OaikyoNTFpsTyd1s X-Received: by 10.236.19.225 with SMTP id n61mr5008289yhn.8.1379080416417; Fri, 13 Sep 2013 06:53:36 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.17.98 with SMTP id n2ls1115213qed.12.gmail; Fri, 13 Sep 2013 06:53:36 -0700 (PDT) X-Received: by 10.52.166.200 with SMTP id zi8mr348312vdb.38.1379080416141; Fri, 13 Sep 2013 06:53:36 -0700 (PDT) Received: from mail-vb0-f43.google.com (mail-vb0-f43.google.com [209.85.212.43]) by mx.google.com with ESMTPS id o5si3156299vdw.63.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 13 Sep 2013 06:53:36 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.212.43 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.212.43; Received: by mail-vb0-f43.google.com with SMTP id h11so963359vbh.30 for ; Fri, 13 Sep 2013 06:53:36 -0700 (PDT) X-Received: by 10.221.6.195 with SMTP id ol3mr315995vcb.34.1379080416044; Fri, 13 Sep 2013 06:53:36 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp82000vcz; Fri, 13 Sep 2013 06:53:35 -0700 (PDT) X-Received: by 10.180.109.132 with SMTP id hs4mr2704261wib.46.1379080414689; Fri, 13 Sep 2013 06:53:34 -0700 (PDT) Received: from indium.canonical.com (indium.canonical.com. [91.189.90.7]) by mx.google.com with ESMTPS id lj7si5497548wjc.18.1969.12.31.16.00.00 (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 13 Sep 2013 06:53:34 -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; Received: from ackee.canonical.com ([91.189.89.26]) by indium.canonical.com with esmtp (Exim 4.71 #1 (Debian)) id 1VKToT-0006w0-SW for ; Fri, 13 Sep 2013 13:53:33 +0000 Received: from ackee.canonical.com (localhost [127.0.0.1]) by ackee.canonical.com (Postfix) with ESMTP id C7A64EBCDD for ; Fri, 13 Sep 2013 13:53:33 +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: 684 X-Launchpad-Notification-Type: branch-revision To: Linaro Patch Tracker From: noreply@launchpad.net Subject: [Branch ~linaro-validation/lava-dispatcher/trunk] Rev 684: Add capri gether support Message-Id: <20130913135333.13251.94305.launchpad@ackee.canonical.com> Date: Fri, 13 Sep 2013 13:53:33 -0000 Reply-To: noreply@launchpad.net Sender: bounces@canonical.com Errors-To: bounces@canonical.com Precedence: list X-Generated-By: Launchpad (canonical.com); Revision="16761"; Instance="launchpad-lazr.conf" X-Launchpad-Hash: 43616404b019307b8dca53df2845f8f36f9e527c X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: noreply@launchpad.net X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.212.43 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Merge authors: Tyler Baker (tyler-baker) Related merge proposals: https://code.launchpad.net/~tyler-baker/lava-dispatcher/capri-updates/+merge/185489 proposed by: Tyler Baker (tyler-baker) review: Approve - Antonio Terceiro (terceiro) ------------------------------------------------------------ revno: 684 [merge] committer: Tyler Baker branch nick: lava-dispatcher timestamp: Fri 2013-09-13 06:52:35 -0700 message: Add capri gether support modified: lava_dispatcher/device/capri.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 === modified file 'lava_dispatcher/device/capri.py' --- lava_dispatcher/device/capri.py 2013-08-28 14:55:50 +0000 +++ lava_dispatcher/device/capri.py 2013-09-13 01:25:58 +0000 @@ -19,9 +19,17 @@ # with this program; if not, see . import logging +import contextlib +import time +import os +import pexpect + from lava_dispatcher.device.target import ( Target ) +from lava_dispatcher.client.base import ( + NetworkCommandRunner, +) from lava_dispatcher.errors import ( CriticalError, ) @@ -31,6 +39,13 @@ from lava_dispatcher.device.master import ( MasterImageTarget ) +from lava_dispatcher.utils import ( + mk_targz, + rmtree, +) +from lava_dispatcher.downloader import ( + download_with_retry, +) class CapriTarget(FastbootTarget, MasterImageTarget): @@ -62,26 +77,79 @@ self.fastboot.flash('system', system) self.fastboot.flash('userdata', userdata) - self.deployment_data = Target.android_deployment_data + self.deployment_data = Target.ubuntu_deployment_data self.deployment_data['boot_image'] = boot def power_on(self): if not self.deployment_data.get('boot_image', False): raise CriticalError('Deploy action must be run first') - self._enter_fastboot() - self.fastboot('reboot') - self.proc.expect(self.context.device_config.master_str, - timeout=300) - - # The capri does not yet have adb support, so we do not wait for adb. - #self._adb('wait-for-device') - - self._booted = True - self.proc.sendline("") # required to put the adb shell in a reasonable state - self.proc.sendline("export PS1='%s'" % self.deployment_data['TESTER_PS1']) - self._runner = self._get_runner(self.proc) + if not self._booted: + self._enter_fastboot() + self.fastboot('reboot') + self._wait_for_prompt(self.proc, + self.context.device_config.master_str, + self.config.boot_linaro_timeout) + + self._booted = True + self.proc.sendline('') + self.proc.sendline('') + self.proc.sendline('export PS1="%s"' % self.deployment_data['TESTER_PS1']) + self._runner = self._get_runner(self.proc) return self.proc + @contextlib.contextmanager + def file_system(self, partition, directory): + try: + pat = self.deployment_data['TESTER_PS1_PATTERN'] + incrc = self.deployment_data['TESTER_PS1_INCLUDES_RC'] + runner = NetworkCommandRunner(self, pat, incrc) + + targetdir = '/%s' % directory + runner.run('mkdir -p %s' % targetdir) + parent_dir, target_name = os.path.split(targetdir) + runner.run('/bin/tar -cmzf /tmp/fs.tgz -C %s %s' + % (parent_dir, target_name)) + runner.run('cd /tmp') # need to be in same dir as fs.tgz + + ip = runner.get_target_ip() + + self.proc.sendline('python -m SimpleHTTPServer 0 2>/dev/null') + match_id = self.proc.expect([ + 'Serving HTTP on 0.0.0.0 port (\d+) \.\.', + pexpect.EOF, pexpect.TIMEOUT]) + if match_id != 0: + msg = "Unable to start HTTP server on Capri" + logging.error(msg) + raise CriticalError(msg) + port = self.proc.match.groups()[match_id] + + url = "http://%s:%s/fs.tgz" % (ip, port) + + logging.info("Fetching url: %s" % url) + tf = download_with_retry(self.context, self.scratch_dir, + url, False) + + tfdir = os.path.join(self.scratch_dir, str(time.time())) + + try: + os.mkdir(tfdir) + self.context.run_command('/bin/tar -C %s -xzf %s' + % (tfdir, tf)) + yield os.path.join(tfdir, target_name) + finally: + tf = os.path.join(self.scratch_dir, 'fs.tgz') + mk_targz(tf, tfdir) + rmtree(tfdir) + + self.proc.sendcontrol('c') # kill SimpleHTTPServer + + # get the last 2 parts of tf, ie "scratchdir/tf.tgz" + tf = '/'.join(tf.split('/')[-2:]) + runner.run('rm -rf %s' % targetdir) + self._target_extract(runner, tf, parent_dir) + finally: + self.proc.sendcontrol('c') # kill SimpleHTTPServer + target_class = CapriTarget