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

Unified Diff: common/battor/battor/battor_stress_test.py

Issue 3014563002: DO NOT SUBMIT: BattOr stress test
Patch Set: Created 3 years, 3 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 | « no previous file | common/battor/battor/battor_wrapper.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: common/battor/battor/battor_stress_test.py
diff --git a/common/battor/battor/battor_stress_test.py b/common/battor/battor/battor_stress_test.py
new file mode 100644
index 0000000000000000000000000000000000000000..8f5e31a4ad58780451260d7cb324fa537f280e95
--- /dev/null
+++ b/common/battor/battor/battor_stress_test.py
@@ -0,0 +1,74 @@
+# Copyright 2016 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.
+
+import logging
+import platform
+import random
+import os
+import sys
+import time
+import unittest
+
+if __name__ == '__main__':
+ sys.path.append(
+ os.path.join(os.path.dirname(__file__), '..'))
+
+from battor import battor_wrapper
+from devil.utils import battor_device_mapping
+from devil.utils import find_usb_devices
+
+def _CreateBattOrWrapper():
+ telemetry_platform = None
+ battor_list = None
+
+ sys_platform = platform.system()
+ if 'Win' in sys_platform:
+ telemetry_platform = 'win'
+ elif 'Linux' in sys_platform:
+ telemetry_platform = 'linux'
+ elif 'Darwin' in sys_platform:
+ telemetry_platform = 'mac'
+
+ if not battor_wrapper.IsBattOrConnected(telemetry_platform):
+ return None
+
+ # On Linux, there can be multiple BattOrs attached, so we need to explicitly
+ # specify which BattOr to use.
+ battor_path = None
+ if telemetry_platform == 'linux':
+ device_tree = find_usb_devices.GetBusNumberToDeviceTreeMap()
+ battor_list = battor_device_mapping.GetBattorList(device_tree)
+ battor_path = '/dev/%s' % battor_list[0]
+
+ return battor_wrapper.BattOrWrapper(
+ telemetry_platform, battor_path=battor_path)
+
+def Main(argv):
+ while True:
+ try:
+ battor = _CreateBattOrWrapper()
+
+ if not battor:
+ print "Failed to create BattOrWrapper: is a BattOr attached?"
+ break
+
+ duration = random.randint(15, 180)
+ battor.StartShell()
+ battor.StartTracing()
+
+ time.sleep(duration)
+ battor.RecordClockSyncMarker('abc')
+ time.sleep(0.5)
+ battor.StopTracing()
+ battor.CollectTraceData()
+ print "PASS for duration = %s" % (duration)
+
+ except KeyboardInterrupt:
+ raise
+ except Exception as e:
+ print 'FAIL for duration = %s, exception: %s' % (duration, e)
+ raise
+
+if __name__ == '__main__':
+ sys.exit(Main(sys.argv))
« no previous file with comments | « no previous file | common/battor/battor/battor_wrapper.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698