aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFabien Lahoudere <fabien.lahoudere@collabora.com>2020-01-17 12:36:13 +0100
committerEnric Balletbo i Serra <enric.balletbo@collabora.com>2020-01-23 14:47:37 +0100
commit89b90b09a0eeedfe0afde5c688cd9831db486a56 (patch)
tree11f2d9562683020a5509eb92e1bcc04b8b9a28e3
parent6813e889c71c5c8c14ccacd6d11add8ac0bd99db (diff)
downloadcros-ec-tests-89b90b09a0eeedfe0afde5c688cd9831db486a56.tar.gz
test_cros_ec_hello: Deploy hello test to all MCUs
We want to ensure that all available MCUs reply to the basic hello command. Signed-off-by: Fabien Lahoudere <fabien.lahoudere@collabora.com> Signed-off-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>
-rw-r--r--cros/helpers/mcu.py27
-rw-r--r--cros/tests/cros_ec_mcu.py27
2 files changed, 37 insertions, 17 deletions
diff --git a/cros/helpers/mcu.py b/cros/helpers/mcu.py
index 2fc6e96..6ea7b28 100644
--- a/cros/helpers/mcu.py
+++ b/cros/helpers/mcu.py
@@ -136,3 +136,30 @@ def check_mcu_abi(s, name):
sysfs_check_attributes_exists(
s, "/sys/class/chromeos/", "cros_" + name, files, False
)
+
+
+def mcu_hello(s, name):
+ """ Checks basic comunication with MCU. """
+ if not os.path.exists("/dev/" + name):
+ s.skipTest("MCU " + name + " not present, skipping")
+ fd = open("/dev/" + name, "r")
+ param = ec_params_hello()
+ param.in_data = 0xA0B0C0D0 # magic number that the EC expects on HELLO
+
+ response = ec_response_hello()
+
+ cmd = cros_ec_command()
+ cmd.version = 0
+ cmd.command = EC_CMD_HELLO
+ cmd.insize = sizeof(param)
+ cmd.outsize = sizeof(response)
+
+ memmove(addressof(cmd.data), addressof(param), cmd.insize)
+ fcntl.ioctl(fd, EC_DEV_IOCXCMD, cmd)
+ memmove(addressof(response), addressof(cmd.data), cmd.outsize)
+
+ fd.close()
+
+ s.assertEqual(cmd.result, 0)
+ # magic number that the EC answers on HELLO
+ s.assertEqual(response.out_data, 0xA1B2C3D4)
diff --git a/cros/tests/cros_ec_mcu.py b/cros/tests/cros_ec_mcu.py
index 06fc96f..aed158a 100644
--- a/cros/tests/cros_ec_mcu.py
+++ b/cros/tests/cros_ec_mcu.py
@@ -29,24 +29,17 @@ class TestCrosECMCU(unittest.TestCase):
def test_cros_ec_hello(self):
""" Checks basic comunication with the main Embedded controller. """
- fd = open("/dev/cros_ec", "r")
- param = ec_params_hello()
- param.in_data = 0xA0B0C0D0 # magic number that the EC expects on HELLO
+ mcu_hello(self, "cros_ec")
- response = ec_response_hello()
+ def test_cros_fp_hello(self):
+ """ Checks basic comunication with the fingerprint controller. """
+ mcu_hello(self, "cros_fp")
- cmd = cros_ec_command()
- cmd.version = 0
- cmd.command = EC_CMD_HELLO
- cmd.insize = sizeof(param)
- cmd.outsize = sizeof(response)
+ def test_cros_tp_hello(self):
+ """ Checks basic comunication with the touchpad controller. """
+ mcu_hello(self, "cros_tp")
- memmove(addressof(cmd.data), addressof(param), cmd.outsize)
- fcntl.ioctl(fd, EC_DEV_IOCXCMD, cmd)
- memmove(addressof(response), addressof(cmd.data), cmd.insize)
+ def test_cros_pd_hello(self):
+ """ Checks basic comunication with the power delivery controller. """
+ mcu_hello(self, "cros_pd")
- fd.close()
-
- self.assertEqual(cmd.result, 0)
- # magic number that the EC answers on HELLO
- self.assertEqual(response.out_data, 0xA1B2C3D4)