author | Mike Kinghan <mikek@symbian.org> |
Fri, 19 Nov 2010 16:17:17 +0000 | |
branch | GCC_SURGE |
changeset 131 | aa939c1eee2f |
parent 34 | 92d87f2e53c2 |
permissions | -rwxr-xr-x |
34
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
1 |
# |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
2 |
# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
3 |
# All rights reserved. |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
4 |
# |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
5 |
# This program is free software: you can redistribute it and/or modify |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
6 |
# it under the terms of the GNU Lesser General Public License as published by |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
7 |
# the Free Software Foundation, either version 3 of the License, or |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
8 |
# (at your option) any later version. |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
9 |
# |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
10 |
# This program is distributed in the hope that it will be useful, |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
11 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
12 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
13 |
# GNU Lesser General Public License for more details. |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
14 |
# |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
15 |
# You should have received a copy of the GNU Lesser General Public License |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
16 |
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
17 |
|
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
18 |
# Launch QEMU for SVP with a specified ROM image and core using a COM port for IO |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
19 |
# Uses Python's Popen class for process control. |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
20 |
# Test output is captured by invoking QEMU in -nographic mode. This redirects serial output to stdout which can then be PIPE'd |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
21 |
# using Popen. |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
22 |
# Tests which hang(or crash into the the crash debugger) are detected using a trivial 'watchdog'. IWBN to use e.g. 'select' |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
23 |
# with a timeout, but this won't work on Windoze, which only supports timeout's on sockets. If the watchdog timeouts out QEMU is killed. |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
24 |
# When the test suite runs to (recognizable) completion QEMU is killed. Unfortunately this appears to require an OS specific |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
25 |
# solution. NB unrecognized completion will result in the watchdog killing QEMU. |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
26 |
# QemuTestRunner collects output into LineTimeInfo objects. These record the time at which each line was received. The time can be used as a crude |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
27 |
# measure of how long a test took to execute. |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
28 |
# The raw data gathered from running the tests can be retrieved using GetResults. This returns a list of LineTimeInfo objects. |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
29 |
|
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
30 |
import sys |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
31 |
mswindows = (sys.platform == "win32") |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
32 |
|
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
33 |
# import the following so we can kill QEMU |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
34 |
|
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
35 |
if mswindows: |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
36 |
# import win32api |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
37 |
import signal |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
38 |
else: |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
39 |
import signal |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
40 |
|
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
41 |
import os |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
42 |
|
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
43 |
import time |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
44 |
|
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
45 |
import re |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
46 |
|
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
47 |
import subprocess |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
48 |
from subprocess import * |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
49 |
|
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
50 |
from stat import * |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
51 |
|
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
52 |
import watchdog |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
53 |
|
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
54 |
__all__ = ["QemuTestRunner"] |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
55 |
|
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
56 |
class LineTimeInfo(object): |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
57 |
def __init__(self, line, atime): |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
58 |
self.line = line |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
59 |
self.time = atime |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
60 |
|
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
61 |
def GetLine(self): |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
62 |
return self.line |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
63 |
|
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
64 |
def GetTime(self): |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
65 |
return self.time |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
66 |
|
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
67 |
class QemuTestRunner(object): |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
68 |
def __init__(self, qemupath, cpu, rompath, board = 'syborg', endOfTestFn=None, displayp=False, dataFile = None): |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
69 |
"""Create new QemuTestRunner instance.""" |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
70 |
self.qemupath = qemupath |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
71 |
self.board = board |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
72 |
self.cpu = cpu |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
73 |
self.rompath = rompath |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
74 |
self.endOfTestFn = endOfTestFn |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
75 |
self.displayp = displayp |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
76 |
#self.cmd = qemupath + " -M syborg -cpu " + cpu + " -kernel " + rompath + " -nographic" |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
77 |
self.cmd = "%s -M %s -cpu %s -kernel %s -nographic" % (qemupath, board, cpu, rompath) |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
78 |
self.endOfTestPattern = re.compile('RUNTESTS: Completed test script') |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
79 |
self.lineTimeInfo = [] |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
80 |
self.id = None |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
81 |
self.dataFile = dataFile |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
82 |
self.watchdog = watchdog.WatchDog(900, lambda : self.KillSim()) |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
83 |
|
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
84 |
def Run(self): |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
85 |
self.lineTimeInfo = [] |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
86 |
output = False |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
87 |
self.timeStarted = time.gmtime() |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
88 |
self.id = time.strftime("%d-%m%--%Y-%H-%M-%S", self.timeStarted) |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
89 |
if self.dataFile != None: |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
90 |
filename = self.dataFile + "-" + self.GetRunId() + "-data.txt" |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
91 |
self.dataFileName = filename |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
92 |
output = open(filename, 'wb') |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
93 |
p = Popen( self.cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE ) |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
94 |
self.popen = p |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
95 |
stdin = p.stdin |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
96 |
stdout = p.stdout |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
97 |
stop = False |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
98 |
|
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
99 |
if self.displayp: |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
100 |
print >> sys.stdout, self.cmd |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
101 |
|
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
102 |
self.watchdog.Start() |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
103 |
try: |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
104 |
while p.poll() == None and not stop: |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
105 |
line = stdout.readline() |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
106 |
atime = time.clock() |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
107 |
self.watchdog.Reset() |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
108 |
if self.displayp and p.returncode == None: |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
109 |
print >> sys.stdout , line |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
110 |
if output and p.returncode == None: |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
111 |
print >> output , line |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
112 |
if p.returncode == None: |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
113 |
self.lineTimeInfo.append(LineTimeInfo(line, atime)) |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
114 |
if self.endOfTestFn != None: |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
115 |
stop = self.endOfTestFn(line) |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
116 |
else: |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
117 |
stop = self.EndOfTestp(line) |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
118 |
finally: |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
119 |
self.timeEnded = time.gmtime() |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
120 |
self.watchdog.Stop() |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
121 |
if output: |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
122 |
output.close() |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
123 |
self.testSuiteFinished = stop; |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
124 |
|
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
125 |
if p.returncode == None: |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
126 |
self.KillSim() |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
127 |
return True |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
128 |
else: |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
129 |
return False |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
130 |
|
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
131 |
def GetDataFileName(self): |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
132 |
return self.dataFileName |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
133 |
|
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
134 |
def TestSuiteFinishedp(self): |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
135 |
return self.testSuiteFinished |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
136 |
|
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
137 |
def EndOfTestp(self, l): |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
138 |
return re.match(self.endOfTestPattern,l) != None |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
139 |
|
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
140 |
def KillSim(self): |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
141 |
# if mswindows: |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
142 |
# win32api.TerminateProcess(int(self.popen._handle), -1) |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
143 |
# else: |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
144 |
os.kill(slef.popen.pid, signal.SIGKILL) |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
145 |
|
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
146 |
def GetResults(self): |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
147 |
return self.lineTimeInfo |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
148 |
|
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
149 |
def GetRomName(self): |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
150 |
return self.rompath |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
151 |
|
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
152 |
def GetRunId(self): |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
153 |
return self.id |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
154 |
|
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
155 |
def GetSummary(self): |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
156 |
simStat = os.stat(self.qemupath) |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
157 |
simSummary = "QEMU Executable: %s size: %d creation time: %d\n" % (self.qemupath, simStat[ST_SIZE], simStat[ST_CTIME]) |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
158 |
boardSummary ="Board: %s\n" % self.board |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
159 |
cpuSummary = "CPU: %s\n" % self.cpu |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
160 |
romStat = os.stat(self.rompath) |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
161 |
romSummary = "ROM image: %s size: %d creation date: %d\n" % (self.rompath, romStat[ST_SIZE], romStat[ST_CTIME]) |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
162 |
timeFormat = "%d-%m%--%Y %H:%M:%S" |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
163 |
startTime = "Start time: " + time.strftime(timeFormat, self.timeStarted) + "\n" |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
164 |
endTime = "End time: " + time.strftime(timeFormat, self.timeEnded) + "\n" |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
165 |
status = "Testsuite did not complete\n" |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
166 |
if self.TestSuiteFinishedp(): |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
167 |
status = "Testsuite completed\n" |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
168 |
return simSummary + boardSummary + cpuSummary + romSummary + startTime + endTime + status |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
169 |
|
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
170 |
def GetReportFileName(self): |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
171 |
return self.GetRomName() + "-" + self.GetRunId() + "-results-summary.txt" |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
172 |
|
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
173 |
class PseudoRunner(QemuTestRunner): |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
174 |
def __init__(self, input): |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
175 |
#self.qemupath = qemupath |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
176 |
#self.board = board |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
177 |
#self.cpu = cpu |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
178 |
#self.rompath = rompath |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
179 |
#self.endOfTestFn = endOfTestFn |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
180 |
#self.displayp = displayp |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
181 |
#self.cmd = qemupath + " -M syborg -cpu " + cpu + " -kernel " + rompath + " -nographic" |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
182 |
#self.endOfTestPattern = re.compile('RUNTESTS: Completed test script') |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
183 |
self.lineTimeInfo = [] |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
184 |
#self.id = None |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
185 |
self.dataFile = input |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
186 |
for line in open(input): |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
187 |
self.lineTimeInfo.append(LineTimeInfo(line, 0)) |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
188 |
|
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
189 |
def GetRomName(self): |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
190 |
return "Unknown" |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
191 |
|
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
192 |
def GetRunId(self): |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
193 |
return None |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
194 |
|
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
195 |
def GetSummary(self): |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
196 |
return "" |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
197 |
|
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
198 |
def GetReportFileName(self): |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
199 |
return "Runtest-Summary.txt" |