diff options
author | Luca Weiss <luca@z3ntu.xyz> | 2021-12-25 14:25:56 +0100 |
---|---|---|
committer | David Gibson <david@gibson.dropbear.id.au> | 2021-12-28 15:30:33 +1100 |
commit | a04f69025003890be265e007238dc91041e5529b (patch) | |
tree | a430fdffa0454b20b05f3a6cf550c4ea963e94c1 /tests | |
parent | 83102717d7c4171aeb2d26941fa1ee2997bf4a7d (diff) | |
download | dtc-a04f69025003890be265e007238dc91041e5529b.zip dtc-a04f69025003890be265e007238dc91041e5529b.tar.gz dtc-a04f69025003890be265e007238dc91041e5529b.tar.bz2 |
pylibfdt: add Property.as_*int*_array()
Add new methods to handle decoding of int32, uint32, int64 and uint64
arrays.
Also add tests for the new methods.
Signed-off-by: Luca Weiss <luca@z3ntu.xyz>
Message-Id: <20211225132558.167123-3-luca@z3ntu.xyz>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/pylibfdt_tests.py | 11 | ||||
-rw-r--r-- | tests/test_props.dts | 4 |
2 files changed, 15 insertions, 0 deletions
diff --git a/tests/pylibfdt_tests.py b/tests/pylibfdt_tests.py index 7e3cc4c..5479363 100644 --- a/tests/pylibfdt_tests.py +++ b/tests/pylibfdt_tests.py @@ -382,6 +382,17 @@ class PyLibfdtBasicTests(unittest.TestCase): self.get_prop("prop-uint64").as_uint64()) self.assertEqual(-2, self.get_prop("prop-int64").as_int64()) + def testGetIntListProperties(self): + """Test that we can access properties as integer lists""" + self.assertEqual([128, -16, -2], + self.get_prop("prop-int32-array").as_int32_list()) + self.assertEqual([0x1, 0x98765432, 0xdeadbeef], + self.get_prop("prop-uint32-array").as_uint32_list()) + self.assertEqual([0x100000000, -2], + self.get_prop("prop-int64-array").as_int64_list()) + self.assertEqual([0x100000000, 0x1], + self.get_prop("prop-uint64-array").as_uint64_list()) + def testGetStringlistProperties(self): """Test that we can access properties as string list""" node = self.fdt.path_offset('/subnode@1/subsubnode') diff --git a/tests/test_props.dts b/tests/test_props.dts index 7e59bd1..5089023 100644 --- a/tests/test_props.dts +++ b/tests/test_props.dts @@ -8,4 +8,8 @@ prop-hex64 = /bits/ 64 <0xdeadbeef01abcdef>; prop-uint64 = /bits/ 64 <9223372036854775807>; prop-int64 = /bits/ 64 <0xfffffffffffffffe>; + prop-int32-array = <128>, <(-16)>, <0xfffffffe>; + prop-uint32-array = <0x1>, <0x98765432>, <0xdeadbeef>; + prop-int64-array = /bits/ 64 <0x100000000 0xfffffffffffffffe>; + prop-uint64-array = /bits/ 64 <0x100000000 0x1>; }; |