From 540289068bf76759ac54c9eb9f8dbc2e8d658e03 Mon Sep 17 00:00:00 2001 From: Ned Williamson Date: Sun, 8 Mar 2015 16:46:19 -0400 Subject: [PATCH] check runtime errors --- static2/testing.py | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/static2/testing.py b/static2/testing.py index f126bbb5..be23d878 100755 --- a/static2/testing.py +++ b/static2/testing.py @@ -15,7 +15,7 @@ import subprocess import argparse from elftools.elf.elffile import ELFFile -from elftools.common.exceptions import ELFError +from elftools.common.exceptions import ELFError, ELFParseError from glob import glob TEST_PATH = os.path.join(qira_config.BASEDIR,"tests_auto","binary-autogen","*") @@ -46,7 +46,7 @@ def get_functions(dwarfinfo): continue 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: short_fn = fn.split("/")[-1] if "/" in fn else fn if os.path.isdir(fn): @@ -78,10 +78,16 @@ def test_files(fns,quiet=False,profile=False): except KeyboardInterrupt: print "User stopped processing test cases." sys.exit() - except: - print "{} {}: {} engine failed to process file".format(fail, short_fn, - engine) + except MemoryError: + #print "{} {}: bap encountered a memory error.".format(fail, short_fn, engine) 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(): dwarfinfo = elf.get_dwarf_info() @@ -125,6 +131,8 @@ def get_file_list(location, recursive=False): for fn in glob(loc): if not os.path.isdir(fn): fns.append(fn) + if fns == []: + print "No files found. Try running with -r." return fns if __name__ == "__main__": @@ -137,6 +145,8 @@ if __name__ == "__main__": help="recurse into directories when checking") parser.add_argument("--quiet",dest="quiet",action="store_true", 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', help='use internal profiling, output to prof.png') parser.add_argument('--verbose',dest="verbose",action="store_true", @@ -152,4 +162,4 @@ if __name__ == "__main__": if len(fns) == 0: 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)