check runtime errors

This commit is contained in:
Ned Williamson 2015-03-08 16:46:19 -04:00
parent 2b9119660b
commit 540289068b
1 changed files with 16 additions and 6 deletions

View File

@ -15,7 +15,7 @@ import subprocess
import argparse import argparse
from elftools.elf.elffile import ELFFile from elftools.elf.elffile import ELFFile
from elftools.common.exceptions import ELFError from elftools.common.exceptions import ELFError, ELFParseError
from glob import glob from glob import glob
TEST_PATH = os.path.join(qira_config.BASEDIR,"tests_auto","binary-autogen","*") TEST_PATH = os.path.join(qira_config.BASEDIR,"tests_auto","binary-autogen","*")
@ -46,7 +46,7 @@ def get_functions(dwarfinfo):
continue continue
return function_starts return function_starts
def test_files(fns,quiet=False,profile=False): def test_files(fns,quiet=False,profile=False,runtime=False):
for fn in fns: for fn in fns:
short_fn = fn.split("/")[-1] if "/" in fn else fn short_fn = fn.split("/")[-1] if "/" in fn else fn
if os.path.isdir(fn): if os.path.isdir(fn):
@ -78,10 +78,16 @@ def test_files(fns,quiet=False,profile=False):
except KeyboardInterrupt: except KeyboardInterrupt:
print "User stopped processing test cases." print "User stopped processing test cases."
sys.exit() sys.exit()
except: except MemoryError:
print "{} {}: {} engine failed to process file".format(fail, short_fn, #print "{} {}: bap encountered a memory error.".format(fail, short_fn, engine)
engine)
continue continue
except Exception as e:
print "{} {}: {} engine failed to process file with `{}'".format(fail, short_fn, engine, e)
continue
if runtime:
if not quiet:
print "{} {}: {} ran without exceptions".format(ok_green, short_fn, engine)
continue
if elf.has_dwarf_info(): if elf.has_dwarf_info():
dwarfinfo = elf.get_dwarf_info() dwarfinfo = elf.get_dwarf_info()
@ -125,6 +131,8 @@ def get_file_list(location, recursive=False):
for fn in glob(loc): for fn in glob(loc):
if not os.path.isdir(fn): if not os.path.isdir(fn):
fns.append(fn) fns.append(fn)
if fns == []:
print "No files found. Try running with -r."
return fns return fns
if __name__ == "__main__": if __name__ == "__main__":
@ -137,6 +145,8 @@ if __name__ == "__main__":
help="recurse into directories when checking") help="recurse into directories when checking")
parser.add_argument("--quiet",dest="quiet",action="store_true", parser.add_argument("--quiet",dest="quiet",action="store_true",
help="don't warn about skipped cases") help="don't warn about skipped cases")
parser.add_argument("--runtime",dest="runtime",action="store_true",
help="only check for runtime errors")
parser.add_argument('--profile',dest="profile",action='store_true', parser.add_argument('--profile',dest="profile",action='store_true',
help='use internal profiling, output to prof.png') help='use internal profiling, output to prof.png')
parser.add_argument('--verbose',dest="verbose",action="store_true", parser.add_argument('--verbose',dest="verbose",action="store_true",
@ -152,4 +162,4 @@ if __name__ == "__main__":
if len(fns) == 0: if len(fns) == 0:
print "No files found in {}. Try running python autogen.py --dwarf in the tests directory.".format(TEST_PATH) print "No files found in {}. Try running python autogen.py --dwarf in the tests directory.".format(TEST_PATH)
test_files(fns,args.quiet, args.profile) test_files(fns, args.quiet, args.profile, args.runtime)