diff options
author | Simon Glass <sjg@chromium.org> | 2018-06-13 21:44:44 -0600 |
---|---|---|
committer | David Gibson <david@gibson.dropbear.id.au> | 2018-06-14 14:08:32 +1000 |
commit | b770f3d1c13f63a22c7015bd2438dbc1164b5362 (patch) | |
tree | db9e5f9cd6779aa04ed395a03f0c18f2bcadc91c /tests | |
parent | 2f0d07e678e05f260b575342867a26d466bdec85 (diff) | |
download | dtc-b770f3d1c13f63a22c7015bd2438dbc1164b5362.zip dtc-b770f3d1c13f63a22c7015bd2438dbc1164b5362.tar.gz dtc-b770f3d1c13f63a22c7015bd2438dbc1164b5362.tar.bz2 |
pylibfdt: Support setting the name of a node
Add a method to call fdt_set_name().
Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/pylibfdt_tests.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/pylibfdt_tests.py b/tests/pylibfdt_tests.py index f3be0ac..9f3e55a 100644 --- a/tests/pylibfdt_tests.py +++ b/tests/pylibfdt_tests.py @@ -465,6 +465,21 @@ class PyLibfdtTests(unittest.TestCase): self.assertEquals(TEST_STRING_3, self.fdt.getprop(node, prop).as_str()) + def testSetName(self): + """Test that we can update a node name""" + node = self.fdt.path_offset('/subnode@1') + old_val = self.fdt.get_name(node) + self.fdt.set_name(node, 'test') + self.assertEquals('test', self.fdt.get_name(node)) + + with self.assertRaises(ValueError) as e: + self.fdt.set_name(node, 'some\0name') + self.assertIn('embedded nul', str(e.exception)) + + with self.assertRaises(ValueError) as e: + self.fdt.set_name(node, 'name\0') + self.assertIn('embedded nul', str(e.exception)) + if __name__ == "__main__": unittest.main() |