Mercurial > lcfOS
view test/testemulation.py @ 341:4d204f6f7d4e devel
Rewrite of assembler parts
author | Windel Bouwman |
---|---|
date | Fri, 28 Feb 2014 18:07:14 +0100 |
parents | c7cc54c0dfdf |
children | 3bb7dcfe5529 |
line wrap: on
line source
import unittest import os import sys import subprocess import socket import time from testzcc import ZccBaseTestCase # Store testdir for safe switch back to directory: testdir = os.path.dirname(os.path.abspath(__file__)) 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', '-nographic', '-kernel', kernel, '-monitor', 'unix:qemucontrol.sock,server', '-serial', 'unix:qemuserial.sock,server'] p = subprocess.Popen(args) # Give process some time to boot: time.sleep(0.5) # Connect to the control socket: qemu_control = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) qemu_control.connect('qemucontrol.sock') time.sleep(0.5) # Now connect to the serial output: qemu_serial = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) qemu_serial.connect('qemuserial.sock') data = qemu_serial.recv(11).decode('ascii') print(data) # Send quit command: qemu_control.send("quit\n".encode('ascii')) p.wait(timeout=3) qemu_control.close() qemu_serial.close() # Check that output was correct: self.assertEqual('Hello worle', 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') if __name__ == '__main__': unittest.main()