зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1550828: String fixes and minor cleanup for power.py and Raptor's mach_commands.py. r=bc
Differential Revision: https://phabricator.services.mozilla.com/D30775 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
c5d721dff7
Коммит
4a55597f03
|
@ -29,9 +29,9 @@ BENCHMARK_REVISION = '2720cdc790828952964524bb44ce8b4c14670e90'
|
|||
class RaptorRunner(MozbuildObject):
|
||||
def run_test(self, raptor_args, kwargs):
|
||||
"""
|
||||
We want to do couple of things before running raptor
|
||||
We want to do a few things before running Raptor:
|
||||
1. Clone mozharness
|
||||
2. Make config for raptor mozharness
|
||||
2. Make the config for Raptor mozharness
|
||||
3. Run mozharness
|
||||
"""
|
||||
|
||||
|
@ -204,7 +204,7 @@ class MachRaptor(MachCommandBase):
|
|||
adbhost = ADBHost(verbose=True)
|
||||
device_serial = "%s:5555" % device.get_ip_address()
|
||||
device.command_output(["tcpip", "5555"])
|
||||
raw_input("Please disconnect your device from USB then press ENTER...")
|
||||
raw_input("Please disconnect your device from USB then press Enter/return...")
|
||||
adbhost.command_output(["connect", device_serial])
|
||||
while len(adbhost.devices()) > 1:
|
||||
raw_input("You must disconnect your device from USB before continuing.")
|
||||
|
@ -218,7 +218,7 @@ class MachRaptor(MachCommandBase):
|
|||
finally:
|
||||
try:
|
||||
if kwargs['app'] in firefox_android_browsers and kwargs['power_test']:
|
||||
raw_input("Connect device via usb and press ENTER...")
|
||||
raw_input("Connect device via USB and press Enter/return...")
|
||||
device = ADBAndroid(device=device_serial, verbose=True)
|
||||
device.command_output(["usb"])
|
||||
adbhost.command_output(["disconnect", device_serial])
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
from __future__ import absolute_import
|
||||
|
||||
import os
|
||||
|
@ -8,21 +9,24 @@ import re
|
|||
|
||||
|
||||
def init_android_power_test(raptor):
|
||||
upload_dir = os.getenv('MOZ_UPLOAD_DIR')
|
||||
upload_dir = os.getenv("MOZ_UPLOAD_DIR")
|
||||
if not upload_dir:
|
||||
raptor.log.critical("% power test ignored; MOZ_UPLOAD_DIR unset" % raptor.config['app'])
|
||||
raptor.log.critical(
|
||||
"% power test ignored; MOZ_UPLOAD_DIR unset" % raptor.config["app"]
|
||||
)
|
||||
return
|
||||
# Set the screen off timeout to 2 hours since the device will be running
|
||||
# disconnected and would otherwise turn off the screen thereby halting
|
||||
# Set the screen-off timeout to two (2) hours, since the device will be running
|
||||
# disconnected, and would otherwise turn off the screen, thereby halting
|
||||
# execution of the test. Save the current value so we can restore it later
|
||||
# since it is a persistent change.
|
||||
raptor.screen_off_timeout = raptor.device.shell_output(
|
||||
"settings get system screen_off_timeout").strip()
|
||||
"settings get system screen_off_timeout"
|
||||
).strip()
|
||||
raptor.device.shell_output("settings put system screen_off_timeout 7200000")
|
||||
raptor.device.shell_output("dumpsys batterystats --reset")
|
||||
raptor.device.shell_output("dumpsys batterystats --enable full-wake-history")
|
||||
filepath = os.path.join(upload_dir, 'battery-before.txt')
|
||||
with open(filepath, 'w') as output:
|
||||
filepath = os.path.join(upload_dir, "battery-before.txt")
|
||||
with open(filepath, "w") as output:
|
||||
output.write(raptor.device.shell_output("dumpsys battery"))
|
||||
|
||||
|
||||
|
@ -49,42 +53,46 @@ def init_android_power_test(raptor):
|
|||
# Bluetooth: 0.527 ( cpu=0.00319 bt=0.524 ) Including smearing: 0.574 ( proportional=... )
|
||||
# Wifi: 0.423 ( cpu=0.343 wifi=0.0800 ) Including smearing: 0.461 ( proportional=0.0375 )
|
||||
#
|
||||
# For Android 8 the cpu, wifi, screen and proportional values from the
|
||||
# Uid line for the app. If the test does not run long enough it
|
||||
# appears that the screen value from the Uid will be missing but the
|
||||
# For Android 8, the cpu, wifi, screen, and proportional values are available from
|
||||
# the Uid line for the app. If the test does not run long enough, it
|
||||
# appears that the screen value from the Uid will be missing, but the
|
||||
# standalone Screen value is available.
|
||||
#
|
||||
# For Android 7 only the cpu value is available from the Uid line. We
|
||||
# For Android 7, only the cpu value is available from the Uid line. We
|
||||
# can use the Screen and Wifi values for Android 7 from the Screen
|
||||
# and Wifi lines which may include contributions from the system or
|
||||
# other apps however it should be useful for spotting changes in power
|
||||
# and Wifi lines, which might include contributions from the system or
|
||||
# other apps; however, it should still be useful for spotting changes in power
|
||||
# usage.
|
||||
#
|
||||
# If the energy values from Uid line for Android 8 are available they
|
||||
# will be used. If for any reason that the screen or wifi power is
|
||||
# If the energy values from the Uid line for Android 8 are available, they
|
||||
# will be used. If for any reason either/both screen or wifi power is
|
||||
# missing, the values from the Screen and Wifi lines will be used.
|
||||
#
|
||||
# If only the cpu energy value is available, then it will be used
|
||||
# If only the cpu energy value is available, it will be used
|
||||
# along with the values from the Screen and Wifi lines.
|
||||
|
||||
|
||||
def finish_android_power_test(raptor, test_name):
|
||||
upload_dir = os.getenv('MOZ_UPLOAD_DIR')
|
||||
upload_dir = os.getenv("MOZ_UPLOAD_DIR")
|
||||
if not upload_dir:
|
||||
raptor.log.critical("% power test ignored because MOZ_UPLOAD_DIR was not set" % test_name)
|
||||
raptor.log.critical(
|
||||
"% power test ignored because MOZ_UPLOAD_DIR was not set" % test_name
|
||||
)
|
||||
return
|
||||
# Restore the screen off timeout.
|
||||
# Restore screen_off_timeout.
|
||||
raptor.device.shell_output(
|
||||
"settings put system screen_off_timeout %s" % raptor.screen_off_timeout)
|
||||
filepath = os.path.join(upload_dir, 'battery-after.txt')
|
||||
with open(filepath, 'w') as output:
|
||||
"settings put system screen_off_timeout %s" % raptor.screen_off_timeout
|
||||
)
|
||||
filepath = os.path.join(upload_dir, "battery-after.txt")
|
||||
with open(filepath, "w") as output:
|
||||
output.write(raptor.device.shell_output("dumpsys battery"))
|
||||
verbose = raptor.device._verbose
|
||||
raptor.device._verbose = False
|
||||
filepath = os.path.join(upload_dir, 'batterystats.csv')
|
||||
with open(filepath, 'w') as output:
|
||||
filepath = os.path.join(upload_dir, "batterystats.csv")
|
||||
with open(filepath, "w") as output:
|
||||
output.write(raptor.device.shell_output("dumpsys batterystats --checkin"))
|
||||
filepath = os.path.join(upload_dir, 'batterystats.txt')
|
||||
with open(filepath, 'w') as output:
|
||||
filepath = os.path.join(upload_dir, "batterystats.txt")
|
||||
with open(filepath, "w") as output:
|
||||
batterystats = raptor.device.shell_output("dumpsys batterystats")
|
||||
output.write(batterystats)
|
||||
raptor.device._verbose = verbose
|
||||
|
@ -93,24 +101,25 @@ def finish_android_power_test(raptor, test_name):
|
|||
total = cpu = wifi = smearing = screen = proportional = 0
|
||||
full_screen = 0
|
||||
full_wifi = 0
|
||||
re_uid = re.compile(r'proc=([^:]+):"%s"' % raptor.config['binary'])
|
||||
re_estimated_power = re.compile(r'\s+Estimated power use [(]mAh[)]')
|
||||
re_proportional = re.compile(r'proportional=([\d.]+)')
|
||||
re_screen = re.compile(r'screen=([\d.]+)')
|
||||
re_full_screen = re.compile(r'\s+Screen:\s+([\d.]+)')
|
||||
re_full_wifi = re.compile(r'\s+Wifi:\s+([\d.]+)')
|
||||
re_uid = re.compile(r'proc=([^:]+):"%s"' % raptor.config["binary"])
|
||||
re_estimated_power = re.compile(r"\s+Estimated power use [(]mAh[)]")
|
||||
re_proportional = re.compile(r"proportional=([\d.]+)")
|
||||
re_screen = re.compile(r"screen=([\d.]+)")
|
||||
re_full_screen = re.compile(r"\s+Screen:\s+([\d.]+)")
|
||||
re_full_wifi = re.compile(r"\s+Wifi:\s+([\d.]+)")
|
||||
re_power = None
|
||||
batterystats = batterystats.split('\n')
|
||||
batterystats = batterystats.split("\n")
|
||||
for line in batterystats:
|
||||
if uid is None:
|
||||
# The proc line containing the uid and app name appears
|
||||
# The proc line containing the Uid and app name appears
|
||||
# before the Estimated power line.
|
||||
match = re_uid.search(line)
|
||||
if match:
|
||||
uid = match.group(1)
|
||||
re_power = re.compile(
|
||||
r'\s+Uid %s:\s+([\d.]+) ([(] cpu=([\d.]+) wifi=([\d.]+) [)] '
|
||||
r'Including smearing: ([\d.]+))?' % uid)
|
||||
r"\s+Uid %s:\s+([\d.]+) ([(] cpu=([\d.]+) wifi=([\d.]+) [)] "
|
||||
r"Including smearing: ([\d.]+))?" % uid
|
||||
)
|
||||
continue
|
||||
if not estimated_power:
|
||||
# Do not attempt to parse data until we have seen
|
||||
|
@ -135,7 +144,7 @@ def finish_android_power_test(raptor, test_name):
|
|||
(total, android8, cpu, wifi, smearing) = match.groups()
|
||||
if android8:
|
||||
# android8 is not None only if the Uid line
|
||||
# contained values for cpu and wifi which is
|
||||
# contained values for cpu and wifi, which is
|
||||
# true only for Android 8+.
|
||||
match = re_screen.search(line)
|
||||
if match:
|
||||
|
@ -151,20 +160,25 @@ def finish_android_power_test(raptor, test_name):
|
|||
screen = full_screen if screen == 0 else screen
|
||||
wifi = full_wifi if wifi is None else wifi
|
||||
|
||||
raptor.log.info('power data for uid: %s, cpu: %s, wifi: %s, screen: %s, proportional: %s' %
|
||||
(uid, cpu, wifi, screen, proportional))
|
||||
raptor.log.info(
|
||||
"power data for uid: %s, cpu: %s, wifi: %s, screen: %s, proportional: %s"
|
||||
% (uid, cpu, wifi, screen, proportional)
|
||||
)
|
||||
|
||||
# send power data directly to the control server results handler;
|
||||
# so it can be formatted and output for perfherder ingestion
|
||||
# send power data directly to the control-server results handler,
|
||||
# so it can be formatted and out-put for perfherder ingestion
|
||||
|
||||
power_data = {'type': 'power',
|
||||
'test': test_name,
|
||||
'unit': 'mAh',
|
||||
'values': {
|
||||
'cpu': float(cpu),
|
||||
'wifi': float(wifi),
|
||||
'screen': float(screen),
|
||||
'proportional': float(proportional)}}
|
||||
power_data = {
|
||||
"type": "power",
|
||||
"test": test_name,
|
||||
"unit": "mAh",
|
||||
"values": {
|
||||
"cpu": float(cpu),
|
||||
"wifi": float(wifi),
|
||||
"screen": float(screen),
|
||||
"proportional": float(proportional),
|
||||
},
|
||||
}
|
||||
|
||||
raptor.log.info("submitting power data via control server directly")
|
||||
raptor.control_server.submit_supporting_data(power_data)
|
||||
|
|
Загрузка…
Ссылка в новой задаче