comparison test/testsamples.py @ 383:173e20a47fda

Added linker description loader
author Windel Bouwman
date Sun, 27 Apr 2014 17:40:39 +0200
parents 6df89163e114
children d056b552d3f4
comparison
equal deleted inserted replaced
382:0c44e494ef58 383:173e20a47fda
20 var int *UART0DR; 20 var int *UART0DR;
21 UART0DR = cast<int*>(0x10009000); // UART0 DR register 21 UART0DR = cast<int*>(0x10009000); // UART0 DR register
22 *UART0DR = c; 22 *UART0DR = c;
23 } 23 }
24 24
25 """
26
27 arch_mmap = """
28 MEMORY image LOCATION=0x10000 SIZE=0x10000 {
29 SECTION(reset)
30 SECTION(code)
31 }
32
33 MEMORY ram LOCATION=0x20000 SIZE=0x10000 {
34 SECTION(data)
35 }
25 """ 36 """
26 37
27 class Samples: 38 class Samples:
28 def testPrint(self): 39 def testPrint(self):
29 snippet = """ 40 snippet = """
134 o1 = assemble(io.StringIO(startercode), 'arm') 145 o1 = assemble(io.StringIO(startercode), 'arm')
135 o2 = c3compile([ 146 o2 = c3compile([
136 relpath('..', 'kernel', 'src', 'io.c3'), 147 relpath('..', 'kernel', 'src', 'io.c3'),
137 io.StringIO(modarchcode), 148 io.StringIO(modarchcode),
138 io.StringIO(src)], [], 'arm') 149 io.StringIO(src)], [], 'arm')
139 layout = {'code': 0x10000, 'data': 0x20000} 150 o3 = link([o1, o2], io.StringIO(arch_mmap))
140 o3 = link([o1, o2], layout)
141 151
142 sample_filename = 'testsample.bin' 152 sample_filename = 'testsample.bin'
143 with open(sample_filename, 'wb') as f: 153 with open(sample_filename, 'wb') as f:
144 f.write(o3.get_section('code').data) 154 f.write(o3.get_section('code').data)
145 155
150 res = runQemu(sample_filename, machine='vexpress-a9') 160 res = runQemu(sample_filename, machine='vexpress-a9')
151 os.remove(sample_filename) 161 os.remove(sample_filename)
152 self.assertEqual(expected_output, res) 162 self.assertEqual(expected_output, res)
153 163
154 164
165 # TODO: test samples on thumb target..
166
167
155 if __name__ == '__main__': 168 if __name__ == '__main__':
156 unittest.main() 169 unittest.main()
157 170