@classmethod
def tearDownClass(cls):
- tools._FinaliseForTest()
+ tools.FinaliseOutputDir()
def setUp(self):
self.dtb = fdt.FdtScan('tools/dtoc/dtoc_test_simple.dts')
@classmethod
def tearDownClass(cls):
- tools._FinaliseForTest()
+ tools.FinaliseOutputDir()
def setUp(self):
self.dtb = fdt.FdtScan('tools/dtoc/dtoc_test_simple.dts')
@classmethod
def tearDownClass(cls):
- tools._FinaliseForTest()
+ tools.FinaliseOutputDir()
def setUp(self):
self.dtb = fdt.FdtScan('tools/dtoc/dtoc_test_simple.dts')
Return fdt.Prop object for this property
"""
- p = self.fdt.get_property(self.node.Offset(), prop_name)
+ p = self.fdt.getprop(self.node.Offset(), prop_name)
return fdt.Prop(self.node, -1, prop_name, p)
def testMakeProp(self):
self.node.AddZeroProp('one')
self.node.AddZeroProp('two')
self.node.AddZeroProp('three')
+ self.dtb.Sync(auto_resize=True)
# Updating existing properties should be OK, since the device-tree size
# does not change
self.node.SetInt('one', 1)
self.node.SetInt('two', 2)
self.node.SetInt('three', 3)
+ self.dtb.Sync(auto_resize=False)
# This should fail since it would need to increase the device-tree size
+ self.node.AddZeroProp('four')
with self.assertRaises(libfdt.FdtException) as e:
- self.node.SetInt('four', 4)
+ self.dtb.Sync(auto_resize=False)
self.assertIn('FDT_ERR_NOSPACE', str(e.exception))
+ self.dtb.Sync(auto_resize=True)
+
+ def testAddNode(self):
+ self.fdt.pack()
+ self.node.AddSubnode('subnode')
+ with self.assertRaises(libfdt.FdtException) as e:
+ self.dtb.Sync(auto_resize=False)
+ self.assertIn('FDT_ERR_NOSPACE', str(e.exception))
+
+ self.dtb.Sync(auto_resize=True)
+ offset = self.fdt.path_offset('/spl-test/subnode')
+ self.assertTrue(offset > 0)
+
+ def testAddMore(self):
+ """Test various other methods for adding and setting properties"""
+ self.node.AddZeroProp('one')
+ self.dtb.Sync(auto_resize=True)
+ data = self.fdt.getprop(self.node.Offset(), 'one')
+ self.assertEqual(0, fdt32_to_cpu(data))
+
+ self.node.SetInt('one', 1)
+ self.dtb.Sync(auto_resize=False)
+ data = self.fdt.getprop(self.node.Offset(), 'one')
+ self.assertEqual(1, fdt32_to_cpu(data))
+
+ val = '123' + chr(0) + '456'
+ self.node.AddString('string', val)
+ self.dtb.Sync(auto_resize=True)
+ data = self.fdt.getprop(self.node.Offset(), 'string')
+ self.assertEqual(val + '\0', data)
+
+ self.fdt.pack()
+ self.node.SetString('string', val + 'x')
+ with self.assertRaises(libfdt.FdtException) as e:
+ self.dtb.Sync(auto_resize=False)
+ self.assertIn('FDT_ERR_NOSPACE', str(e.exception))
+ self.node.SetString('string', val[:-1])
+
+ prop = self.node.props['string']
+ prop.SetData(val)
+ self.dtb.Sync(auto_resize=False)
+ data = self.fdt.getprop(self.node.Offset(), 'string')
+ self.assertEqual(val, data)
+
+ self.node.AddEmptyProp('empty', 5)
+ self.dtb.Sync(auto_resize=True)
+ prop = self.node.props['empty']
+ prop.SetData(val)
+ self.dtb.Sync(auto_resize=False)
+ data = self.fdt.getprop(self.node.Offset(), 'empty')
+ self.assertEqual(val, data)
+
+ self.node.SetData('empty', '123')
+ self.assertEqual('123', prop.bytes)
+
+ def testFromData(self):
+ dtb2 = fdt.Fdt.FromData(self.dtb.GetContents())
+ self.assertEqual(dtb2.GetContents(), self.dtb.GetContents())
+
+ self.node.AddEmptyProp('empty', 5)
+ self.dtb.Sync(auto_resize=True)
+ self.assertTrue(dtb2.GetContents() != self.dtb.GetContents())
class TestFdtUtil(unittest.TestCase):
def setUpClass(cls):
tools.PrepareOutputDir(None)
+ @classmethod
+ def tearDownClass(cls):
+ tools.FinaliseOutputDir()
+
def setUp(self):
self.dtb = fdt.FdtScan('tools/dtoc/dtoc_test_simple.dts')
self.node = self.dtb.GetNode('/spl-test')
parser = OptionParser()
parser.add_option('-B', '--build-dir', type='string', default='b',
help='Directory containing the build output')
+parser.add_option('-P', '--processes', type=int,
+ help='set number of processes to use for running tests')
parser.add_option('-t', '--test', action='store_true', dest='test',
default=False, help='run tests')
parser.add_option('-T', '--test-coverage', action='store_true',