Mercurial > lcfOS
comparison test/testemulation.py @ 375:19eacf4f7270
Started on memory manager
author | Windel Bouwman |
---|---|
date | Sun, 23 Mar 2014 15:44:06 +0100 |
parents | 68841f9ab96c |
children | 9667d78ba79e |
comparison
equal
deleted
inserted
replaced
374:72a3b646d543 | 375:19eacf4f7270 |
---|---|
2 import os | 2 import os |
3 import sys | 3 import sys |
4 import subprocess | 4 import subprocess |
5 import socket | 5 import socket |
6 import time | 6 import time |
7 import shutil | |
7 | 8 |
8 from testzcc import ZccBaseTestCase | 9 from testzcc import ZccBaseTestCase |
9 | 10 |
10 # Store testdir for safe switch back to directory: | 11 # Store testdir for safe switch back to directory: |
11 testdir = os.path.dirname(os.path.abspath(__file__)) | 12 testdir = os.path.dirname(os.path.abspath(__file__)) |
14 try: | 15 try: |
15 os.remove(fn) | 16 os.remove(fn) |
16 except OSError: | 17 except OSError: |
17 pass | 18 pass |
18 | 19 |
20 qemu_app = 'qemu-system-arm' | |
21 | |
22 def has_qemu(): | |
23 """ Determines if qemu is possible """ | |
24 return bool(shutil.which(qemu_app)) | |
25 | |
26 | |
19 def runQemu(kernel, machine='lm3s811evb'): | 27 def runQemu(kernel, machine='lm3s811evb'): |
20 """ Runs qemu on a given kernel file """ | 28 """ Runs qemu on a given kernel file """ |
21 | 29 |
30 if not has_qemu(): | |
31 return '' | |
22 tryrm('qemucontrol.sock') | 32 tryrm('qemucontrol.sock') |
23 tryrm('qemuserial.sock') | 33 tryrm('qemuserial.sock') |
24 | 34 |
25 # Listen to the control socket: | 35 # Listen to the control socket: |
26 qemu_control_serve = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) | 36 qemu_control_serve = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) |
30 # Listen to the serial output: | 40 # Listen to the serial output: |
31 qemu_serial_serve = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) | 41 qemu_serial_serve = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) |
32 qemu_serial_serve.bind('qemuserial.sock') | 42 qemu_serial_serve.bind('qemuserial.sock') |
33 qemu_serial_serve.listen(0) | 43 qemu_serial_serve.listen(0) |
34 | 44 |
35 args = ['qemu-system-arm', '-M', machine, '-m', '16M', | 45 args = [qemu_app, '-M', machine, '-m', '16M', |
36 '-nographic', | 46 '-nographic', |
37 '-kernel', kernel, | 47 '-kernel', kernel, |
38 '-monitor', 'unix:qemucontrol.sock', | 48 '-monitor', 'unix:qemucontrol.sock', |
39 '-serial', 'unix:qemuserial.sock', | 49 '-serial', 'unix:qemuserial.sock', |
40 '-S'] | 50 '-S'] |
84 | 94 |
85 | 95 |
86 class EmulationTestCase(ZccBaseTestCase): | 96 class EmulationTestCase(ZccBaseTestCase): |
87 """ Tests the compiler driver """ | 97 """ Tests the compiler driver """ |
88 def setUp(self): | 98 def setUp(self): |
89 if 'TESTEMU' not in os.environ: | 99 if not has_qemu(): |
90 self.skipTest('Not running emulation tests') | 100 self.skipTest('Not running Qemu test') |
91 | 101 |
92 def testM3Bare(self): | 102 def testM3Bare(self): |
93 """ Build bare m3 binary and emulate it """ | 103 """ Build bare m3 binary and emulate it """ |
94 recipe = os.path.join(testdir, 'm3_bare', 'recipe.yaml') | 104 recipe = os.path.join(testdir, 'm3_bare', 'recipe.yaml') |
95 self.buildRecipe(recipe) | 105 self.buildRecipe(recipe) |