Mercurial > lcfOS
diff test/testemulation.py @ 346:3bb7dcfe5529
expanded arm target
author | Windel Bouwman |
---|---|
date | Fri, 07 Mar 2014 17:05:32 +0100 |
parents | c7cc54c0dfdf |
children | 899ae3aea803 |
line wrap: on
line diff
--- a/test/testemulation.py Sun Mar 02 17:12:08 2014 +0100 +++ b/test/testemulation.py Fri Mar 07 17:05:32 2014 +0100 @@ -14,15 +14,11 @@ class EmulationTestCase(ZccBaseTestCase): """ Tests the compiler driver """ def setUp(self): - os.chdir(testdir) if 'TESTEMU' not in os.environ: self.skipTest('Not running emulation tests') - def tearDown(self): - os.chdir(testdir) - - def runQemu(self, kernel): - args = ['qemu-system-arm', '-M', 'lm3s811evb', '-m', '16M', + def runQemu(self, kernel, machine='lm3s811evb'): + args = ['qemu-system-arm', '-M', machine, '-m', '16M', '-nographic', '-kernel', kernel, '-monitor', 'unix:qemucontrol.sock,server', '-serial', 'unix:qemuserial.sock,server'] @@ -41,9 +37,19 @@ qemu_serial = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) qemu_serial.connect('qemuserial.sock') + time.sleep(0.5) - data = qemu_serial.recv(11).decode('ascii') - print(data) + qemu_serial.settimeout(0.2) + + # Receive all data: + data = bytearray() + for i in range(40): + try: + data += qemu_serial.recv(1) + except socket.timeout as e: + break + data = data.decode('ascii') + # print(data) # Send quit command: qemu_control.send("quit\n".encode('ascii')) @@ -52,13 +58,21 @@ qemu_serial.close() # Check that output was correct: - self.assertEqual('Hello worle', data) + return data def testM3Bare(self): """ Build bare m3 binary and emulate it """ recipe = os.path.join(testdir, 'm3_bare', 'recipe.yaml') self.buildRecipe(recipe) - self.runQemu('m3_bare/bare.bin') + data = self.runQemu('m3_bare/bare.bin') + self.assertEqual('Hello worle', data) + + def testA9Bare(self): + """ Build vexpress cortex-A9 binary and emulate it """ + recipe = os.path.join(testdir, '..', 'examples', 'qemu_a9_hello', 'recipe.yaml') + self.buildRecipe(recipe) + data = self.runQemu('../examples/qemu_a9_hello/hello.bin', machine='vexpress-a9') + self.assertEqual('Hello worle', data) if __name__ == '__main__':