|
| 1 | +import unittest |
| 2 | +from cros_ec_python import CrOS_EC, DeviceTypes, general |
| 3 | +from cros_ec_python.constants import MEMMAP |
| 4 | + |
| 5 | +ec: CrOS_EC | None = None |
| 6 | + |
| 7 | + |
| 8 | +class TestLinuxDev(unittest.TestCase): |
| 9 | + def test1_init(self): |
| 10 | + global ec |
| 11 | + ec = CrOS_EC(DeviceTypes.LinuxDev) |
| 12 | + self.assertIsNotNone(ec) |
| 13 | + |
| 14 | + def test2_memmap(self): |
| 15 | + resp = ec.memmap(MEMMAP.EC_MEMMAP_ID, 2) |
| 16 | + self.assertEqual(resp, b'EC') |
| 17 | + |
| 18 | + def test3_hello(self): |
| 19 | + data = b'ECEC' |
| 20 | + resp = ec.command(0, general.EC_CMD_HELLO, len(data), 4, data) |
| 21 | + self.assertEqual(resp, (int.from_bytes(data, "little") + 0x01020304).to_bytes(4, "little")) |
| 22 | + |
| 23 | + |
| 24 | +class TestLPC(unittest.TestCase): |
| 25 | + def test1_init(self): |
| 26 | + global ec |
| 27 | + ec = CrOS_EC(DeviceTypes.LPC, address=0xE00) |
| 28 | + self.assertIsNotNone(ec) |
| 29 | + |
| 30 | + def test2_memmap(self): |
| 31 | + resp = ec.memmap(MEMMAP.EC_MEMMAP_ID, 2) |
| 32 | + self.assertEqual(resp, b'EC') |
| 33 | + |
| 34 | + @unittest.skip("Not implemented") |
| 35 | + def test3_hello(self): |
| 36 | + data = b'ECEC' |
| 37 | + resp = ec.command(0, general.EC_CMD_HELLO, len(data), 4, data) |
| 38 | + self.assertEqual(resp, (int.from_bytes(data, "little") + 0x01020304).to_bytes(4, "little")) |
| 39 | + |
| 40 | + |
| 41 | +if __name__ == '__main__': |
| 42 | + unittest.main() |
0 commit comments