X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=lib%2Fas3%2Fruntests.py;h=b46206dfdc0be4f708dca2390979cf8f85985fb2;hb=91f2889c15fa9cd7290b840beae49218131b5636;hp=a5e865c2f46e6ecce745c24cec7e6ecfcfd95838;hpb=802358aa95688439e3acc0444951ea11a7b1f051;p=swftools.git diff --git a/lib/as3/runtests.py b/lib/as3/runtests.py index a5e865c..b46206d 100644 --- a/lib/as3/runtests.py +++ b/lib/as3/runtests.py @@ -25,6 +25,7 @@ import os import time import subprocess import marshal +import select from optparse import OptionParser def check(s): @@ -58,22 +59,30 @@ def check(s): return 0 def runcmd(cmd,args,wait): - #fo = open(tempfile, "wb") - fo= os.tmpfile() + #fo = os.tmpfile() + fi,fo = os.pipe() + fo = os.fdopen(fo, "wb") p = subprocess.Popen([cmd] + args, executable=cmd, stdout=fo, stderr=fo) ret = -1 + output = "" for i in range(wait*10): + if fi in select.select([fi],[],[], 0.01)[0]: + output += os.read(fi, 8192) + if "[exit]" in output: + break ret = p.poll() if ret is not None: break time.sleep(0.1) else: os.kill(p.pid, 9) - os.system("killall -9 "+cmd) - - fo.seek(0) - output = fo.read() + os.system("killall -9 %s >/dev/null 2>/dev/null" % cmd) fo.close() + + if fi in select.select([fi],[],[], 0.01)[0]: + output += os.read(fi, 8192) + + os.close(fi) return ret,output class Cache: @@ -131,7 +140,10 @@ class TestBase: ret,output = runcmd("./parser",[self.file],wait=60) self.compile_error = 0 self.compile_output = output + self.exit_status = 0 if ret: + self.compile_output += "\nExit status %d" % (-ret) + self.exit_status = -ret self.compile_error = 1 return 0 if not os.path.isfile("abc.swf"): @@ -153,11 +165,14 @@ class TestBase: print self.r(str(self.nr),3)," ", if self.compile_error: if self.dorun: - print "err"," - ", + if self.exit_status == 11: + print "crash"," - ", + else: + print "err "," - ", else: - print "err"," ", + print "err "," ", else: - print "ok ", + print "ok ", if self.dorun: if not self.flash_error: print "ok ", @@ -171,13 +186,13 @@ class TestBase: def doprintlong(self): print self.nr, self.file print "================================" - print "compile:", (test.compile_error and "error" or "ok") - print test.compile_output + print "compile:", (self.compile_error and "error" or "ok") + print self.compile_output if not self.dorun: return print "================================" - print "run:", (test.flash_error and "error" or "ok") - print test.flash_output + print "run:", (self.flash_error and "error" or "ok") + print self.flash_output print "================================" def r(self,s,l):