def parse_args(): p = optparse.OptionParser( usage='Usage: %prog [options] SOURCEDIR RESULTDIR', description='Barrelfish regression/benchmark harness') g = optparse.OptionGroup(p, 'Basic options') g.add_option('-b', '--build', action='append', dest='buildspecs', metavar='BUILD', help='build types to perform [default: release]') g.add_option('-B', '--buildbase', dest='buildbase', metavar='DIR', help='places builds under DIR [default: SOURCEDIR/builds]') g.add_option('-e', '--existingbuild', dest='existingbuild', metavar='DIR', help='existing build directory (may not be used with -b)') g.add_option('-m', '--machine', action='append', dest='machinespecs', metavar='MACHINE', help='victim machines to use') g.add_option('-t', '--test', action='append', dest='testspecs', metavar='TEST', help='tests/benchmarks to run') g.add_option('-c', '--comment', dest='comment', help='comment to store with all collected data') p.add_option_group(g) g = optparse.OptionGroup(p, 'Debugging options') g.add_option('-L', '--listall', action='store_true', dest='listall', help='list available builds, machines and tests') debug.addopts(g, 'debuglevel') g.add_option('-k', '--keepgoing', action='store_true', dest='keepgoing', help='attempt to continue on errors') p.add_option_group(g) p.set_defaults(debuglevel=debug.NORMAL) options, args = p.parse_args() debug.current_level = options.debuglevel if options.listall: list_all() sys.exit(0) if len(args) != 2: p.error('source and results directories must be specified') options.sourcedir, options.resultsdir = args # determine default buildbase if needed if options.buildbase is None: options.buildbase = os.path.join(options.sourcedir, 'builds') # check validity of source and results dirs if not os.path.isdir(os.path.join(options.sourcedir, 'hake')): p.error('invalid source directory %s' % options.sourcedir) if not (os.path.isdir(options.resultsdir) and os.access(options.resultsdir, os.W_OK)): p.error('invalid results directory %s' % options.resultsdir) # resolve and instantiate all builds def _lookup(spec, classes): spec = spec.lower() return [c for c in classes if fnmatch.fnmatch(c.name.lower(), spec)] if options.existingbuild: if options.buildspecs: p.error('existing build directory cannot be used together' ' with build types (-b)') options.builds = [builds.existingbuild(options, options.existingbuild)] else: options.builds = [] if not options.buildspecs: options.buildspecs = ['release'] for spec in options.buildspecs: matches = _lookup(spec, builds.all_builds) if matches == []: p.error('no builds match "%s" (try -L for a list)' % spec) options.builds.extend( [b for b in matches if b not in options.builds]) options.builds = [b(options) for b in options.builds] # resolve and instantiate all machines if options.machinespecs is None: p.error('no machines specified') options.machines = [] for spec in options.machinespecs: matches = _lookup(spec, machines.all_machines) if matches == []: p.error('no machines match "%s" (try -L for a list)' % spec) options.machines.extend( [m for m in matches if m not in options.machines]) options.machines = [m(options) for m in options.machines] # resolve and instantiate all tests if options.testspecs: options.tests = [] for spec in options.testspecs: matches = _lookup(spec, tests.all_tests) if matches == []: p.error('no tests match "%s" (try -L for a list)' % spec) options.tests.extend( [t for t in matches if t not in options.tests]) else: p.error('no tests specified (try -t memtest if unsure)') options.tests = [t(options) for t in options.tests] debug.verbose('Host: ' + gethostname()) debug.verbose('Builds: ' + ', '.join([b.name for b in options.builds])) debug.verbose('Machines: ' + ', '.join([m.name for m in options.machines])) debug.verbose('Tests: ' + ', '.join([t.name for t in options.tests])) return options
def parse_args(): p = optparse.OptionParser( usage='Usage: %prog [options] SOURCEDIR RESULTDIR', description='Barrelfish regression/benchmark harness') g = optparse.OptionGroup(p, 'Basic options') g.add_option('-b', '--build', action='append', dest='buildspecs', metavar='BUILD', help='build types to perform [default: test]') g.add_option('-B', '--buildbase', dest='buildbase', metavar='DIR', help='places builds under DIR [default: SOURCEDIR/builds]') g.add_option('-e', '--existingbuild', dest='existingbuild', metavar='DIR', help='existing build directory (may not be used with -b)') g.add_option('-m', '--machine', action='append', dest='machinespecs', metavar='MACHINE', help='victim machines to use') g.add_option('-t', '--test', action='append', dest='testspecs', metavar='TEST', help='tests/benchmarks to run') g.add_option('-c', '--comment', dest='comment', help='comment to store with all collected data') g.add_option('-x', '--xml', dest='xml', action='store_true', default=False, help='output summary of tests in Junit XML format') p.add_option_group(g) g = optparse.OptionGroup(p, 'Debugging options') g.add_option('-L', '--listall', action='store_true', dest='listall', help='list available builds, machines and tests') debug.addopts(g, 'debuglevel') g.add_option('-k', '--keepgoing', action='store_true', dest='keepgoing', help='attempt to continue on errors') p.add_option_group(g) p.set_defaults(debuglevel=debug.NORMAL) options, args = p.parse_args() debug.current_level = options.debuglevel if options.listall: list_all() sys.exit(0) if len(args) != 2: p.error('source and results directories must be specified') options.sourcedir, options.resultsdir = args # determine default buildbase if needed if options.buildbase is None: options.buildbase = os.path.join(options.sourcedir, 'builds') # check validity of source and results dirs if not os.path.isdir(os.path.join(options.sourcedir, 'hake')): p.error('invalid source directory %s' % options.sourcedir) if not (os.path.isdir(options.resultsdir) and os.access(options.resultsdir, os.W_OK)): p.error('invalid results directory %s' % options.resultsdir) if options.xml and not have_junit_xml: p.error('--xml requires junit-xml.\n' 'Please install junit-xml through pip or easy_install') # resolve and instantiate all builds def _lookup(spec, classes, nameFn=lambda c: c.name.lower()): spec = spec.lower() return [c for c in classes if fnmatch.fnmatch(nameFn(c), spec)] if options.existingbuild: if options.buildspecs: p.error('existing build directory cannot be used together' ' with build types (-b)') options.builds = [builds.existingbuild(options, options.existingbuild)] options.buildbase = options.existingbuild else: options.builds = [] if not options.buildspecs: options.buildspecs = ['test'] for spec in options.buildspecs: matches = _lookup(spec, builds.all_builds) if matches == []: p.error('no builds match "%s" (try -L for a list)' % spec) options.builds.extend( [b for b in matches if b not in options.builds]) options.builds = [b(options) for b in options.builds] # resolve and instantiate all machines if options.machinespecs is None: p.error('no machines specified') options.machines = [] for spec in options.machinespecs: matches = _lookup(spec, MachineFactory.machineFactories, nameFn=lambda fac: fac.lower()) if matches == []: p.error('no machines match "%s" (try -L for a list)' % spec) options.machines.extend( [m for m in matches if m not in options.machines]) options.machines = [ MachineFactory.createMachineByName(m, options) for m in options.machines ] # resolve and instantiate all tests if options.testspecs: options.tests = [] for spec in options.testspecs: matches = _lookup(spec, tests.all_tests) if matches == []: p.error('no tests match "%s" (try -L for a list)' % spec) options.tests.extend( [t for t in matches if t not in options.tests]) else: p.error('no tests specified (try -t memtest if unsure)') options.tests = [t(options) for t in options.tests] debug.verbose('Host: ' + gethostname()) debug.verbose('Builds: ' + ', '.join([b.name for b in options.builds])) debug.verbose('Machines: ' + ', '.join([m.getName() for m in options.machines])) debug.verbose('Tests: ' + ', '.join([t.name for t in options.tests])) return options
def parse_args(): p = optparse.OptionParser( usage='Usage: %prog [options] SOURCEDIR BUILDDIR', description='AOS Autograder') g = optparse.OptionGroup(p, 'Basic options') g.add_option('-b', '--buildbase', dest='buildbase', metavar='DIR', help='places builds under DIR [default: SOURCEDIR/builds]') g.add_option('-m', '--machine', action='append', dest='machinespecs', metavar='MACHINE', help='victim machines to use') g.add_option('-t', '--test', action='append', dest='testspecs', metavar='TEST', help='tests/benchmarks to run') p.add_option_group(g) g = optparse.OptionGroup(p, 'Debugging options') g.add_option('-L', '--listall', action='store_true', dest='listall', help='list available builds, machines and tests') debug.addopts(g, 'debuglevel') g.add_option('-k', '--keepgoing', action='store_true', dest='keepgoing', help='attempt to continue on errors') p.add_option_group(g) p.set_defaults(debuglevel=debug.NORMAL) options, args = p.parse_args() debug.current_level = options.debuglevel if options.listall: list_all() sys.exit(0) if len(args) != 2: p.error('source and build directory must be specified') options.sourcedir, options.builddir = args options.builds = [builds.existingbuild(options, options.builddir)] # check validity of source and results dirs if not os.path.isdir(os.path.join(options.sourcedir, 'hake')): p.error('invalid source directory %s' % options.sourcedir) if not (os.path.isdir(options.builddir) and os.access(options.builddir, os.W_OK)): p.error('invalid build directory %s' % options.builddir) options.resultsdir = os.path.join(options.builddir, "results") if not os.path.isdir(options.resultsdir): os.mkdir(options.resultsdir, 0755) # resolve and instantiate all builds def _lookup(spec, classes): spec = spec.lower() return [c for c in classes if fnmatch.fnmatch(c.name.lower(), spec)] # resolve and instantiate all machines if options.machinespecs is None: p.error('no machines specified') options.machines = [] for spec in options.machinespecs: matches = _lookup(spec, machines.all_machines) if matches == []: p.error('no machines match "%s" (try -L for a list)' % spec) options.machines.extend( [m for m in matches if m not in options.machines]) options.machines = [m(options) for m in options.machines] # resolve and instantiate all tests if options.testspecs: options.tests = [] for spec in options.testspecs: matches = _lookup(spec, tests.all_tests) if matches == []: p.error('no tests match "%s" (try -L for a list)' % spec) options.tests.extend( [t for t in matches if t not in options.tests]) else: p.error('no tests specified (try -t hello if unsure)') options.tests = [t(options) for t in options.tests] debug.verbose('Host: ' + gethostname()) debug.verbose('Builds: ' + ', '.join([b.name for b in options.builds])) debug.verbose('Machines: ' + ', '.join([m.name for m in options.machines])) debug.verbose('Tests: ' + ', '.join([t.name for t in options.tests])) return options