annotate test/testbintools.py @ 385:d056b552d3f4

Made better use of layout
author Windel Bouwman
date Thu, 01 May 2014 14:03:12 +0200
parents 173e20a47fda
children
rev   line source
336
d1ecc493384e Added spiffy armtoken class for bit fiddeling. Added cool test that checks for build repeatability
Windel Bouwman
parents:
diff changeset
1 import unittest
d1ecc493384e Added spiffy armtoken class for bit fiddeling. Added cool test that checks for build repeatability
Windel Bouwman
parents:
diff changeset
2 import sys
377
9667d78ba79e Switched to xml for project description
Windel Bouwman
parents: 342
diff changeset
3 import io
342
86b02c98a717 Moved target directory
Windel Bouwman
parents: 336
diff changeset
4 from ppci.target.arm.token import ArmToken
336
d1ecc493384e Added spiffy armtoken class for bit fiddeling. Added cool test that checks for build repeatability
Windel Bouwman
parents:
diff changeset
5 from ppci.linker import Linker
377
9667d78ba79e Switched to xml for project description
Windel Bouwman
parents: 342
diff changeset
6 from ppci.objectfile import ObjectFile, serialize, deserialize, load_object
336
d1ecc493384e Added spiffy armtoken class for bit fiddeling. Added cool test that checks for build repeatability
Windel Bouwman
parents:
diff changeset
7 from ppci import CompilerError
377
9667d78ba79e Switched to xml for project description
Windel Bouwman
parents: 342
diff changeset
8 from ppci.tasks import TaskRunner, TaskError
9667d78ba79e Switched to xml for project description
Windel Bouwman
parents: 342
diff changeset
9 from ppci.buildtasks import EmptyTask
381
6df89163e114 Fix section and ldr pseudo instruction
Windel Bouwman
parents: 377
diff changeset
10 from ppci.buildfunctions import link
383
173e20a47fda Added linker description loader
Windel Bouwman
parents: 381
diff changeset
11 from ppci import layout
342
86b02c98a717 Moved target directory
Windel Bouwman
parents: 336
diff changeset
12
86b02c98a717 Moved target directory
Windel Bouwman
parents: 336
diff changeset
13
86b02c98a717 Moved target directory
Windel Bouwman
parents: 336
diff changeset
14 class TaskTestCase(unittest.TestCase):
377
9667d78ba79e Switched to xml for project description
Windel Bouwman
parents: 342
diff changeset
15 @unittest.skip('api change')
342
86b02c98a717 Moved target directory
Windel Bouwman
parents: 336
diff changeset
16 def testCircular(self):
86b02c98a717 Moved target directory
Windel Bouwman
parents: 336
diff changeset
17 t1 = EmptyTask('t1')
86b02c98a717 Moved target directory
Windel Bouwman
parents: 336
diff changeset
18 t2 = EmptyTask('t2')
86b02c98a717 Moved target directory
Windel Bouwman
parents: 336
diff changeset
19 t1.add_dependency(t2)
86b02c98a717 Moved target directory
Windel Bouwman
parents: 336
diff changeset
20 with self.assertRaises(TaskError):
86b02c98a717 Moved target directory
Windel Bouwman
parents: 336
diff changeset
21 t2.add_dependency(t1)
86b02c98a717 Moved target directory
Windel Bouwman
parents: 336
diff changeset
22
377
9667d78ba79e Switched to xml for project description
Windel Bouwman
parents: 342
diff changeset
23 @unittest.skip('api change')
342
86b02c98a717 Moved target directory
Windel Bouwman
parents: 336
diff changeset
24 def testCircularDeeper(self):
86b02c98a717 Moved target directory
Windel Bouwman
parents: 336
diff changeset
25 t1 = EmptyTask('t1')
86b02c98a717 Moved target directory
Windel Bouwman
parents: 336
diff changeset
26 t2 = EmptyTask('t2')
86b02c98a717 Moved target directory
Windel Bouwman
parents: 336
diff changeset
27 t3 = EmptyTask('t3')
86b02c98a717 Moved target directory
Windel Bouwman
parents: 336
diff changeset
28 t1.add_dependency(t2)
86b02c98a717 Moved target directory
Windel Bouwman
parents: 336
diff changeset
29 t2.add_dependency(t3)
86b02c98a717 Moved target directory
Windel Bouwman
parents: 336
diff changeset
30 with self.assertRaises(TaskError):
86b02c98a717 Moved target directory
Windel Bouwman
parents: 336
diff changeset
31 t3.add_dependency(t1)
86b02c98a717 Moved target directory
Windel Bouwman
parents: 336
diff changeset
32
377
9667d78ba79e Switched to xml for project description
Windel Bouwman
parents: 342
diff changeset
33 @unittest.skip('api change')
342
86b02c98a717 Moved target directory
Windel Bouwman
parents: 336
diff changeset
34 def testSort(self):
86b02c98a717 Moved target directory
Windel Bouwman
parents: 336
diff changeset
35 t1 = EmptyTask('t1')
86b02c98a717 Moved target directory
Windel Bouwman
parents: 336
diff changeset
36 t2 = EmptyTask('t2')
86b02c98a717 Moved target directory
Windel Bouwman
parents: 336
diff changeset
37 runner = TaskRunner()
86b02c98a717 Moved target directory
Windel Bouwman
parents: 336
diff changeset
38 t1.add_dependency(t2)
86b02c98a717 Moved target directory
Windel Bouwman
parents: 336
diff changeset
39 runner.add_task(t1)
86b02c98a717 Moved target directory
Windel Bouwman
parents: 336
diff changeset
40 runner.add_task(t2)
86b02c98a717 Moved target directory
Windel Bouwman
parents: 336
diff changeset
41 runner.run_tasks()
336
d1ecc493384e Added spiffy armtoken class for bit fiddeling. Added cool test that checks for build repeatability
Windel Bouwman
parents:
diff changeset
42
d1ecc493384e Added spiffy armtoken class for bit fiddeling. Added cool test that checks for build repeatability
Windel Bouwman
parents:
diff changeset
43
d1ecc493384e Added spiffy armtoken class for bit fiddeling. Added cool test that checks for build repeatability
Windel Bouwman
parents:
diff changeset
44 class TokenTestCase(unittest.TestCase):
d1ecc493384e Added spiffy armtoken class for bit fiddeling. Added cool test that checks for build repeatability
Windel Bouwman
parents:
diff changeset
45 def testSetBits(self):
d1ecc493384e Added spiffy armtoken class for bit fiddeling. Added cool test that checks for build repeatability
Windel Bouwman
parents:
diff changeset
46 at = ArmToken()
d1ecc493384e Added spiffy armtoken class for bit fiddeling. Added cool test that checks for build repeatability
Windel Bouwman
parents:
diff changeset
47 at[2:4] = 0b11
d1ecc493384e Added spiffy armtoken class for bit fiddeling. Added cool test that checks for build repeatability
Windel Bouwman
parents:
diff changeset
48 self.assertEqual(0xc, at.bit_value)
d1ecc493384e Added spiffy armtoken class for bit fiddeling. Added cool test that checks for build repeatability
Windel Bouwman
parents:
diff changeset
49
d1ecc493384e Added spiffy armtoken class for bit fiddeling. Added cool test that checks for build repeatability
Windel Bouwman
parents:
diff changeset
50 def testSetBits(self):
d1ecc493384e Added spiffy armtoken class for bit fiddeling. Added cool test that checks for build repeatability
Windel Bouwman
parents:
diff changeset
51 at = ArmToken()
d1ecc493384e Added spiffy armtoken class for bit fiddeling. Added cool test that checks for build repeatability
Windel Bouwman
parents:
diff changeset
52 at[4:8] = 0b1100
d1ecc493384e Added spiffy armtoken class for bit fiddeling. Added cool test that checks for build repeatability
Windel Bouwman
parents:
diff changeset
53 self.assertEqual(0xc0, at.bit_value)
d1ecc493384e Added spiffy armtoken class for bit fiddeling. Added cool test that checks for build repeatability
Windel Bouwman
parents:
diff changeset
54
d1ecc493384e Added spiffy armtoken class for bit fiddeling. Added cool test that checks for build repeatability
Windel Bouwman
parents:
diff changeset
55
d1ecc493384e Added spiffy armtoken class for bit fiddeling. Added cool test that checks for build repeatability
Windel Bouwman
parents:
diff changeset
56 class LinkerTestCase(unittest.TestCase):
d1ecc493384e Added spiffy armtoken class for bit fiddeling. Added cool test that checks for build repeatability
Windel Bouwman
parents:
diff changeset
57 def testUndefinedReference(self):
d1ecc493384e Added spiffy armtoken class for bit fiddeling. Added cool test that checks for build repeatability
Windel Bouwman
parents:
diff changeset
58 o1 = ObjectFile()
d1ecc493384e Added spiffy armtoken class for bit fiddeling. Added cool test that checks for build repeatability
Windel Bouwman
parents:
diff changeset
59 o1.get_section('.text')
d1ecc493384e Added spiffy armtoken class for bit fiddeling. Added cool test that checks for build repeatability
Windel Bouwman
parents:
diff changeset
60 o1.add_relocation('undefined_sym', 0, 'rel8', '.text')
d1ecc493384e Added spiffy armtoken class for bit fiddeling. Added cool test that checks for build repeatability
Windel Bouwman
parents:
diff changeset
61 o2 = ObjectFile()
d1ecc493384e Added spiffy armtoken class for bit fiddeling. Added cool test that checks for build repeatability
Windel Bouwman
parents:
diff changeset
62 with self.assertRaises(CompilerError):
385
d056b552d3f4 Made better use of layout
Windel Bouwman
parents: 383
diff changeset
63 o3 = link([o1, o2], layout.Layout(), 'arm')
336
d1ecc493384e Added spiffy armtoken class for bit fiddeling. Added cool test that checks for build repeatability
Windel Bouwman
parents:
diff changeset
64
d1ecc493384e Added spiffy armtoken class for bit fiddeling. Added cool test that checks for build repeatability
Windel Bouwman
parents:
diff changeset
65 def testDuplicateSymbol(self):
d1ecc493384e Added spiffy armtoken class for bit fiddeling. Added cool test that checks for build repeatability
Windel Bouwman
parents:
diff changeset
66 o1 = ObjectFile()
d1ecc493384e Added spiffy armtoken class for bit fiddeling. Added cool test that checks for build repeatability
Windel Bouwman
parents:
diff changeset
67 o1.get_section('.text')
d1ecc493384e Added spiffy armtoken class for bit fiddeling. Added cool test that checks for build repeatability
Windel Bouwman
parents:
diff changeset
68 o1.add_symbol('a', 0, '.text')
d1ecc493384e Added spiffy armtoken class for bit fiddeling. Added cool test that checks for build repeatability
Windel Bouwman
parents:
diff changeset
69 o2 = ObjectFile()
d1ecc493384e Added spiffy armtoken class for bit fiddeling. Added cool test that checks for build repeatability
Windel Bouwman
parents:
diff changeset
70 o2.get_section('.text')
d1ecc493384e Added spiffy armtoken class for bit fiddeling. Added cool test that checks for build repeatability
Windel Bouwman
parents:
diff changeset
71 o2.add_symbol('a', 0, '.text')
d1ecc493384e Added spiffy armtoken class for bit fiddeling. Added cool test that checks for build repeatability
Windel Bouwman
parents:
diff changeset
72 with self.assertRaises(CompilerError):
385
d056b552d3f4 Made better use of layout
Windel Bouwman
parents: 383
diff changeset
73 o3 = link([o1, o2], layout.Layout(), 'arm')
336
d1ecc493384e Added spiffy armtoken class for bit fiddeling. Added cool test that checks for build repeatability
Windel Bouwman
parents:
diff changeset
74
d1ecc493384e Added spiffy armtoken class for bit fiddeling. Added cool test that checks for build repeatability
Windel Bouwman
parents:
diff changeset
75 def testRel8Relocation(self):
d1ecc493384e Added spiffy armtoken class for bit fiddeling. Added cool test that checks for build repeatability
Windel Bouwman
parents:
diff changeset
76 o1 = ObjectFile()
d1ecc493384e Added spiffy armtoken class for bit fiddeling. Added cool test that checks for build repeatability
Windel Bouwman
parents:
diff changeset
77 o1.get_section('.text').add_data(bytes([0]*100))
d1ecc493384e Added spiffy armtoken class for bit fiddeling. Added cool test that checks for build repeatability
Windel Bouwman
parents:
diff changeset
78 o1.add_relocation('a', 0, 'rel8', '.text')
d1ecc493384e Added spiffy armtoken class for bit fiddeling. Added cool test that checks for build repeatability
Windel Bouwman
parents:
diff changeset
79 o2 = ObjectFile()
d1ecc493384e Added spiffy armtoken class for bit fiddeling. Added cool test that checks for build repeatability
Windel Bouwman
parents:
diff changeset
80 o2.get_section('.text').add_data(bytes([0]*100))
d1ecc493384e Added spiffy armtoken class for bit fiddeling. Added cool test that checks for build repeatability
Windel Bouwman
parents:
diff changeset
81 o2.add_symbol('a', 24, '.text')
385
d056b552d3f4 Made better use of layout
Windel Bouwman
parents: 383
diff changeset
82 o3 = link([o1, o2], layout.Layout(), 'arm')
336
d1ecc493384e Added spiffy armtoken class for bit fiddeling. Added cool test that checks for build repeatability
Windel Bouwman
parents:
diff changeset
83
d1ecc493384e Added spiffy armtoken class for bit fiddeling. Added cool test that checks for build repeatability
Windel Bouwman
parents:
diff changeset
84 def testSymbolValues(self):
d1ecc493384e Added spiffy armtoken class for bit fiddeling. Added cool test that checks for build repeatability
Windel Bouwman
parents:
diff changeset
85 o1 = ObjectFile()
d1ecc493384e Added spiffy armtoken class for bit fiddeling. Added cool test that checks for build repeatability
Windel Bouwman
parents:
diff changeset
86 o1.get_section('.text').add_data(bytes([0]*108))
d1ecc493384e Added spiffy armtoken class for bit fiddeling. Added cool test that checks for build repeatability
Windel Bouwman
parents:
diff changeset
87 o1.add_symbol('b', 24, '.text')
d1ecc493384e Added spiffy armtoken class for bit fiddeling. Added cool test that checks for build repeatability
Windel Bouwman
parents:
diff changeset
88 o2 = ObjectFile()
d1ecc493384e Added spiffy armtoken class for bit fiddeling. Added cool test that checks for build repeatability
Windel Bouwman
parents:
diff changeset
89 o2.get_section('.text').add_data(bytes([0]*100))
d1ecc493384e Added spiffy armtoken class for bit fiddeling. Added cool test that checks for build repeatability
Windel Bouwman
parents:
diff changeset
90 o2.add_symbol('a', 2, '.text')
385
d056b552d3f4 Made better use of layout
Windel Bouwman
parents: 383
diff changeset
91 o3 = link([o1, o2], layout.Layout(), 'arm')
336
d1ecc493384e Added spiffy armtoken class for bit fiddeling. Added cool test that checks for build repeatability
Windel Bouwman
parents:
diff changeset
92 self.assertEqual(110, o3.find_symbol('a').value)
d1ecc493384e Added spiffy armtoken class for bit fiddeling. Added cool test that checks for build repeatability
Windel Bouwman
parents:
diff changeset
93 self.assertEqual(24, o3.find_symbol('b').value)
d1ecc493384e Added spiffy armtoken class for bit fiddeling. Added cool test that checks for build repeatability
Windel Bouwman
parents:
diff changeset
94 self.assertEqual(208, o3.get_section('.text').Size)
d1ecc493384e Added spiffy armtoken class for bit fiddeling. Added cool test that checks for build repeatability
Windel Bouwman
parents:
diff changeset
95
d1ecc493384e Added spiffy armtoken class for bit fiddeling. Added cool test that checks for build repeatability
Windel Bouwman
parents:
diff changeset
96 def testMemoryLayout(self):
383
173e20a47fda Added linker description loader
Windel Bouwman
parents: 381
diff changeset
97 spec = """
173e20a47fda Added linker description loader
Windel Bouwman
parents: 381
diff changeset
98 MEMORY flash LOCATION=0x08000000 SIZE=0x3000 {
173e20a47fda Added linker description loader
Windel Bouwman
parents: 381
diff changeset
99 SECTION(code)
173e20a47fda Added linker description loader
Windel Bouwman
parents: 381
diff changeset
100 }
173e20a47fda Added linker description loader
Windel Bouwman
parents: 381
diff changeset
101 MEMORY flash LOCATION=0x20000000 SIZE=0x3000 {
173e20a47fda Added linker description loader
Windel Bouwman
parents: 381
diff changeset
102 SECTION(data)
173e20a47fda Added linker description loader
Windel Bouwman
parents: 381
diff changeset
103 }
173e20a47fda Added linker description loader
Windel Bouwman
parents: 381
diff changeset
104 """
173e20a47fda Added linker description loader
Windel Bouwman
parents: 381
diff changeset
105 memory_layout = layout.load_layout(io.StringIO(spec))
336
d1ecc493384e Added spiffy armtoken class for bit fiddeling. Added cool test that checks for build repeatability
Windel Bouwman
parents:
diff changeset
106 o1 = ObjectFile()
383
173e20a47fda Added linker description loader
Windel Bouwman
parents: 381
diff changeset
107 o1.get_section('code').add_data(bytes([0]*108))
173e20a47fda Added linker description loader
Windel Bouwman
parents: 381
diff changeset
108 o1.add_symbol('b', 24, 'code')
336
d1ecc493384e Added spiffy armtoken class for bit fiddeling. Added cool test that checks for build repeatability
Windel Bouwman
parents:
diff changeset
109 o2 = ObjectFile()
383
173e20a47fda Added linker description loader
Windel Bouwman
parents: 381
diff changeset
110 o2.get_section('code').add_data(bytes([0]*100))
173e20a47fda Added linker description loader
Windel Bouwman
parents: 381
diff changeset
111 o2.get_section('data').add_data(bytes([0]*100))
173e20a47fda Added linker description loader
Windel Bouwman
parents: 381
diff changeset
112 o2.add_symbol('a', 2, 'data')
173e20a47fda Added linker description loader
Windel Bouwman
parents: 381
diff changeset
113 o2.add_symbol('c', 2, 'code')
385
d056b552d3f4 Made better use of layout
Windel Bouwman
parents: 383
diff changeset
114 o3 = link([o1, o2], memory_layout, 'arm')
d056b552d3f4 Made better use of layout
Windel Bouwman
parents: 383
diff changeset
115 self.assertEqual(0x20000000+2, o3.get_symbol_value('a'))
d056b552d3f4 Made better use of layout
Windel Bouwman
parents: 383
diff changeset
116 self.assertEqual(0x08000000+24, o3.get_symbol_value('b'))
d056b552d3f4 Made better use of layout
Windel Bouwman
parents: 383
diff changeset
117 self.assertEqual(0x08000000+110, o3.get_symbol_value('c'))
383
173e20a47fda Added linker description loader
Windel Bouwman
parents: 381
diff changeset
118 self.assertEqual(208, o3.get_section('code').Size)
173e20a47fda Added linker description loader
Windel Bouwman
parents: 381
diff changeset
119 self.assertEqual(100, o3.get_section('data').Size)
336
d1ecc493384e Added spiffy armtoken class for bit fiddeling. Added cool test that checks for build repeatability
Windel Bouwman
parents:
diff changeset
120
d1ecc493384e Added spiffy armtoken class for bit fiddeling. Added cool test that checks for build repeatability
Windel Bouwman
parents:
diff changeset
121
377
9667d78ba79e Switched to xml for project description
Windel Bouwman
parents: 342
diff changeset
122 class ObjectFileTestCase(unittest.TestCase):
9667d78ba79e Switched to xml for project description
Windel Bouwman
parents: 342
diff changeset
123 def makeTwins(self):
9667d78ba79e Switched to xml for project description
Windel Bouwman
parents: 342
diff changeset
124 o1 = ObjectFile()
9667d78ba79e Switched to xml for project description
Windel Bouwman
parents: 342
diff changeset
125 o2 = ObjectFile()
9667d78ba79e Switched to xml for project description
Windel Bouwman
parents: 342
diff changeset
126 o2.get_section('code').add_data(bytes(range(55)))
9667d78ba79e Switched to xml for project description
Windel Bouwman
parents: 342
diff changeset
127 o1.get_section('code').add_data(bytes(range(55)))
9667d78ba79e Switched to xml for project description
Windel Bouwman
parents: 342
diff changeset
128 o1.add_relocation('A', 0x2, 'imm12_dumm', 'code')
9667d78ba79e Switched to xml for project description
Windel Bouwman
parents: 342
diff changeset
129 o2.add_relocation('A', 0x2, 'imm12_dumm', 'code')
9667d78ba79e Switched to xml for project description
Windel Bouwman
parents: 342
diff changeset
130 o1.add_symbol('A2', 0x90, 'code')
9667d78ba79e Switched to xml for project description
Windel Bouwman
parents: 342
diff changeset
131 o2.add_symbol('A2', 0x90, 'code')
9667d78ba79e Switched to xml for project description
Windel Bouwman
parents: 342
diff changeset
132 o1.add_symbol('A3', 0x90, 'code')
9667d78ba79e Switched to xml for project description
Windel Bouwman
parents: 342
diff changeset
133 o2.add_symbol('A3', 0x90, 'code')
9667d78ba79e Switched to xml for project description
Windel Bouwman
parents: 342
diff changeset
134 return o1, o2
9667d78ba79e Switched to xml for project description
Windel Bouwman
parents: 342
diff changeset
135
9667d78ba79e Switched to xml for project description
Windel Bouwman
parents: 342
diff changeset
136 def testEquality(self):
9667d78ba79e Switched to xml for project description
Windel Bouwman
parents: 342
diff changeset
137 o1, o2 = self.makeTwins()
9667d78ba79e Switched to xml for project description
Windel Bouwman
parents: 342
diff changeset
138 self.assertEqual(o1, o2)
9667d78ba79e Switched to xml for project description
Windel Bouwman
parents: 342
diff changeset
139
9667d78ba79e Switched to xml for project description
Windel Bouwman
parents: 342
diff changeset
140 def testSaveAndLoad(self):
9667d78ba79e Switched to xml for project description
Windel Bouwman
parents: 342
diff changeset
141 o1, o2 = self.makeTwins()
9667d78ba79e Switched to xml for project description
Windel Bouwman
parents: 342
diff changeset
142 f1 = io.StringIO()
9667d78ba79e Switched to xml for project description
Windel Bouwman
parents: 342
diff changeset
143 o1.save(f1)
9667d78ba79e Switched to xml for project description
Windel Bouwman
parents: 342
diff changeset
144 f2 = io.StringIO(f1.getvalue())
9667d78ba79e Switched to xml for project description
Windel Bouwman
parents: 342
diff changeset
145 o3 = load_object(f2)
9667d78ba79e Switched to xml for project description
Windel Bouwman
parents: 342
diff changeset
146 self.assertEqual(o3, o1)
9667d78ba79e Switched to xml for project description
Windel Bouwman
parents: 342
diff changeset
147
9667d78ba79e Switched to xml for project description
Windel Bouwman
parents: 342
diff changeset
148 def testSerialization(self):
9667d78ba79e Switched to xml for project description
Windel Bouwman
parents: 342
diff changeset
149 o1, o2 = self.makeTwins()
9667d78ba79e Switched to xml for project description
Windel Bouwman
parents: 342
diff changeset
150 o3 = deserialize(serialize(o1))
9667d78ba79e Switched to xml for project description
Windel Bouwman
parents: 342
diff changeset
151 self.assertEqual(o3, o1)
9667d78ba79e Switched to xml for project description
Windel Bouwman
parents: 342
diff changeset
152
9667d78ba79e Switched to xml for project description
Windel Bouwman
parents: 342
diff changeset
153
383
173e20a47fda Added linker description loader
Windel Bouwman
parents: 381
diff changeset
154 class LayoutFileTestCase(unittest.TestCase):
173e20a47fda Added linker description loader
Windel Bouwman
parents: 381
diff changeset
155 def testLayout1(self):
173e20a47fda Added linker description loader
Windel Bouwman
parents: 381
diff changeset
156 spec = """
173e20a47fda Added linker description loader
Windel Bouwman
parents: 381
diff changeset
157 MEMORY flash LOCATION=0x1000 SIZE=0x3000 {
173e20a47fda Added linker description loader
Windel Bouwman
parents: 381
diff changeset
158 SECTION(code)
173e20a47fda Added linker description loader
Windel Bouwman
parents: 381
diff changeset
159 ALIGN(4)
173e20a47fda Added linker description loader
Windel Bouwman
parents: 381
diff changeset
160 }
173e20a47fda Added linker description loader
Windel Bouwman
parents: 381
diff changeset
161 """
173e20a47fda Added linker description loader
Windel Bouwman
parents: 381
diff changeset
162 layout1 = layout.load_layout(io.StringIO(spec))
173e20a47fda Added linker description loader
Windel Bouwman
parents: 381
diff changeset
163 layout2 = layout.Layout()
173e20a47fda Added linker description loader
Windel Bouwman
parents: 381
diff changeset
164 m = layout.Memory('flash')
173e20a47fda Added linker description loader
Windel Bouwman
parents: 381
diff changeset
165 m.location = 0x1000
173e20a47fda Added linker description loader
Windel Bouwman
parents: 381
diff changeset
166 m.size = 0x3000
173e20a47fda Added linker description loader
Windel Bouwman
parents: 381
diff changeset
167 m.add_input(layout.Section('code'))
173e20a47fda Added linker description loader
Windel Bouwman
parents: 381
diff changeset
168 m.add_input(layout.Align(4))
173e20a47fda Added linker description loader
Windel Bouwman
parents: 381
diff changeset
169 layout2.add_memory(m)
173e20a47fda Added linker description loader
Windel Bouwman
parents: 381
diff changeset
170 self.assertEqual(layout2, layout1)
173e20a47fda Added linker description loader
Windel Bouwman
parents: 381
diff changeset
171
173e20a47fda Added linker description loader
Windel Bouwman
parents: 381
diff changeset
172
336
d1ecc493384e Added spiffy armtoken class for bit fiddeling. Added cool test that checks for build repeatability
Windel Bouwman
parents:
diff changeset
173 if __name__ == '__main__':
d1ecc493384e Added spiffy armtoken class for bit fiddeling. Added cool test that checks for build repeatability
Windel Bouwman
parents:
diff changeset
174 unittest.main()
d1ecc493384e Added spiffy armtoken class for bit fiddeling. Added cool test that checks for build repeatability
Windel Bouwman
parents:
diff changeset
175 sys.exit()