OLD | NEW |
(Empty) | |
| 1 # Copyright (c) 2011 The Chromium OS Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. |
| 4 |
| 5 """Module containing class that implements an au_worker for a test device.""" |
| 6 |
| 7 import unittest |
| 8 |
| 9 import cros_build_lib as cros_lib |
| 10 |
| 11 import au_worker |
| 12 |
| 13 class RealAUWorker(au_worker.AUWorker): |
| 14 """Test harness for updating real images.""" |
| 15 |
| 16 def __init__(self, options): |
| 17 """Processes non-vm-specific options.""" |
| 18 au_worker.AUWorker.__init__(self, options) |
| 19 self.remote = options.remote |
| 20 if not self.remote: cros_lib.Die('We require a remote address for tests.') |
| 21 |
| 22 def PrepareBase(self, image_path): |
| 23 """Auto-update to base image to prepare for test.""" |
| 24 self.PrepareRealBase(image_path) |
| 25 |
| 26 def UpdateImage(self, image_path, src_image_path='', stateful_change='old', |
| 27 proxy_port=None, private_key_path=None): |
| 28 """Updates a remote image using image_to_live.sh.""" |
| 29 stateful_change_flag = self.GetStatefulChangeFlag(stateful_change) |
| 30 cmd = ['%s/image_to_live.sh' % self.crosutils, |
| 31 '--remote=%s' % self.remote, |
| 32 stateful_change_flag, |
| 33 '--verify', |
| 34 ] |
| 35 self.AppendUpdateFlags(cmd, image_path, src_image_path, proxy_port, |
| 36 private_key_path) |
| 37 self.RunUpdateCmd(cmd) |
| 38 |
| 39 def UpdateUsingPayload(self, update_path, stateful_change='old', |
| 40 proxy_port=None): |
| 41 """Updates a remote image using image_to_live.sh.""" |
| 42 stateful_change_flag = self.GetStatefulChangeFlag(stateful_change) |
| 43 cmd = ['%s/image_to_live.sh' % self.crosutils, |
| 44 '--payload=%s' % update_path, |
| 45 '--remote=%s' % self.remote, |
| 46 stateful_change_flag, |
| 47 '--verify', |
| 48 ] |
| 49 if proxy_port: cmd.append('--proxy_port=%s' % proxy_port) |
| 50 self.RunUpdateCmd(cmd) |
| 51 |
| 52 def VerifyImage(self, unittest, percent_required_to_pass=100): |
| 53 """Verifies an image using run_remote_tests.sh with verification suite.""" |
| 54 output = cros_lib.RunCommand( |
| 55 ['%s/run_remote_tests.sh' % self.crosutils, |
| 56 '--remote=%s' % self.remote, |
| 57 self.verify_suite, |
| 58 ], error_ok=True, enter_chroot=False, redirect_stdout=True) |
| 59 return self.AssertEnoughTestsPassed(unittest, output, |
| 60 percent_required_to_pass) |
| 61 |
OLD | NEW |