Returns:
Prop added
"""
- out = b''
- for string in val:
- out += bytes(string, 'utf-8') + b'\0'
+ out = b'\0'.join(bytes(s, 'utf-8') for s in val) + b'\0' if val else b''
return self.AddData(prop_name, out)
def AddInt(self, prop_name, val):
if not prop:
return default
value = prop.value
+ if not prop.bytes:
+ return ''
if isinstance(value, list):
raise ValueError("Node '%s' property '%s' has list value: expecting "
"a single string" % (node.name, propname))
if not prop:
return default
value = prop.value
+ if not prop.bytes:
+ return []
if not isinstance(value, list):
strval = GetString(node, propname)
return [strval]
data = self.fdt.getprop(self.node.Offset(), 'stringlist')
self.assertEqual(b'123\x00456\0', data)
+ val = []
+ self.node.AddStringList('stringlist', val)
+ self.dtb.Sync(auto_resize=True)
+ data = self.fdt.getprop(self.node.Offset(), 'stringlist')
+ self.assertEqual(b'', data)
+
def test_delete_node(self):
"""Test deleting a node"""
old_offset = self.fdt.path_offset('/spl-test')
self.assertEqual('message', fdt_util.GetString(self.node, 'stringval'))
self.assertEqual('test', fdt_util.GetString(self.node, 'missing',
'test'))
+ self.assertEqual('', fdt_util.GetString(self.node, 'boolval'))
with self.assertRaises(ValueError) as e:
self.assertEqual(3, fdt_util.GetString(self.node, 'stringarray'))
fdt_util.GetStringList(self.node, 'stringarray'))
self.assertEqual(['test'],
fdt_util.GetStringList(self.node, 'missing', ['test']))
+ self.assertEqual([], fdt_util.GetStringList(self.node, 'boolval'))
def testGetArgs(self):
node = self.dtb.GetNode('/orig-node')