fix run-tests (not that it's used)

This commit is contained in:
Kevin Lange 2014-03-23 20:26:03 -07:00
parent e0ac170a18
commit c7414e579f
2 changed files with 75 additions and 68 deletions

View File

@ -13,14 +13,10 @@ void notice(char * type, char * fmt, ...) {
va_list argp;
va_start(argp, fmt);
/* core-tests header */
syscall_print("core-tests : ");
syscall_print(type);
syscall_print(" : ");
/* end core-tests header */
char buffer[1024];
vsnprintf(buffer, 1024, fmt, argp);
syscall_print(buffer);
syscall_print("\n");
printf("core-tests : %s : ", type);
vprintf(fmt, argp);
printf("\n");
}
int main(int argc, char * argv[]) {

View File

@ -1,66 +1,77 @@
#!/usr/bin/env python2
import subprocess, sys
import subprocess
import sys
import time
q = subprocess.Popen(['qemu-system-i386', '-kernel', 'toaruos-kernel', '-m', '256',
'-serial', 'stdio', '-vga', 'std', '-hda', 'toaruos-disk.img',
'-vnc', ':1', '-append', 'vgaterm hdd start=/bin/core-tests logtoserial=10'],
stdout=subprocess.PIPE)
class TestRunner(object):
passes = 0
failures = 0
result = 0
def __init__(self):
self.passes = 0
self.fails = 0
def process_line(line):
global passes, failures
data = line.strip().split(" : ")
if data[1] == "FAIL":
color = "1;31"
text = "fail"
failures += 1
elif data[1] == "WARN":
color = "1;33"
text = "warn"
elif data[1] == "PASS":
color = "1;32"
text = "pass"
passes += 1
elif data[1] == "INFO":
color = "1;34"
text = "info"
elif data[1] == "DONE":
color = "1;36"
text = "Done!"
elif data[1] == "FATAL":
color = "1;37;41"
text = "FATAL ERROR ECOUNTERED"
print "\033[%sm%s\033[0m %s" % (color, text, data[2])
if data[1] == "FATAL":
return 2
elif data[1] == "DONE":
return 1
return 0
def run(self):
self.qemu = subprocess.Popen(['make','-s','headless'], stdout=subprocess.PIPE, stdin=subprocess.PIPE)
time.sleep(2)
self.qemu.stdin.write("shell\n")
self.qemu.stdin.write("core-tests\n");
line = ""
while self.qemu.poll() == None:
charin = self.qemu.stdout.read(1)
if charin == '\n':
self.parse_line(line)
line = ""
else:
line += charin
print "\033[1mTest completed. \033[1;32m%d passes\033[0m, \033[1;31m%d failures\033[0m." % (self.passes, self.fails)
if self.fails > 0:
sys.exit(1)
def parse_line(self, line):
if line.startswith("core-tests :"):
output, result = self.process_line(line)
print output
if result > 0:
self.qemu.kill()
else:
self.log_line(line)
def process_line(self, line):
data = line.strip().split(" : ")
text = ""
color = ""
result = 0
if data[1] == "FAIL":
color = "1;31"
text = "fail"
self.fails += 1
elif data[1] == "WARN":
color = "1;33"
text = "warn"
elif data[1] == "PASS":
color = "1;32"
text = "pass"
self.passes += 1
elif data[1] == "INFO":
color = "1;34"
text = "info"
elif data[1] == "DONE":
color = "1;36"
text = "Done!"
result = 1
elif data[1] == "FATAL":
color = "1;37;41"
text = "FATAL ERROR ECOUNTERED"
result = 2
return "\033[%sm%s\033[0m %s" % (color, text, data[2]), result
def log_line(self, line):
print >>sys.stderr, line.strip()
def log_line(line):
print >>sys.stderr, line.strip()
while q.poll() == None:
line = q.stdout.readline()
if line:
if line.startswith("core-tests :"):
result = process_line(line)
if result > 0:
q.kill()
try:
subprocess.call(["stty","echo"])
except:
pass
if result == 2:
sys.exit(2)
else:
log_line(line)
print "\033[1mTest completed. \033[1;32m%d passes\033[0m, \033[1;31m%d failures\033[0m." % (passes, failures)
if failures > 0:
sys.exit(1)
if __name__ == "__main__":
TestRunner().run()