Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 # Copyright 2013 The Chromium 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 """Generates test runner factory and tests for performance tests.""" | |
| 6 | |
| 7 import json | |
| 8 import logging | |
| 9 import os | |
| 10 import psutil | |
| 11 import signal | |
| 12 import test_runner | |
| 13 | |
| 14 from pylib import android_commands | |
| 15 from pylib import cmd_helper | |
| 16 from pylib import forwarder | |
| 17 from pylib import ports | |
| 18 | |
| 19 | |
| 20 def _KillPendingServers(): | |
| 21 for retry in range(5): | |
| 22 for server in ['lighttpd', 'web-page-replay']: | |
| 23 pids = [p.pid for p in psutil.process_iter() if server in p.name] | |
| 24 for pid in pids: | |
| 25 try: | |
| 26 logging.warning('Killing %s %s', server, pid) | |
| 27 os.kill(pid, signal.SIGQUIT) | |
| 28 except Exception as e: | |
| 29 logging.warning('Failed killing %s %s %s', server, pid, e) | |
| 30 # Restart the adb server with taskset to set a single CPU affinity. | |
|
craigdh
2013/08/13 16:58:46
This seems widely applicable. Should this be done
bulach
2013/08/13 17:06:53
yes, just not yet. :)
the main goal of this patch
craigdh
2013/08/13 19:03:46
Sounds most excellent.
| |
| 31 cmd_helper.RunCmd(['adb', 'kill-server']) | |
| 32 cmd_helper.RunCmd(['taskset', '-c', '0', 'adb', 'start-server']) | |
| 33 cmd_helper.RunCmd(['taskset', '-c', '0', 'adb', 'root']) | |
| 34 i = 1 | |
| 35 while not android_commands.GetAttachedDevices(): | |
| 36 time.sleep(i) | |
| 37 i *= 2 | |
| 38 if i > 10: | |
| 39 break | |
| 40 # Reset the test port allocation. It's important to do it before starting | |
| 41 # to dispatch any step. | |
| 42 if not ports.ResetTestServerPortAllocation(): | |
| 43 raise Exception('Failed to reset test server port.') | |
| 44 | |
| 45 forwarder.Forwarder.UseMultiprocessing() | |
| 46 | |
| 47 | |
| 48 def Setup(test_options): | |
| 49 """Create and return the test runner factory and tests. | |
| 50 | |
| 51 Args: | |
| 52 test_options: A PerformanceOptions object. | |
| 53 | |
| 54 Returns: | |
| 55 A tuple of (TestRunnerFactory, tests). | |
| 56 """ | |
| 57 # Before running the tests, kill any leftover server. | |
| 58 _KillPendingServers() | |
| 59 | |
| 60 with file(test_options.steps, 'r') as f: | |
| 61 tests = json.load(f) | |
| 62 | |
| 63 flaky_steps = [] | |
| 64 if test_options.flaky_steps: | |
| 65 with file(test_options.flaky_steps, 'r') as f: | |
| 66 flaky_steps = json.load(f) | |
| 67 | |
| 68 def TestRunnerFactory(device, shard_index): | |
| 69 return test_runner.TestRunner( | |
| 70 test_options, device, tests, flaky_steps) | |
| 71 | |
| 72 return (TestRunnerFactory, sorted(tests.keys())) | |
| OLD | NEW |