def main(): if not is_in_rootdir(): testlog.error('Error: Please run me from the root dir of pyelftools!') return 1 run_test_script('test/run_all_unittests.py') run_test_script('test/run_examples_test.py') run_test_script('test/run_readelf_tests.py', '--parallel')
def main(): if not is_in_rootdir(): testlog.error('Error: Please run me from the root dir of pyelftools!') return 1 run_test_script('test/run_all_unittests.py') run_test_script('test/run_examples_test.py') run_test_script('test/run_readelf_tests.py')
def main(): if not is_in_rootdir(): testlog.error('Error: Please run me from the root dir of pyelftools!') return 1 optparser = OptionParser(usage='usage: %prog [options] [file] [file] ...', prog='run_readelf_tests.py') optparser.add_option('-V', '--verbose', action='store_true', dest='verbose', help='Verbose output') optparser.add_option('-k', '--keep-going', action='store_true', dest='keep_going', help="Run all tests, don't stop at the first failure") options, args = optparser.parse_args() if options.verbose: testlog.info('Running in verbose mode') testlog.info('Python executable = %s' % sys.executable) testlog.info('readelf path = %s' % READELF_PATH) testlog.info('Given list of files: %s' % args) # If file names are given as command-line arguments, only these files # are taken as inputs. Otherwise, autodiscovery is performed. if len(args) > 0: filenames = args else: filenames = sorted(discover_testfiles('test/testfiles_for_readelf')) failures = 0 for filename in filenames: if not run_test_on_file(filename, verbose=options.verbose): failures += 1 if not options.keep_going: break if failures == 0: testlog.info('\nConclusion: SUCCESS') return 0 elif options.keep_going: testlog.info('\nConclusion: FAIL ({}/{})'.format( failures, len(filenames))) return 1 else: testlog.info('\nConclusion: FAIL') return 1
def main(): if not is_in_rootdir(): testlog.error('Error: Please run me from the root dir of pyelftools!') return 1 success = True for example_path in discover_examples(): if success: success = success and run_example_and_compare(example_path) if success: testlog.info('\nConclusion: SUCCESS') return 0 else: testlog.info('\nConclusion: FAIL') return 1
def main(): if not is_in_rootdir(): testlog.error('Error: Please run me from the root dir of pyelftools!') return 1 optparser = OptionParser( usage='usage: %prog [options] [file] [file] ...', prog='run_readelf_tests.py') optparser.add_option('-V', '--verbose', action='store_true', dest='verbose', help='Verbose output') optparser.add_option('-k', '--keep-going', action='store_true', dest='keep_going', help="Run all tests, don't stop at the first failure") options, args = optparser.parse_args() if options.verbose: testlog.info('Running in verbose mode') testlog.info('Python executable = %s' % sys.executable) testlog.info('readelf path = %s' % READELF_PATH) testlog.info('Given list of files: %s' % args) # If file names are given as command-line arguments, only these files # are taken as inputs. Otherwise, autodiscovery is performed. if len(args) > 0: filenames = args else: filenames = sorted(discover_testfiles('test/testfiles_for_readelf')) failures = 0 for filename in filenames: if not run_test_on_file(filename, verbose=options.verbose): failures += 1 if not options.keep_going: break if failures == 0: testlog.info('\nConclusion: SUCCESS') return 0 elif options.keep_going: testlog.info('\nConclusion: FAIL ({}/{})'.format( failures, len(filenames))) return 1 else: testlog.info('\nConclusion: FAIL') return 1
def main(): if not is_in_rootdir(): testlog.error('Error: Please run me from the root dir of pyelftools!') return 1 optparser = OptionParser( usage='usage: %prog [options] [file] [file] ...', prog='run_readelf_tests.py') optparser.add_option('-V', '--verbose', action='store_true', dest='verbose', help='Verbose output') options, args = optparser.parse_args() if options.verbose: testlog.info('Running in verbose mode') testlog.info('Python executable = %s' % sys.executable) testlog.info('readelf path = %s' % READELF_PATH) testlog.info('Given list of files: %s' % args) # If file names are given as command-line arguments, only these files # are taken as inputs. Otherwise, autodiscovery is performed. # if len(args) > 0: filenames = args else: filenames = list(discover_testfiles('test/testfiles_for_readelf')) success = True for filename in filenames: if success: success = success and run_test_on_file( filename, verbose=options.verbose) if success: testlog.info('\nConclusion: SUCCESS') return 0 else: testlog.info('\nConclusion: FAIL') return 1
def main(): if not is_in_rootdir(): testlog.error('Error: Please run me from the root dir of pyelftools!') return 1 argparser = argparse.ArgumentParser( usage='usage: %(prog)s [options] [file] [file] ...', prog='run_readelf_tests.py') argparser.add_argument('files', nargs='*', help='files to run tests on') argparser.add_argument( '--parallel', action='store_true', help='run tests in parallel; always runs all tests w/o verbose') argparser.add_argument('-V', '--verbose', action='store_true', dest='verbose', help='verbose output') argparser.add_argument( '-k', '--keep-going', action='store_true', dest='keep_going', help="Run all tests, don't stop at the first failure") args = argparser.parse_args() if args.parallel: if args.verbose or args.keep_going == False: print('WARNING: parallel mode disables verbosity and always keeps going') if args.verbose: testlog.info('Running in verbose mode') testlog.info('Python executable = %s' % sys.executable) testlog.info('readelf path = %s' % READELF_PATH) testlog.info('Given list of files: %s' % args.files) # If file names are given as command-line arguments, only these files # are taken as inputs. Otherwise, autodiscovery is performed. if len(args.files) > 0: filenames = args.files else: filenames = sorted(discover_testfiles('test/testfiles_for_readelf')) if len(filenames) > 1 and args.parallel: pool = Pool() results = pool.map( run_test_on_file, filenames) failures = results.count(False) else: failures = 0 for filename in filenames: if not run_test_on_file(filename, verbose=args.verbose): failures += 1 if not args.keep_going: break if failures == 0: testlog.info('\nConclusion: SUCCESS') return 0 elif args.keep_going: testlog.info('\nConclusion: FAIL ({}/{})'.format( failures, len(filenames))) return 1 else: testlog.info('\nConclusion: FAIL') return 1
def main(): if not is_in_rootdir(): testlog.error('Error: Please run me from the root dir of pyelftools!') return 1 argparser = argparse.ArgumentParser( usage='usage: %(prog)s [options] [file] [file] ...', prog='run_readelf_tests.py') argparser.add_argument('files', nargs='*', help='files to run tests on') argparser.add_argument( '--parallel', action='store_true', help='run tests in parallel; always runs all tests w/o verbose') argparser.add_argument('-V', '--verbose', action='store_true', dest='verbose', help='verbose output') argparser.add_argument( '-k', '--keep-going', action='store_true', dest='keep_going', help="Run all tests, don't stop at the first failure") argparser.add_argument('--opt', action='store', dest='opt', metavar='<readelf-option>', help='Limit the test one one readelf option.') args = argparser.parse_args() if args.parallel: if args.verbose or args.keep_going == False: print( 'WARNING: parallel mode disables verbosity and always keeps going' ) if args.verbose: testlog.info('Running in verbose mode') testlog.info('Python executable = %s' % sys.executable) testlog.info('readelf path = %s' % READELF_PATH) testlog.info('Given list of files: %s' % args.files) # If file names are given as command-line arguments, only these files # are taken as inputs. Otherwise, autodiscovery is performed. if len(args.files) > 0: filenames = args.files else: filenames = sorted(discover_testfiles('test/testfiles_for_readelf')) if len(filenames) > 1 and args.parallel: pool = Pool() results = pool.map(run_test_on_file, filenames) failures = results.count(False) else: failures = 0 for filename in filenames: if not run_test_on_file(filename, args.verbose, args.opt): failures += 1 if not args.keep_going: break if failures == 0: testlog.info('\nConclusion: SUCCESS') return 0 elif args.keep_going: testlog.info('\nConclusion: FAIL ({}/{})'.format( failures, len(filenames))) return 1 else: testlog.info('\nConclusion: FAIL') return 1