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

Unified Diff: build/android/pylib/perf/setup.py

Issue 22854004: Android: first step into making "perf tests" reuse the functional test infra. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: copyright notice Created 7 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « build/android/pylib/perf/__init__.py ('k') | build/android/pylib/perf/test_options.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/android/pylib/perf/setup.py
diff --git a/build/android/pylib/perf/setup.py b/build/android/pylib/perf/setup.py
new file mode 100644
index 0000000000000000000000000000000000000000..5d0272d2f71e010cdfdd6ef1ddecc5646ad5ef88
--- /dev/null
+++ b/build/android/pylib/perf/setup.py
@@ -0,0 +1,74 @@
+# Copyright 2013 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""Generates test runner factory and tests for performance tests."""
+
+import json
+import logging
+import os
+import psutil
+import signal
+import time
+
+from pylib import android_commands
+from pylib import cmd_helper
+from pylib import forwarder
+from pylib import ports
+
+import test_runner
+
+
+def _KillPendingServers():
+ for retry in range(5):
+ for server in ['lighttpd', 'web-page-replay']:
+ pids = [p.pid for p in psutil.process_iter() if server in p.name]
+ for pid in pids:
+ try:
+ logging.warning('Killing %s %s', server, pid)
+ os.kill(pid, signal.SIGQUIT)
+ except Exception as e:
+ logging.warning('Failed killing %s %s %s', server, pid, e)
+ # Restart the adb server with taskset to set a single CPU affinity.
+ cmd_helper.RunCmd(['adb', 'kill-server'])
+ cmd_helper.RunCmd(['taskset', '-c', '0', 'adb', 'start-server'])
+ cmd_helper.RunCmd(['taskset', '-c', '0', 'adb', 'root'])
+ i = 1
+ while not android_commands.GetAttachedDevices():
+ time.sleep(i)
+ i *= 2
+ if i > 10:
+ break
+ # Reset the test port allocation. It's important to do it before starting
+ # to dispatch any step.
+ if not ports.ResetTestServerPortAllocation():
+ raise Exception('Failed to reset test server port.')
+
+ forwarder.Forwarder.UseMultiprocessing()
+
+
+def Setup(test_options):
+ """Create and return the test runner factory and tests.
+
+ Args:
+ test_options: A PerformanceOptions object.
+
+ Returns:
+ A tuple of (TestRunnerFactory, tests).
+ """
+ # Before running the tests, kill any leftover server.
+ _KillPendingServers()
+
+ with file(test_options.steps, 'r') as f:
+ tests = json.load(f)
+
+ flaky_steps = []
+ if test_options.flaky_steps:
+ with file(test_options.flaky_steps, 'r') as f:
+ flaky_steps = json.load(f)
+
+ def TestRunnerFactory(device, shard_index):
+ return test_runner.TestRunner(
+ test_options, device, tests, flaky_steps)
+
+ return (TestRunnerFactory, sorted(tests.keys()))
« no previous file with comments | « build/android/pylib/perf/__init__.py ('k') | build/android/pylib/perf/test_options.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698