comparison test/testemulation.py @ 366:39bf68bf1891

Fix sample tests and deterministic build
author Windel Bouwman
date Fri, 21 Mar 2014 09:43:01 +0100
parents c49459768aaa
children 5333318ee33d
comparison
equal deleted inserted replaced
365:98ff43cfdd36 366:39bf68bf1891
21 os.remove('qemuserial.sock') 21 os.remove('qemuserial.sock')
22 except FileNotFoundError: 22 except FileNotFoundError:
23 pass 23 pass
24 24
25 # Listen to the control socket: 25 # Listen to the control socket:
26 qemu_control = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 26 qemu_control_serve = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
27 qemu_control.bind('qemucontrol.sock') 27 qemu_control_serve.bind('qemucontrol.sock')
28 qemu_control.listen(0) 28 qemu_control_serve.listen(0)
29 29
30 # Listen to the serial output: 30 # Listen to the serial output:
31 qemu_serial = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 31 qemu_serial_serve = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
32 qemu_serial.bind('qemuserial.sock') 32 qemu_serial_serve.bind('qemuserial.sock')
33 qemu_serial.listen(0) 33 qemu_serial_serve.listen(0)
34 34
35 args = ['qemu-system-arm', '-M', machine, '-m', '16M', 35 args = ['qemu-system-arm', '-M', machine, '-m', '16M',
36 '-nographic', '-kernel', kernel, '-monitor', 36 '-nographic', '-kernel', kernel, '-monitor',
37 'unix:qemucontrol.sock', 37 'unix:qemucontrol.sock',
38 '-serial', 'unix:qemuserial.sock', '-S'] 38 '-serial', 'unix:qemuserial.sock', '-S']
39 p = subprocess.Popen(args) 39 p = subprocess.Popen(args,
40 #stdout=subprocess.DEVNULL, 40 stdout=subprocess.DEVNULL,
41 #stderr=subprocess.DEVNULL) 41 stderr=subprocess.DEVNULL)
42 42
43 # Give process some time to boot: 43 # Give process some time to boot:
44 qemu_serial, address_peer = qemu_serial.accept() 44 qemu_serial, address_peer = qemu_serial_serve.accept()
45 qemu_control, address_peer = qemu_control.accept() 45 qemu_control, address_peer = qemu_control_serve.accept()
46
47 # Give the go command:
46 qemu_control.send('cont\n'.encode('ascii')) 48 qemu_control.send('cont\n'.encode('ascii'))
47 49
48 qemu_serial.settimeout(0.2) 50 qemu_serial.settimeout(0.2)
49 51
50 # Receive all data: 52 # Receive all data:
61 qemu_control.send("quit\n".encode('ascii')) 63 qemu_control.send("quit\n".encode('ascii'))
62 try: 64 try:
63 p.wait(timeout=3) 65 p.wait(timeout=3)
64 except subprocess.TimeoutExpired: 66 except subprocess.TimeoutExpired:
65 p.kill() 67 p.kill()
66 print(p.communicate())
67 qemu_control.close() 68 qemu_control.close()
68 qemu_serial.close() 69 qemu_serial.close()
70 qemu_control_serve.close()
71 qemu_serial_serve.close()
69 72
70 try: 73 try:
71 os.remove('qemucontrol.sock') 74 os.remove('qemucontrol.sock')
72 except FileNotFoundError: 75 except FileNotFoundError:
73 pass 76 pass