]>
git.ipfire.org Git - people/ms/u-boot.git/blob - tools/binman/image_test.py
2 # Copyright (c) 2017 Google, Inc
3 # Written by Simon Glass <sjg@chromium.org>
5 # SPDX-License-Identifier: GPL-2.0+
7 # Test for the image module
11 from image
import Image
12 from elf_test
import capture_sys_output
14 class TestImage(unittest
.TestCase
):
15 def testInvalidFormat(self
):
16 image
= Image('name', 'node', test
=True)
17 with self
.assertRaises(ValueError) as e
:
18 image
.LookupSymbol('_binman_something_prop_', False, 'msg')
20 "msg: Symbol '_binman_something_prop_' has invalid format",
23 def testMissingSymbol(self
):
24 image
= Image('name', 'node', test
=True)
26 with self
.assertRaises(ValueError) as e
:
27 image
.LookupSymbol('_binman_type_prop_pname', False, 'msg')
28 self
.assertIn("msg: Entry 'type' not found in list ()",
31 def testMissingSymbolOptional(self
):
32 image
= Image('name', 'node', test
=True)
34 with
capture_sys_output() as (stdout
, stderr
):
35 val
= image
.LookupSymbol('_binman_type_prop_pname', True, 'msg')
36 self
.assertEqual(val
, None)
37 self
.assertEqual("Warning: msg: Entry 'type' not found in list ()\n",
39 self
.assertEqual('', stdout
.getvalue())
41 def testBadProperty(self
):
42 image
= Image('name', 'node', test
=True)
43 image
._entries
= {'u-boot': 1}
44 with self
.assertRaises(ValueError) as e
:
45 image
.LookupSymbol('_binman_u_boot_prop_bad', False, 'msg')
46 self
.assertIn("msg: No such property 'bad", str(e
.exception
))