Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(496)

Side by Side Diff: bin/au_test_harness/au_worker.py

Issue 6614029: Add ability to pass a base test root and create results dirs relative. (Closed) Base URL: http://git.chromium.org/git/crosutils.git@master
Patch Set: ws Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « bin/au_test_harness/au_test.py ('k') | bin/au_test_harness/cros_au_test_harness.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2011 The Chromium OS Authors. All rights reserved. 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 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 """Module that contains the interface for au_test_harness workers. 5 """Module that contains the interface for au_test_harness workers.
6 6
7 An au test harnss worker is a class that contains the logic for performing 7 An au test harnss worker is a class that contains the logic for performing
8 and validating updates on a target. This should be subclassed to handle 8 and validating updates on a target. This should be subclassed to handle
9 various types of target. Types of targets include VM's, real devices, etc. 9 various types of target. Types of targets include VM's, real devices, etc.
10 """ 10 """
11 11
12 import inspect
13 import threading
12 import os 14 import os
13 import sys 15 import sys
14 16
15 import cros_build_lib as cros_lib 17 import cros_build_lib as cros_lib
16 18
17 import dev_server_wrapper 19 import dev_server_wrapper
18 import update_exception 20 import update_exception
19 21
20 22
21 class AUWorker(object): 23 class AUWorker(object):
22 """Interface for a worker that updates and verifies images.""" 24 """Interface for a worker that updates and verifies images."""
23 25 # Mapping between cached payloads to directory locations.
24 update_cache = None 26 update_cache = None
25 27
26 # --- INTERFACE --- 28 # --- INTERFACE ---
27 29
28 def __init__(self, options): 30 def __init__(self, options, test_results_root):
29 """Processes options for the specific-type of worker.""" 31 """Processes options for the specific-type of worker."""
30 self.board = options.board 32 self.board = options.board
31 self.private_key = options.private_key 33 self.private_key = options.private_key
34 self.test_results_root = test_results_root
32 self.use_delta_updates = options.delta 35 self.use_delta_updates = options.delta
33 self.verbose = options.verbose 36 self.verbose = options.verbose
34 self.vm_image_path = None 37 self.vm_image_path = None
35 if options.quick_test: 38 if options.quick_test:
36 self.verify_suite = 'build_RootFilesystemSize' 39 self.verify_suite = 'build_RootFilesystemSize'
37 else: 40 else:
38 self.verify_suite = 'suite_Smoke' 41 self.verify_suite = 'suite_Smoke'
39 42
40 # Set these up as they are used often. 43 # Set these up as they are used often.
41 self.crosutils = os.path.join(os.path.dirname(__file__), '..', '..') 44 self.crosutils = os.path.join(os.path.dirname(__file__), '..', '..')
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 """ 221 """
219 cros_lib.Info('Output from VerifyImage():') 222 cros_lib.Info('Output from VerifyImage():')
220 print >> sys.stderr, output 223 print >> sys.stderr, output
221 sys.stderr.flush() 224 sys.stderr.flush()
222 percent_passed = self._ParseGenerateTestReportOutput(output) 225 percent_passed = self._ParseGenerateTestReportOutput(output)
223 cros_lib.Info('Percent passed: %d vs. Percent required: %d' % ( 226 cros_lib.Info('Percent passed: %d vs. Percent required: %d' % (
224 percent_passed, percent_required_to_pass)) 227 percent_passed, percent_required_to_pass))
225 unittest.assertTrue(percent_passed >= percent_required_to_pass) 228 unittest.assertTrue(percent_passed >= percent_required_to_pass)
226 return percent_passed 229 return percent_passed
227 230
231 def InitializeResultsDirectory(self):
232 """Called by a test to initialize a results directory for this worker."""
233 # Use the name of the test.
234 test_name = inspect.stack()[1][3]
235 self.results_directory = os.path.join(self.test_results_root, test_name)
236 self.results_count = 0
237
238 def GetNextResultsPath(self, label):
239 """Returns a new results path based for this label.
240
241 Prefixes directory returned for worker with time called i.e. 1_label,
242 2_label, etc.
243 """
244 self.results_count += 1
245 return os.path.join(self.results_directory, '%s_%s' % (self.results_count,
246 label))
247
228 # --- PRIVATE HELPER FUNCTIONS --- 248 # --- PRIVATE HELPER FUNCTIONS ---
229 249
230 def _ParseGenerateTestReportOutput(self, output): 250 def _ParseGenerateTestReportOutput(self, output):
231 """Returns the percentage of tests that passed based on output.""" 251 """Returns the percentage of tests that passed based on output."""
232 percent_passed = 0 252 percent_passed = 0
233 lines = output.split('\n') 253 lines = output.split('\n')
234 254
235 for line in lines: 255 for line in lines:
236 if line.startswith("Total PASS:"): 256 if line.startswith("Total PASS:"):
237 # FORMAT: ^TOTAL PASS: num_passed/num_total (percent%)$ 257 # FORMAT: ^TOTAL PASS: num_passed/num_total (percent%)$
238 percent_passed = line.split()[3].strip('()%') 258 percent_passed = line.split()[3].strip('()%')
239 cros_lib.Info('Percent of tests passed %s' % percent_passed) 259 cros_lib.Info('Percent of tests passed %s' % percent_passed)
240 break 260 break
241 261
242 return int(percent_passed) 262 return int(percent_passed)
OLDNEW
« no previous file with comments | « bin/au_test_harness/au_test.py ('k') | bin/au_test_harness/cros_au_test_harness.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698