comparison test/testemulation.py @ 340:c7cc54c0dfdf devel

Test featurebranch
author Windel Bouwman
date Sun, 23 Feb 2014 16:24:01 +0100
parents 6ee17c4dd6b8
children 3bb7dcfe5529
comparison
equal deleted inserted replaced
339:6ee17c4dd6b8 340:c7cc54c0dfdf
19 self.skipTest('Not running emulation tests') 19 self.skipTest('Not running emulation tests')
20 20
21 def tearDown(self): 21 def tearDown(self):
22 os.chdir(testdir) 22 os.chdir(testdir)
23 23
24 def runQemu(self, kernel, timespan=2): 24 def runQemu(self, kernel):
25 args = ['qemu-system-arm', '-M', 'lm3s811evb', '-m', '16M', 25 args = ['qemu-system-arm', '-M', 'lm3s811evb', '-m', '16M',
26 '-nographic', '-kernel', kernel, '-monitor', 26 '-nographic', '-kernel', kernel, '-monitor',
27 'unix:qemucontrol.sock,server', 27 'unix:qemucontrol.sock,server',
28 '-serial', 'unix:qemuserial.sock,server'] 28 '-serial', 'unix:qemuserial.sock,server']
29 p = subprocess.Popen(args) 29 p = subprocess.Popen(args)
33 33
34 # Connect to the control socket: 34 # Connect to the control socket:
35 qemu_control = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 35 qemu_control = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
36 qemu_control.connect('qemucontrol.sock') 36 qemu_control.connect('qemucontrol.sock')
37 37
38 time.sleep(2.5) 38 time.sleep(0.5)
39 39
40 # Now connect to the serial output: 40 # Now connect to the serial output:
41 qemu_serial = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 41 qemu_serial = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
42 qemu_serial.connect('qemuserial.sock') 42 qemu_serial.connect('qemuserial.sock')
43 43
45 data = qemu_serial.recv(11).decode('ascii') 45 data = qemu_serial.recv(11).decode('ascii')
46 print(data) 46 print(data)
47 47
48 # Send quit command: 48 # Send quit command:
49 qemu_control.send("quit\n".encode('ascii')) 49 qemu_control.send("quit\n".encode('ascii'))
50 50 p.wait(timeout=3)
51 p.wait(timeout=timespan)
52
53 qemu_control.close() 51 qemu_control.close()
54 qemu_serial.close() 52 qemu_serial.close()
55 53
56 # Check that output was correct: 54 # Check that output was correct:
57 self.assertEqual('Hello worle', data) 55 self.assertEqual('Hello worle', data)