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

Side by Side Diff: client/tests/kvm/kvm_test_utils.py

Issue 1595019: Merge remote branch 'origin/upstream' into tempbranch (Closed)
Patch Set: Created 10 years, 8 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
OLDNEW
1 """ 1 """
2 High-level KVM test utility functions. 2 High-level KVM test utility functions.
3 3
4 This module is meant to reduce code size by performing common test procedures. 4 This module is meant to reduce code size by performing common test procedures.
5 Generally, code here should look like test code. 5 Generally, code here should look like test code.
6 More specifically: 6 More specifically:
7 - Functions in this module should raise exceptions if things go wrong 7 - Functions in this module should raise exceptions if things go wrong
8 (unlike functions in kvm_utils.py and kvm_vm.py which report failure via 8 (unlike functions in kvm_utils.py and kvm_vm.py which report failure via
9 their returned values). 9 their returned values).
10 - Functions in this module may use logging.info(), in addition to 10 - Functions in this module may use logging.info(), in addition to
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 291
292 def extract(vm, remote_path, dest_dir="."): 292 def extract(vm, remote_path, dest_dir="."):
293 """ 293 """
294 Extract a .tar.bz2 file on the guest. 294 Extract a .tar.bz2 file on the guest.
295 295
296 @param vm: VM object 296 @param vm: VM object
297 @param remote_path: Remote file path 297 @param remote_path: Remote file path
298 @param dest_dir: Destination dir for the contents 298 @param dest_dir: Destination dir for the contents
299 """ 299 """
300 basename = os.path.basename(remote_path) 300 basename = os.path.basename(remote_path)
301 logging.info("Extracting %s..." % basename) 301 logging.info("Extracting %s...", basename)
302 (status, output) = session.get_command_status_output( 302 (status, output) = session.get_command_status_output(
303 "tar xjvf %s -C %s" % (remote_path, dest_dir)) 303 "tar xjvf %s -C %s" % (remote_path, dest_dir))
304 if status != 0: 304 if status != 0:
305 logging.error("Uncompress output:\n%s" % output) 305 logging.error("Uncompress output:\n%s" % output)
306 raise error.TestFail("Could not extract % on guest") 306 raise error.TestFail("Could not extract %s on guest" % basename)
307 307
308 if not os.path.isfile(control_path): 308 if not os.path.isfile(control_path):
309 raise error.TestError("Invalid path to autotest control file: %s" % 309 raise error.TestError("Invalid path to autotest control file: %s" %
310 control_path) 310 control_path)
311 311
312 tarred_autotest_path = "/tmp/autotest.tar.bz2" 312 tarred_autotest_path = "/tmp/autotest.tar.bz2"
313 tarred_test_path = "/tmp/%s.tar.bz2" % test_name 313 tarred_test_path = "/tmp/%s.tar.bz2" % test_name
314 314
315 # To avoid problems, let's make the test use the current AUTODIR 315 # To avoid problems, let's make the test use the current AUTODIR
316 # (autotest client path) location 316 # (autotest client path) location
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 session.get_command_output("mkdir -p %s" % tests_path) 349 session.get_command_output("mkdir -p %s" % tests_path)
350 350
351 # Extract <test_name>.tar.bz2 into autotest/tests 351 # Extract <test_name>.tar.bz2 into autotest/tests
352 extract(vm, tarred_test_path, "/") 352 extract(vm, tarred_test_path, "/")
353 353
354 if not vm.copy_files_to(control_path, 354 if not vm.copy_files_to(control_path,
355 os.path.join(autotest_path, 'control')): 355 os.path.join(autotest_path, 'control')):
356 raise error.TestFail("Could not copy the test control file to guest") 356 raise error.TestFail("Could not copy the test control file to guest")
357 357
358 # Run the test 358 # Run the test
359 logging.info("Running test '%s'..." % test_name) 359 logging.info("Running test '%s'...", test_name)
360 session.get_command_output("cd %s" % autotest_path) 360 session.get_command_output("cd %s" % autotest_path)
361 session.get_command_output("rm -f control.state") 361 session.get_command_output("rm -f control.state")
362 session.get_command_output("rm -rf results/*") 362 session.get_command_output("rm -rf results/*")
363 logging.info("---------------- Test output ----------------") 363 logging.info("---------------- Test output ----------------")
364 status = session.get_command_status("bin/autotest control", 364 status = session.get_command_status("bin/autotest control",
365 timeout=timeout, 365 timeout=timeout,
366 print_func=logging.info) 366 print_func=logging.info)
367 logging.info("--------------End of test output ------------") 367 logging.info("------------- End of test output ------------")
368 if status is None: 368 if status is None:
369 raise error.TestFail("Timeout elapsed while waiting for autotest to " 369 raise error.TestFail("Timeout elapsed while waiting for autotest to "
370 "complete") 370 "complete")
371 371
372 # Get the results generated by autotest 372 # Get the results generated by autotest
373 output = session.get_command_output("cat results/*/status") 373 output = session.get_command_output("cat results/*/status")
374 results = scan_results.parse_results(output) 374 results = scan_results.parse_results(output)
375 session.close 375 session.close
376 376
377 # Copy test results to the local bindir/guest_results 377 # Copy test results to the local bindir/guest_results
(...skipping 17 matching lines...) Expand all
395 bad_results += [r for r in results if r[1] == "ABORT"] 395 bad_results += [r for r in results if r[1] == "ABORT"]
396 396
397 # Fail the test if necessary 397 # Fail the test if necessary
398 if not results: 398 if not results:
399 raise error.TestFail("Test '%s' did not produce any recognizable " 399 raise error.TestFail("Test '%s' did not produce any recognizable "
400 "results" % test_name) 400 "results" % test_name)
401 if bad_results: 401 if bad_results:
402 result = bad_results[0] 402 result = bad_results[0]
403 raise error.TestFail("Test '%s' ended with %s (reason: '%s')" 403 raise error.TestFail("Test '%s' ended with %s (reason: '%s')"
404 % (result[0], result[1], result[3])) 404 % (result[0], result[1], result[3]))
OLDNEW
« no previous file with comments | « client/tests/iperf/iperf.py ('k') | client/tests/lmbench/0001-Fix-build-issues-with-lmbench.patch » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698