Lines Matching +full:class +full:- +full:utils
3 # Use of this source code is governed by a BSD-style license that can be
12 from autotest_lib.client.bin import utils
40 http://www.intel.com/content/www/us/en/processors/processor-numbers.html
46 cpuinfo = utils.read_file('/proc/cpuinfo')
48 if re.search(r'AMD.*[AE][269]-9[0-9][0-9][0-9].*RADEON.*R[245]', cpuinfo):
52 if re.search(r'Intel.*Atom.*[NZ][2-6]', cpuinfo):
54 if re.search(r'Intel.*Celeron.*N2[89][0-9][0-9]', cpuinfo):
56 if re.search(r'Intel.*Celeron.*N3[0-9][0-9][0-9]', cpuinfo):
58 if re.search(r'Intel.*Celeron.*[0-9]{3,4}', cpuinfo):
60 # https://ark.intel.com/products/series/94028/5th-Generation-Intel-Core-M-Processors
61 # https://ark.intel.com/products/series/94025/6th-Generation-Intel-Core-m-Processors
62 # https://ark.intel.com/products/series/95542/7th-Generation-Intel-Core-m-Processors
63 if re.search(r'Intel.*Core.*[mM][357]-[567][Y0-9][0-9][0-9]', cpuinfo):
65 if re.search(r'Intel.*Core.*i[357]-[234][0-9][0-9][0-9]', cpuinfo):
83 rapl_set = set(["Haswell", "Haswell-E", "Broadwell", "Skylake", "Goldmont",
86 cpu_uarch = utils.get_intel_cpu_uarch()
101 return os.path.isdir('/sys/devices/virtual/powercap/intel-rapl/')
118 command = ('dbus-send --type=method_call --system '
119 '--dest=%s %s %s.%s %s') % (destination, path, interface,
121 utils.system_output(command)
152 psu = utils.system_output('cros_config /hardware-properties psu-type')
169 cmd = 'check_powerd_config --suspend_to_idle'
170 result = utils.run(cmd, ignore_status=True)
184 """Get the percent-based low-battery shutdown threshold.
187 Float, percent-based low-battery shutdown threshold. 0 if error.
191 command = 'check_powerd_config --low_battery_shutdown_percent'
192 ret = float(utils.run(command).stdout)
208 return utils.run(command, ignore_status=True).exit_status == 0
222 error.CmdError: if ectool returns non-zero exit status.
228 utils.run(ec_cmd_normal)
230 utils.run(ec_cmd_discharge)
252 error.CmdError: if ectool returns non-zero exit status.
264 Remove the following types of non-important keyvals.
265 - Minor checkpoints. (start with underscore)
266 - Individual cpu / gpu frequency buckets.
268 - Specific idle states from cpuidle/cpupkg.
269 (regex '.*cpu(idle|pkg)[ABD-Za-z0-9_\-]+C[^0].*')
272 keyvals: keyvals to remove non-important ones.
275 Dictionary, keyvals with non-important ones removed.
280 .*cpu(idle|pkg)[ABD-Za-z0-9_\-]+C[^0].*
290 return {'encoding': 'utf-8'}
295 class BacklightException(Exception):
296 """Class for Backlight exceptions."""
299 class Backlight(object):
300 """Class for control of built-in panel backlight.
327 # See http://www.chromium.org/chromium-os/testing/power-testing for more
349 force_battery_arg = "--force_battery " if force_battery else ""
350 cmd = ("backlight_tool --get_initial_brightness --lux=150 " +
353 level = float(utils.system_output(cmd).rstrip())
375 error.TestFail: if 'cmd' returns non-zero exit status.
382 return utils.system_output(cmd).rstrip()
392 self._try_bl_cmd('--set_brightness=%d' % (level))
400 self._try_bl_cmd('--set_brightness_percent=%f' % (percent))
413 return int(self._try_bl_cmd('--get_brightness'))
421 return int(self._try_bl_cmd('--get_max_brightness'))
429 return float(self._try_bl_cmd('--get_brightness_percent'))
437 return float(self._try_bl_cmd('--linear_to_nonlinear=%f' % linear))
445 return float(self._try_bl_cmd('--nonlinear_to_linear=%f' % nonlinear))
453 class KbdBacklightException(Exception):
454 """Class for KbdBacklight exceptions."""
457 class KbdBacklight(object):
458 """Class for control of keyboard backlight.
477 cmd = 'check_powerd_config --keyboard_backlight'
478 result = utils.run(cmd, ignore_status=True)
483 cmd = ("backlight_tool --keyboard --get_initial_brightness "
484 "--lux=0 2>/dev/null")
486 utils.system_output(cmd).rstrip())
498 cmd = 'backlight_tool --keyboard --get_brightness_percent'
499 return float(utils.system_output(cmd).strip())
517 cmd = 'backlight_tool --keyboard --set_brightness_percent=%f' % percent
518 utils.system(cmd)
526 cmd = 'backlight_tool --keyboard --set_brightness=%d' % level
527 utils.system(cmd)
530 class BacklightController(object):
531 """Class to simulate control of backlight via keyboard or Chrome UI.
602 class DisplayException(Exception):
603 """Class for Display exceptions."""
626 class PowerPrefChanger(object):
628 Class to temporarily change powerd prefs. Construct with a dict of
638 utils.write_one_line('%s/%s' % (self._TEMPDIR, name), value)
639 utils.system('mount --bind %s %s' % (self._TEMPDIR, self._PREFDIR))
645 utils.system('umount %s' % self._PREFDIR, ignore_status=True)
653 class Registers(object):
654 """Class to examine PCI and MSR registers."""
671 self._mch_bar = int(utils.system_output(cmd), 16) & 0xfffffffe
679 self._dmi_bar = int(utils.system_output(cmd), 16) & 0xfffffffe
684 return int(utils.system_output(cmd), 16)
688 return int(utils.system_output(cmd), 16)
712 mask = (1 << (hi_bit - lo_bit + 1)) - 1
744 for cpu_id in range(0, max(utils.count_cpus(), 1)):
774 class USBDevicePower(object):
775 """Class for USB device related power information.
784 allowlisted: Boolean if USB device is allowlisted for USB auto-suspend
806 out = utils.read_one_line(control_file)
811 class USBPower(object):
812 """Class to expose USB related power functionality.
814 Initially that includes the policy around USB auto-suspend and our
828 auto-suspend
832 _alist_file: path to laptop-mode-tools (LMT) USB autosuspend
842 '/etc/laptop-mode/conf.d/board-specific/usb-autosuspend.conf'
844 # and should be updated when possible. ("WHITELIST" -> "ALLOWLIST") # nocheck
852 CrOS allowlist only internal USB devices to enter USB auto-suspend mode
853 via laptop-mode tools.
857 out = utils.system_output(cmd, ignore_status=True)
894 vid = utils.read_one_line(vid_path)
895 pid = utils.read_one_line(pid_path)
900 class DisplayPanelSelfRefresh(object):
901 """Class for control and monitoring of display's PSR."""
912 _init_time: time when PSR class was instantiated.
941 count = utils.get_field(utils.read_file(self._psr_path),
953 @returns: PSR residency in percent or -1 if not able to calculate.
956 return -1
958 tdelta = time.time() - self._init_time
959 cdelta = self._get_counter() - self._init_counter
974 class BaseActivityException(Exception):
975 """Class for base activity simulation exceptions."""
978 class BaseActivitySimulator(object):
979 """Class to simulate wake activity on the normally autosuspended base."""
981 # Note on naming: throughout this class, the word base is used to mean the
988 _BASE_INIT_CMD = 'cros_config /detachable-base usb-path'
1005 init_file_content = utils.read_file(self._BASE_INIT_FILE)
1007 # The string can be like: env USB_PATH="1-1.1"
1008 path = re.search(r'env USB_PATH=\"?([0-9.-]+)\"?',
1020 result = utils.run(self._BASE_INIT_CMD, ignore_status=True)