]> Git Repo - J-u-boot.git/blame - tools/binman/image_test.py
binman: Allow a way to select expanded entries
[J-u-boot.git] / tools / binman / image_test.py
CommitLineData
83d290c5 1# SPDX-License-Identifier: GPL-2.0+
19790632
SG
2# Copyright (c) 2017 Google, Inc
3# Written by Simon Glass <[email protected]>
4#
19790632
SG
5# Test for the image module
6
7import unittest
8
07237988 9from binman.image import Image
16287933 10from patman.test_util import capture_sys_output
19790632
SG
11
12class TestImage(unittest.TestCase):
13 def testInvalidFormat(self):
14 image = Image('name', 'node', test=True)
15 with self.assertRaises(ValueError) as e:
7c150136 16 image.LookupSymbol('_binman_something_prop_', False, 'msg', 0)
19790632
SG
17 self.assertIn(
18 "msg: Symbol '_binman_something_prop_' has invalid format",
19 str(e.exception))
20
21 def testMissingSymbol(self):
22 image = Image('name', 'node', test=True)
8beb11ea 23 image._entries = {}
19790632 24 with self.assertRaises(ValueError) as e:
7c150136 25 image.LookupSymbol('_binman_type_prop_pname', False, 'msg', 0)
19790632
SG
26 self.assertIn("msg: Entry 'type' not found in list ()",
27 str(e.exception))
28
29 def testMissingSymbolOptional(self):
30 image = Image('name', 'node', test=True)
8beb11ea 31 image._entries = {}
19790632 32 with capture_sys_output() as (stdout, stderr):
7c150136 33 val = image.LookupSymbol('_binman_type_prop_pname', True, 'msg', 0)
19790632
SG
34 self.assertEqual(val, None)
35 self.assertEqual("Warning: msg: Entry 'type' not found in list ()\n",
36 stderr.getvalue())
37 self.assertEqual('', stdout.getvalue())
38
39 def testBadProperty(self):
40 image = Image('name', 'node', test=True)
8beb11ea 41 image._entries = {'u-boot': 1}
19790632 42 with self.assertRaises(ValueError) as e:
7c150136 43 image.LookupSymbol('_binman_u_boot_prop_bad', False, 'msg', 0)
19790632 44 self.assertIn("msg: No such property 'bad", str(e.exception))
This page took 0.137007 seconds and 4 git commands to generate.