aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEnric Balletbo i Serra <enric.balletbo@collabora.com>2019-12-20 11:08:55 +0100
committerEnric Balletbo i Serra <enric.balletbo@collabora.com>2019-12-23 17:13:53 +0100
commit11e177b1d5a864e4916daae78d9fe78a96306bf6 (patch)
treeb35c96b97251235ec4b0ba081ef0e0fba55ac7fe
parent8b30644dad48eec907d6800a4e49aefd3e5428a5 (diff)
downloadcros-ec-tests-11e177b1d5a864e4916daae78d9fe78a96306bf6.tar.gz
Autoformat the code to conform with PEP 8 using 'black'
'black' is a program that autoformats code following most of the rules in PEP 8. Run that program in order to autformat current files. Install 'black' using pip. It requires Python 3.6+ to run: $ pip install black Signed-off-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>
-rw-r--r--helpers/kernel.py7
-rw-r--r--helpers/mcu.py148
-rw-r--r--helpers/sysfs.py6
-rwxr-xr-xrunners/lava_runner.py32
-rw-r--r--tests/cros_ec_accel.py49
-rw-r--r--tests/cros_ec_extcon.py13
-rw-r--r--tests/cros_ec_gyro.py41
-rw-r--r--tests/cros_ec_mcu.py16
-rw-r--r--tests/cros_ec_power.py53
-rw-r--r--tests/cros_ec_pwm.py19
-rw-r--r--tests/cros_ec_rtc.py19
11 files changed, 249 insertions, 154 deletions
diff --git a/helpers/kernel.py b/helpers/kernel.py
index 2b57db1..5e9ef65 100644
--- a/helpers/kernel.py
+++ b/helpers/kernel.py
@@ -6,18 +6,21 @@ def version_to_int(version, major, minor):
pattern = "{0:03d}{1:03d}{2:03d}"
return int(pattern.format(version, major, minor))
+
# Return the running kernel version
def current_kernel_version():
- fd = open("/proc/version", 'r')
- current = fd.read().split()[2].split('-')[0].split('.')
+ fd = open("/proc/version", "r")
+ current = fd.read().split()[2].split("-")[0].split(".")
fd.close()
return version_to_int(int(current[0]), int(current[1]), int(current[2]))
+
def kernel_lower_than(version, major, minor):
if version_to_int(version, major, minor) > current_kernel_version():
return True
return False
+
def kernel_greater_than(version, major, minor):
if version_to_int(version, major, minor) < current_kernel_version():
return True
diff --git a/helpers/mcu.py b/helpers/mcu.py
index 6dc2df4..3bfca58 100644
--- a/helpers/mcu.py
+++ b/helpers/mcu.py
@@ -6,99 +6,99 @@ import os
from helpers.sysfs import *
from ctypes import *
-EC_CMD_PROTO_VERSION = 0x0000
-EC_CMD_HELLO = 0x0001
-EC_CMD_GET_VERSION = 0x0002
-EC_CMD_GET_FEATURES = 0x000D
+EC_CMD_PROTO_VERSION = 0x0000
+EC_CMD_HELLO = 0x0001
+EC_CMD_GET_VERSION = 0x0002
+EC_CMD_GET_FEATURES = 0x000D
-EC_HOST_PARAM_SIZE = 0xfc
+EC_HOST_PARAM_SIZE = 0xFC
-EC_DEV_IOCXCMD = 0xc014ec00 # _IOWR(EC_DEV_IOC, 0, struct cros_ec_command)
+EC_DEV_IOCXCMD = 0xC014EC00 # _IOWR(EC_DEV_IOC, 0, struct cros_ec_command)
-ECFEATURES = -1
+ECFEATURES = -1
# Supported features
-EC_FEATURE_LIMITED = 0
-EC_FEATURE_FLASH = 1
-EC_FEATURE_PWM_FAN = 2
-EC_FEATURE_PWM_KEYB = 3
-EC_FEATURE_LIGHTBAR = 4
-EC_FEATURE_LED = 5
-EC_FEATURE_MOTION_SENSE = 6
-EC_FEATURE_KEYB = 7
-EC_FEATURE_PSTORE = 8
-EC_FEATURE_PORT80 = 9
-EC_FEATURE_THERMAL = 10
-EC_FEATURE_BKLIGHT_SWITCH = 11
-EC_FEATURE_WIFI_SWITCH = 12
-EC_FEATURE_HOST_EVENTS = 13
-EC_FEATURE_GPIO = 14
-EC_FEATURE_I2C = 15
-EC_FEATURE_CHARGER = 16
-EC_FEATURE_BATTERY = 17
-EC_FEATURE_SMART_BATTERY = 18
-EC_FEATURE_HANG_DETECT = 19
-EC_FEATURE_PMU = 20
-EC_FEATURE_SUB_MCU = 21
-EC_FEATURE_USB_PD = 22
-EC_FEATURE_USB_MUX = 23
-EC_FEATURE_MOTION_SENSE_FIFO = 24
-EC_FEATURE_VSTORE = 25
-EC_FEATURE_USBC_SS_MUX_VIRTUAL = 26
-EC_FEATURE_RTC = 27
-EC_FEATURE_FINGERPRINT = 28
-EC_FEATURE_TOUCHPAD = 29
-EC_FEATURE_RWSIG = 30
-EC_FEATURE_DEVICE_EVENT = 31
-EC_FEATURE_UNIFIED_WAKE_MASKS = 32
-EC_FEATURE_HOST_EVENT64 = 33
-EC_FEATURE_EXEC_IN_RAM = 34
-EC_FEATURE_CEC = 35
-EC_FEATURE_MOTION_SENSE_TIGHT_TIMESTAMPS = 36
-EC_FEATURE_REFINED_TABLET_MODE_HYSTERESIS = 37
-EC_FEATURE_SCP = 39
-EC_FEATURE_ISH = 40
+EC_FEATURE_LIMITED = 0
+EC_FEATURE_FLASH = 1
+EC_FEATURE_PWM_FAN = 2
+EC_FEATURE_PWM_KEYB = 3
+EC_FEATURE_LIGHTBAR = 4
+EC_FEATURE_LED = 5
+EC_FEATURE_MOTION_SENSE = 6
+EC_FEATURE_KEYB = 7
+EC_FEATURE_PSTORE = 8
+EC_FEATURE_PORT80 = 9
+EC_FEATURE_THERMAL = 10
+EC_FEATURE_BKLIGHT_SWITCH = 11
+EC_FEATURE_WIFI_SWITCH = 12
+EC_FEATURE_HOST_EVENTS = 13
+EC_FEATURE_GPIO = 14
+EC_FEATURE_I2C = 15
+EC_FEATURE_CHARGER = 16
+EC_FEATURE_BATTERY = 17
+EC_FEATURE_SMART_BATTERY = 18
+EC_FEATURE_HANG_DETECT = 19
+EC_FEATURE_PMU = 20
+EC_FEATURE_SUB_MCU = 21
+EC_FEATURE_USB_PD = 22
+EC_FEATURE_USB_MUX = 23
+EC_FEATURE_MOTION_SENSE_FIFO = 24
+EC_FEATURE_VSTORE = 25
+EC_FEATURE_USBC_SS_MUX_VIRTUAL = 26
+EC_FEATURE_RTC = 27
+EC_FEATURE_FINGERPRINT = 28
+EC_FEATURE_TOUCHPAD = 29
+EC_FEATURE_RWSIG = 30
+EC_FEATURE_DEVICE_EVENT = 31
+EC_FEATURE_UNIFIED_WAKE_MASKS = 32
+EC_FEATURE_HOST_EVENT64 = 33
+EC_FEATURE_EXEC_IN_RAM = 34
+EC_FEATURE_CEC = 35
+EC_FEATURE_MOTION_SENSE_TIGHT_TIMESTAMPS = 36
+EC_FEATURE_REFINED_TABLET_MODE_HYSTERESIS = 37
+EC_FEATURE_SCP = 39
+EC_FEATURE_ISH = 40
+
class cros_ec_command(Structure):
_fields_ = [
- ('version', c_uint),
- ('command', c_uint),
- ('outsize', c_uint),
- ('insize', c_uint),
- ('result', c_uint),
- ('data', c_ubyte * EC_HOST_PARAM_SIZE)
+ ("version", c_uint),
+ ("command", c_uint),
+ ("outsize", c_uint),
+ ("insize", c_uint),
+ ("result", c_uint),
+ ("data", c_ubyte * EC_HOST_PARAM_SIZE),
]
+
class ec_params_hello(Structure):
- _fields_ = [
- ('in_data', c_uint)
- ]
+ _fields_ = [("in_data", c_uint)]
+
class ec_response_hello(Structure):
- _fields_ = [
- ('out_data', c_uint)
- ]
+ _fields_ = [("out_data", c_uint)]
+
class ec_params_get_features(Structure):
- _fields_ = [
- ('in_data', c_ulong)
- ]
+ _fields_ = [("in_data", c_ulong)]
+
class ec_response_get_features(Structure):
- _fields_ = [
- ('out_data', c_ulong)
- ]
+ _fields_ = [("out_data", c_ulong)]
+
def EC_FEATURE_MASK_0(event_code):
- return (1 << (event_code % 32))
+ return 1 << (event_code % 32)
+
def EC_FEATURE_MASK_1(event_code):
- return (1 << (event_code - 32))
+ return 1 << (event_code - 32)
+
def is_feature_supported(feature):
global ECFEATURES
if ECFEATURES == -1:
- fd = open("/dev/cros_ec", 'r')
+ fd = open("/dev/cros_ec", "r")
param = ec_params_get_features()
response = ec_response_get_features()
@@ -122,9 +122,11 @@ def is_feature_supported(feature):
return (ECFEATURES & EC_FEATURE_MASK_0(feature)) > 0
-def check_mcu_abi(s, name):
- if not os.path.exists("/dev/cros_" + name):
- s.skipTest("MCU " + name + " not supported, skipping")
- files = ["flashinfo", "reboot", "version"]
- sysfs_check_attributes_exists(s, "/sys/class/chromeos/", "cros_" + name, files, False)
+def check_mcu_abi(s, name):
+ if not os.path.exists("/dev/cros_" + name):
+ s.skipTest("MCU " + name + " not supported, skipping")
+ files = ["flashinfo", "reboot", "version"]
+ sysfs_check_attributes_exists(
+ s, "/sys/class/chromeos/", "cros_" + name, files, False
+ )
diff --git a/helpers/sysfs.py b/helpers/sysfs.py
index 2a0f4c2..0700c01 100644
--- a/helpers/sysfs.py
+++ b/helpers/sysfs.py
@@ -3,17 +3,19 @@
import os
+
def read_file(name):
- fd = open(name, 'r')
+ fd = open(name, "r")
contents = fd.read()
fd.close()
return contents
+
def sysfs_check_attributes_exists(s, path, name, files, check_devtype):
match = 0
for devname in os.listdir(path):
if check_devtype:
- fd = open(path + "/" + devname + "/name", 'r')
+ fd = open(path + "/" + devname + "/name", "r")
devtype = fd.read()
fd.close()
if not devtype.startswith(name):
diff --git a/runners/lava_runner.py b/runners/lava_runner.py
index 6b57f4b..b94ce8c 100755
--- a/runners/lava_runner.py
+++ b/runners/lava_runner.py
@@ -12,30 +12,38 @@ from tests.cros_ec_rtc import *
from tests.cros_ec_power import *
from tests.cros_ec_extcon import *
-class LavaTextTestResult(unittest.TestResult):
+class LavaTextTestResult(unittest.TestResult):
def __init__(self, runner):
unittest.TestResult.__init__(self)
self.runner = runner
def addSuccess(self, test):
unittest.TestResult.addSuccess(self, test)
- self.runner.writeUpdate("<LAVA_SIGNAL_TESTCASE TEST_CASE_ID=%s RESULT=pass>\n" % test.id())
+ self.runner.writeUpdate(
+ "<LAVA_SIGNAL_TESTCASE TEST_CASE_ID=%s RESULT=pass>\n" % test.id()
+ )
def addError(self, test, err):
unittest.TestResult.addError(self, test, err)
- self.runner.writeUpdate("<LAVA_SIGNAL_TESTCASE TEST_CASE_ID=%s RESULT=unknown>\n" % test.id())
+ self.runner.writeUpdate(
+ "<LAVA_SIGNAL_TESTCASE TEST_CASE_ID=%s RESULT=unknown>\n" % test.id()
+ )
def addFailure(self, test, err):
unittest.TestResult.addFailure(self, test, err)
- self.runner.writeUpdate("<LAVA_SIGNAL_TESTCASE TEST_CASE_ID=%s RESULT=fail>\n" % test.id())
+ self.runner.writeUpdate(
+ "<LAVA_SIGNAL_TESTCASE TEST_CASE_ID=%s RESULT=fail>\n" % test.id()
+ )
def addSkip(self, test, reason):
unittest.TestResult.addSkip(self, test, reason)
- self.runner.writeUpdate("<LAVA_SIGNAL_TESTCASE TEST_CASE_ID=%s RESULT=skip>\n" % test.id())
+ self.runner.writeUpdate(
+ "<LAVA_SIGNAL_TESTCASE TEST_CASE_ID=%s RESULT=skip>\n" % test.id()
+ )
-class LavaTestRunner:
+class LavaTestRunner:
def __init__(self, stream=sys.stderr, verbosity=0):
self.stream = stream
self.verbosity = verbosity
@@ -49,9 +57,13 @@ class LavaTestRunner:
result.testsRun
return result
-if __name__ == '__main__':
- unittest.main(testRunner=LavaTestRunner(),
+
+if __name__ == "__main__":
+ unittest.main(
+ testRunner=LavaTestRunner(),
# these make sure that some options that are not applicable
# remain hidden from the help menu.
- failfast=False, buffer=False, catchbreak=False)
-
+ failfast=False,
+ buffer=False,
+ catchbreak=False,
+ )
diff --git a/tests/cros_ec_accel.py b/tests/cros_ec_accel.py
index 06f328a..6d20d79 100644
--- a/tests/cros_ec_accel.py
+++ b/tests/cros_ec_accel.py
@@ -6,32 +6,48 @@ from helpers.kernel import *
import math
import unittest
-class TestCrosECAccel(unittest.TestCase):
+class TestCrosECAccel(unittest.TestCase):
def test_cros_ec_accel_iio_abi(self):
- files = [ "buffer", "calibrate", "current_timestamp_clock", "id",
- "in_accel_x_calibbias", "in_accel_x_calibscale",
- "in_accel_x_raw", "in_accel_y_calibbias",
- "in_accel_y_calibscale", "in_accel_y_raw",
- "in_accel_z_calibbias", "in_accel_z_calibscale",
- "in_accel_z_raw", "location", "sampling_frequency",
- "sampling_frequency_available", "scale",
- "scan_elements/", "trigger/"]
- sysfs_check_attributes_exists( self, "/sys/bus/iio/devices", "cros-ec-accel", files, True)
- if kernel_greater_than(5,4,0):
- sysfs_check_attributes_exists( self, "/sys/bus/iio/devices", "cros-ec-accel", ["frequency"], True)
-
+ files = [
+ "buffer",
+ "calibrate",
+ "current_timestamp_clock",
+ "id",
+ "in_accel_x_calibbias",
+ "in_accel_x_calibscale",
+ "in_accel_x_raw",
+ "in_accel_y_calibbias",
+ "in_accel_y_calibscale",
+ "in_accel_y_raw",
+ "in_accel_z_calibbias",
+ "in_accel_z_calibscale",
+ "in_accel_z_raw",
+ "location",
+ "sampling_frequency",
+ "sampling_frequency_available",
+ "scale",
+ "scan_elements/",
+ "trigger/",
+ ]
+ sysfs_check_attributes_exists(
+ self, "/sys/bus/iio/devices", "cros-ec-accel", files, True
+ )
+ if kernel_greater_than(5, 4, 0):
+ sysfs_check_attributes_exists(
+ self, "/sys/bus/iio/devices", "cros-ec-accel", ["frequency"], True
+ )
# This function validate accelerometer data by computing the magnitude.
# If the magnitude is not closed to 1G, that means data are invalid or
# the machine is in movement or there is a earth quake.
def test_cros_ec_accel_iio_data_is_valid(self):
ACCEL_1G_IN_MS2 = 9.8185
- ACCEL_MAG_VALID_OFFSET = .25
+ ACCEL_MAG_VALID_OFFSET = 0.25
match = 0
for devname in os.listdir("/sys/bus/iio/devices"):
base_path = "/sys/bus/iio/devices/" + devname + "/"
- fd = open(base_path + "name", 'r')
+ fd = open(base_path + "name", "r")
devtype = fd.read()
if devtype.startswith("cros-ec-accel"):
location = read_file(base_path + "location")
@@ -39,7 +55,7 @@ class TestCrosECAccel(unittest.TestCase):
exp = ACCEL_1G_IN_MS2
err = exp * ACCEL_MAG_VALID_OFFSET
mag = 0
- for axis in ['x', 'y', 'z']:
+ for axis in ["x", "y", "z"]:
axis_path = base_path + "in_accel_" + axis + "_raw"
value = int(read_file(axis_path))
value *= accel_scale
@@ -50,4 +66,3 @@ class TestCrosECAccel(unittest.TestCase):
fd.close()
if match == 0:
self.skipTest("No accelerometer found, skipping")
-
diff --git a/tests/cros_ec_extcon.py b/tests/cros_ec_extcon.py
index 2e31e79..073471f 100644
--- a/tests/cros_ec_extcon.py
+++ b/tests/cros_ec_extcon.py
@@ -4,16 +4,23 @@
from helpers.sysfs import *
import unittest
+
class TestCrosECextcon(unittest.TestCase):
def test_cros_ec_extcon_usbc_abi(self):
match = 0
for devname in os.listdir("/sys/class/extcon"):
devtype = read_file("/sys/class/extcon/" + devname + "/name")
if ".spi:ec@0:extcon@" in devtype:
- self.assertEqual(os.path.exists("/sys/class/extcon/" + devname + "/state"), 1)
+ self.assertEqual(
+ os.path.exists("/sys/class/extcon/" + devname + "/state"), 1
+ )
for cable in os.listdir("/sys/class/extcon/" + devname):
- self.assertEqual(os.path.exists("/sys/class/extcon/" + devname + "/name"), 1)
- self.assertEqual(os.path.exists("/sys/class/extcon/" + devname + "/state"), 1)
+ self.assertEqual(
+ os.path.exists("/sys/class/extcon/" + devname + "/name"), 1
+ )
+ self.assertEqual(
+ os.path.exists("/sys/class/extcon/" + devname + "/state"), 1
+ )
match += 1
if match == 0:
self.skipTest("No extcon device found, skipping")
diff --git a/tests/cros_ec_gyro.py b/tests/cros_ec_gyro.py
index 9427e62..8d11b18 100644
--- a/tests/cros_ec_gyro.py
+++ b/tests/cros_ec_gyro.py
@@ -5,17 +5,34 @@ from helpers.sysfs import *
from helpers.kernel import *
import unittest
-class TestCrosECGyro(unittest.TestCase):
+class TestCrosECGyro(unittest.TestCase):
def test_cros_ec_gyro_iio_abi(self):
- files = [ "buffer/", "calibrate", "current_timestamp_clock", "id",
- "in_anglvel_x_calibbias", "in_anglvel_x_calibscale",
- "in_anglvel_x_raw", "in_anglvel_y_calibbias",
- "in_anglvel_y_calibscale", "in_anglvel_y_raw",
- "in_anglvel_z_calibbias", "in_anglvel_z_calibscale",
- "in_anglvel_z_raw", "location", "sampling_frequency",
- "sampling_frequency_available", "scale",
- "scan_elements/", "trigger/"]
- sysfs_check_attributes_exists( self, "/sys/bus/iio/devices", "cros-ec-gyro", files, True)
- if kernel_greater_than(5,4,0):
- sysfs_check_attributes_exists( self, "/sys/bus/iio/devices", "cros-ec-gyro", ["frequency"], True)
+ files = [
+ "buffer/",
+ "calibrate",
+ "current_timestamp_clock",
+ "id",
+ "in_anglvel_x_calibbias",
+ "in_anglvel_x_calibscale",
+ "in_anglvel_x_raw",
+ "in_anglvel_y_calibbias",
+ "in_anglvel_y_calibscale",
+ "in_anglvel_y_raw",
+ "in_anglvel_z_calibbias",
+ "in_anglvel_z_calibscale",
+ "in_anglvel_z_raw",
+ "location",
+ "sampling_frequency",
+ "sampling_frequency_available",
+ "scale",
+ "scan_elements/",
+ "trigger/",
+ ]
+ sysfs_check_attributes_exists(
+ self, "/sys/bus/iio/devices", "cros-ec-gyro", files, True
+ )
+ if kernel_greater_than(5, 4, 0):
+ sysfs_check_attributes_exists(
+ self, "/sys/bus/iio/devices", "cros-ec-gyro", ["frequency"], True
+ )
diff --git a/tests/cros_ec_mcu.py b/tests/cros_ec_mcu.py
index 92ca69a..1b5bb51 100644
--- a/tests/cros_ec_mcu.py
+++ b/tests/cros_ec_mcu.py
@@ -5,26 +5,27 @@ from helpers.mcu import *
import fcntl
import unittest
+
class TestCrosECMCU(unittest.TestCase):
def test_cros_ec_abi(self):
- check_mcu_abi(self, "ec");
+ check_mcu_abi(self, "ec")
def test_cros_fp_abi(self):
- check_mcu_abi(self, "fp");
+ check_mcu_abi(self, "fp")
def test_cros_tp_abi(self):
- check_mcu_abi(self, "tp");
+ check_mcu_abi(self, "tp")
def test_cros_pd_abi(self):
- check_mcu_abi(self, "pd");
+ check_mcu_abi(self, "pd")
def test_cros_ec_chardev(self):
self.assertEqual(os.path.exists("/dev/cros_ec"), 1)
def test_cros_ec_hello(self):
- fd = open("/dev/cros_ec", 'r')
+ fd = open("/dev/cros_ec", "r")
param = ec_params_hello()
- param.in_data = 0xa0b0c0d0 # magic number that the EC expects on HELLO
+ param.in_data = 0xA0B0C0D0 # magic number that the EC expects on HELLO
response = ec_response_hello()
@@ -42,5 +43,4 @@ class TestCrosECMCU(unittest.TestCase):
self.assertEqual(cmd.result, 0)
# magic number that the EC answers on HELLO
- self.assertEqual(response.out_data, 0xa1b2c3d4)
-
+ self.assertEqual(response.out_data, 0xA1B2C3D4)
diff --git a/tests/cros_ec_power.py b/tests/cros_ec_power.py
index 4d34c3e..0515d4b 100644
--- a/tests/cros_ec_power.py
+++ b/tests/cros_ec_power.py
@@ -4,20 +4,47 @@
from helpers.sysfs import *
import unittest
+
class TestCrosECPower(unittest.TestCase):
def test_cros_ec_usbpd_charger_abi(self):
- files = [ "current_max", "input_current_limit",
- "input_voltage_limit", "manufacturer", "model_name",
- "online", "power/autosuspend_delay_ms", "status",
- "type", "usb_type", "voltage_max_design",
- "voltage_now"]
- sysfs_check_attributes_exists( self, "/sys/class/power_supply/", "CROS_USBPD_CHARGER", files, False)
+ files = [
+ "current_max",
+ "input_current_limit",
+ "input_voltage_limit",
+ "manufacturer",
+ "model_name",
+ "online",
+ "power/autosuspend_delay_ms",
+ "status",
+ "type",
+ "usb_type",
+ "voltage_max_design",
+ "voltage_now",
+ ]
+ sysfs_check_attributes_exists(
+ self, "/sys/class/power_supply/", "CROS_USBPD_CHARGER", files, False
+ )
def test_cros_ec_battery_abi(self):
- files = [ "alarm", "capacity_level", "charge_full_design",
- "current_now", "manufacturer", "serial_number",
- "type", "voltage_min_design", "capacity",
- "charge_full", "charge_now", "cycle_count",
- "model_name", "present", "status", "technology",
- "voltage_now"]
- sysfs_check_attributes_exists( self, "/sys/class/power_supply/", "BAT", files, False)
+ files = [
+ "alarm",
+ "capacity_level",
+ "charge_full_design",
+ "current_now",
+ "manufacturer",
+ "serial_number",
+ "type",
+ "voltage_min_design",
+ "capacity",
+ "charge_full",
+ "charge_now",
+ "cycle_count",
+ "model_name",
+ "present",
+ "status",
+ "technology",
+ "voltage_now",
+ ]
+ sysfs_check_attributes_exists(
+ self, "/sys/class/power_supply/", "BAT", files, False
+ )
diff --git a/tests/cros_ec_pwm.py b/tests/cros_ec_pwm.py
index e494b74..db084a6 100644
--- a/tests/cros_ec_pwm.py
+++ b/tests/cros_ec_pwm.py
@@ -4,18 +4,19 @@
from helpers.sysfs import *
import unittest
+
class TestCrosECPWM(unittest.TestCase):
def test_cros_ec_pwm_backlight(self):
if not os.path.exists("/sys/class/backlight/backlight/max_brightness"):
self.skipTest("No backlight pwm found, skipping")
is_ec_pwm = False
- fd = open("/sys/kernel/debug/pwm", 'r')
+ fd = open("/sys/kernel/debug/pwm", "r")
line = fd.readline()
while line and not is_ec_pwm:
- if line[0] != ' ' and ":ec-pwm" in line:
+ if line[0] != " " and ":ec-pwm" in line:
line = fd.readline()
while line:
- if line[0] == '\n':
+ if line[0] == "\n":
is_ec_pwm = False
break
if "backlight" in line:
@@ -26,22 +27,22 @@ class TestCrosECPWM(unittest.TestCase):
fd.close()
if not is_ec_pwm:
self.skipTest("No EC backlight pwm found, skipping")
- fd = open("/sys/class/backlight/backlight/max_brightness", 'r')
+ fd = open("/sys/class/backlight/backlight/max_brightness", "r")
brightness = int(int(fd.read()) / 2)
fd.close()
- fd = open("/sys/class/backlight/backlight/brightness", 'w')
+ fd = open("/sys/class/backlight/backlight/brightness", "w")
fd.write(str(brightness))
fd.close()
- fd = open("/sys/kernel/debug/pwm", 'r')
+ fd = open("/sys/kernel/debug/pwm", "r")
line = fd.readline()
while line:
if "backlight" in line:
start = line.find("duty") + 6
- self.assertNotEqual(start,5)
+ self.assertNotEqual(start, 5)
end = start + line[start:].find(" ")
- self.assertNotEqual(start,end)
+ self.assertNotEqual(start, end)
duty = int(line[start:end])
- self.assertNotEqual(duty,0)
+ self.assertNotEqual(duty, 0)
break
line = fd.readline()
fd.close()
diff --git a/tests/cros_ec_rtc.py b/tests/cros_ec_rtc.py
index 146f868..3aa05c1 100644
--- a/tests/cros_ec_rtc.py
+++ b/tests/cros_ec_rtc.py
@@ -5,19 +5,28 @@ from helpers.mcu import *
from helpers.sysfs import *
import unittest
+
class TestCrosECRTC(unittest.TestCase):
def test_cros_ec_rtc_abi(self):
if not is_feature_supported(EC_FEATURE_RTC):
self.skipTest("EC_FEATURE_RTC not supported, skipping")
match = 0
for devname in os.listdir("/sys/class/rtc"):
- fd = open("/sys/class/rtc/" + devname + "/name", 'r')
+ fd = open("/sys/class/rtc/" + devname + "/name", "r")
devtype = fd.read()
fd.close()
if devtype.startswith("cros-ec-rtc"):
- files = [ "date", "hctosys", "max_user_freq", "since_epoch",
- "time", "wakealarm" ]
+ files = [
+ "date",
+ "hctosys",
+ "max_user_freq",
+ "since_epoch",
+ "time",
+ "wakealarm",
+ ]
match += 1
for filename in files:
- self.assertEqual(os.path.exists("/sys/class/rtc/" + devname + "/" + filename), 1)
- self.assertNotEqual(match,0)
+ self.assertEqual(
+ os.path.exists("/sys/class/rtc/" + devname + "/" + filename), 1
+ )
+ self.assertNotEqual(match, 0)