1
0
mirror of https://github.com/ARM-software/workload-automation.git synced 2025-02-20 20:09:11 +00:00

Merge pull request #157 from ep1cman/juno-fixes

hwmon & adb fixes
This commit is contained in:
setrofim 2016-05-10 09:49:33 +01:00
commit 9296bafbd9
5 changed files with 35 additions and 27 deletions

View File

@ -637,7 +637,15 @@ class AndroidDevice(BaseLinuxDevice): # pylint: disable=W0223
"""
lockdb = '/data/system/locksettings.db'
sqlcommand = "update locksettings set value='0' where name='screenlock.disabled';"
self.execute('{} {} "{}"'.format(self.sqlite, lockdb, sqlcommand), as_root=True)
f = tempfile.NamedTemporaryFile()
try:
f.write('{} {} "{}"'.format(self.sqlite, lockdb, sqlcommand))
f.flush()
on_device_executable = self.install_executable(f.name,
with_name="disable_screen_lock")
finally:
f.close()
self.execute(on_device_executable, as_root=True)
def disable_selinux(self):
# This may be invoked from intialize() so we can't use execute() or the

View File

@ -199,16 +199,6 @@ class Gem5AndroidDevice(BaseGem5Device, AndroidDevice):
props = self._get_android_properties(context)
return props
def disable_screen_lock(self):
"""
Attempts to disable he screen lock on the device.
Overridden here as otherwise we have issues with too many backslashes.
"""
lockdb = '/data/system/locksettings.db'
sqlcommand = "update locksettings set value=\'0\' where name=\'screenlock.disabled\';"
self.execute('{} {} "{}"'.format(self.sqlite, lockdb, sqlcommand), as_root=True)
def capture_screen(self, filepath):
if BaseGem5Device.capture_screen(self, filepath):
return

View File

@ -64,6 +64,7 @@ class HwmonInstrument(Instrument):
parameters = [
Parameter('sensors', kind=list_of_strs, default=['energy', 'temp'],
global_alias='hwmon_sensors',
allowed_values=HWMON_SENSORS.keys(),
description='The kinds of sensors hwmon instrument will look for')
]
@ -73,11 +74,7 @@ class HwmonInstrument(Instrument):
if self.sensors:
self.sensor_kinds = {}
for kind in self.sensors:
if kind in HWMON_SENSORS:
self.sensor_kinds[kind] = HWMON_SENSORS[kind]
else:
message = 'Unexpected sensor type: {}; must be in {}'.format(kind, HWMON_SENSORS.keys())
raise ConfigError(message)
self.sensor_kinds[kind] = HWMON_SENSORS[kind]
else:
self.sensor_kinds = HWMON_SENSORS
@ -110,13 +107,17 @@ class HwmonInstrument(Instrument):
if report_type == 'diff':
before, after = sensor.readings
diff = conversion(after - before)
context.result.add_metric(sensor.label, diff, units)
context.result.add_metric(sensor.label, diff, units,
classifiers={"hwmon_device": sensor.device_name})
elif report_type == 'before/after':
before, after = sensor.readings
mean = conversion((after + before) / 2)
context.result.add_metric(sensor.label, mean, units)
context.result.add_metric(sensor.label + ' before', conversion(before), units)
context.result.add_metric(sensor.label + ' after', conversion(after), units)
context.result.add_metric(sensor.label, mean, units,
classifiers={"hwmon_device": sensor.device_name})
context.result.add_metric(sensor.label + ' before', conversion(before), units,
classifiers={"hwmon_device": sensor.device_name})
context.result.add_metric(sensor.label + ' after', conversion(after), units,
classifiers={"hwmon_device": sensor.device_name})
else:
raise InstrumentError('Unexpected report_type: {}'.format(report_type))
except ValueError, e:

View File

@ -276,7 +276,7 @@ def adb_shell(device, command, timeout=None, check_exit_code=False, as_root=Fals
full_command = 'adb {} shell "{}"'.format(device_string, escape_double_quotes(command))
logger.debug(full_command)
if check_exit_code:
actual_command = "adb {} shell '({}); echo; echo $?'".format(device_string, escape_single_quotes(command))
actual_command = "adb {} shell '({}); echo \"\n$?\"'".format(device_string, escape_single_quotes(command))
try:
raw_output, error = check_output(actual_command, timeout, shell=True)
except CalledProcessErrorWithStderr as e:

View File

@ -22,9 +22,10 @@ HWMON_ROOT = '/sys/class/hwmon'
class HwmonSensor(object):
def __init__(self, device, kind, label, filepath):
def __init__(self, device, kind, device_name, label, filepath):
self.device = device
self.kind = kind
self.device_name = device_name
self.label = label
self.filepath = filepath
self.readings = []
@ -58,10 +59,10 @@ def discover_sensors(device, sensor_kinds):
for hwmon_device in hwmon_devices:
try:
device_path = path.join(HWMON_ROOT, hwmon_device, 'device')
name = device.get_sysfile_value(path.join(device_path, 'name'))
base_name = device.get_sysfile_value(path.join(device_path, 'name'))
except DeviceError: # probably a virtual device
device_path = path.join(HWMON_ROOT, hwmon_device)
name = device.get_sysfile_value(path.join(device_path, 'name'))
base_name = device.get_sysfile_value(path.join(device_path, 'name'))
for sensor_kind in sensor_kinds:
i = 1
@ -69,9 +70,17 @@ def discover_sensors(device, sensor_kinds):
while device.file_exists(input_path):
label_path = path.join(device_path, '{}{}_label'.format(sensor_kind, i))
if device.file_exists(label_path):
name += ' ' + device.get_sysfile_value(label_path)
sensors.append(HwmonSensor(device, sensor_kind, name, input_path))
sensors.append(HwmonSensor(device,
sensor_kind,
base_name,
device.get_sysfile_value(label_path),
input_path))
else:
sensors.append(HwmonSensor(device,
sensor_kind,
base_name,
"{}{}".format(sensor_kind, i),
input_path))
i += 1
input_path = path.join(device_path, '{}{}_input'.format(sensor_kind, i))
return sensors