예제 #1
0
def clean(args):
    '''Remove source database and all objects'''
    maker = builder.PETScMaker()
    maker.setup()
    maker.clean('libpetsc')
    maker.cleanup()
    return 0
예제 #2
0
def check(args):
  '''Check that build is functional'''
  ret       = 0
  extraArgs = ' '+' '.join(args.args)
  maker     = builder.PETScMaker('example.log')
  maker.setup()
  if 'regParams' in args and not args.regParams is None:
    mod = __import__(args.regParams)
    builder.localRegressionParameters[os.path.dirname(mod.__file__)] = mod.regressionParameters
  # C test
  if len(args.files):
    examples = []
    for f in args.files:
      if f[0] == '[':
        examples.append(map(os.path.abspath, f[1:-1].split(',')))
      else:
        examples.append(os.path.abspath(f))
  else:
    examples = [os.path.join(maker.petscDir, 'src', 'snes', 'examples', 'tutorials', 'ex5.c')]
  # Fortran test
  if not len(args.files):
    if hasattr(maker.configInfo.compilers, 'FC'):
      examples.append(os.path.join(maker.petscDir, 'src', 'snes', 'examples', 'tutorials', 'ex5f90t.F'))
      examples.append(os.path.join(maker.petscDir, 'src', 'snes', 'examples', 'tutorials', 'ex5f90.F'))
      examples.append(os.path.join(maker.petscDir, 'src', 'snes', 'examples', 'tutorials', 'ex5f.F'))
  for ex in examples:
    ret = checkSingleRun(maker, ex, args.replace, extraArgs)
    if ret: break
  if not ret:
    print('All tests pass')
  maker.cleanup()
  return ret
예제 #3
0
def regression(args):
    '''Run complete regression suite'''
    ret = 0
    maker = builder.PETScMaker()
    maker.setup()

    args.retain = False
    args.testnum = None
    walker = builder.DirectoryTreeWalker(maker.argDB,
                                         maker.log,
                                         maker.configInfo,
                                         allowExamples=True)
    #dirs = map(lambda d: os.path.join(maker.petscDir, 'src', d), ['inline', 'sys', 'vec', 'mat', 'dm', 'ksp', 'snes', 'ts', 'docs', 'tops'])
    dirs = map(lambda d: os.path.join(maker.petscDir, 'src', d), ['vec'])
    for d in dirs:
        print 'Dir', d
        for root, files in walker.walk(d):
            baseDir = os.path.basename(root)
            if not baseDir == 'tests' and not baseDir == 'tutorials': continue
            for f in files:
                basename, ext = os.path.splitext(f)
                if not basename.startswith('ex'): continue
                if not ext in ['.c', '.F']: continue
                ex = os.path.join(root, f)
                ret = checkSingleRun(maker, ex)
                if ret: break
            if ret: break
        if ret: break
    if not ret:
        print('All regression tests pass')
    maker.cleanup()
    return ret
예제 #4
0
def stubs(args):
    '''Build stubs for certain languages'''
    maker = builder.PETScMaker()
    maker.setup()
    for language in args.languages:
        print(language)
        getattr(maker, 'build' + language.capitalize() + 'Stubs')()
    maker.cleanup()
    return 0
예제 #5
0
def purge(args):
    '''Remove a sets of files from the source database'''
    maker = builder.PETScMaker()
    maker.setup()
    maker.updateDependencies('libpetsc', maker.rootDir)
    for p in args.files:
        filename = os.path.abspath(p)
        maker.logPrint('Removing %s from the source database' % filename)
        maker.sourceDatabase.removeNode(filename)
    maker.cleanup()
    return 0
예제 #6
0
def regression(args):
    '''Run complete regression suite'''
    ret = 0
    maker = builder.PETScMaker()
    maker.setup()
    for ex in examples:
        ret = checkSingleRun(maker, ex)
        if ret: break
    if not ret:
        print('All regression tests pass')
    maker.cleanup()
    return ret
예제 #7
0
def build(dry_run=False):
    log.info('PETSc: build')
    # Run PETSc build
    if dry_run: return
    use_builder_py = False
    if use_builder_py:
        import builder
        builder.PETScMaker().run()
        import logger
        logger.Logger.defaultLog = None
    else:
        make = find_executable('make')
        status = os.system(" ".join([make, 'all']))
        if status != 0: raise RuntimeError(status)
예제 #8
0
def buildExample(args):
    '''Build and link an example'''
    ret = 0
    maker = builder.PETScMaker()
    maker.setup()
    examples = []
    for f in args.files:
        if f[0] == '[':
            examples.append(map(os.path.abspath, f[1:-1].split(',')))
        else:
            examples.append(os.path.abspath(f))
    for ex in examples:
        ret = buildSingleExample(maker, ex)
        if ret: break
    maker.cleanup()
    return ret
예제 #9
0
def regression(args):
    '''Run complete regression suite'''
    ret = 0
    gret = 0
    maker = builder.PETScMaker('regression.log')
    maker.setup()
    haltOnError = False

    args.retain = False
    args.testnum = None
    if len(args.dirs):
        regdirs = args.dirs
    else:
        regdirs = map(lambda d: os.path.join('src', d), [
            'inline', 'sys', 'vec', 'mat', 'dm', 'ksp', 'snes', 'ts', 'docs',
            'tops'
        ])
    walker = builder.DirectoryTreeWalker(maker.argDB,
                                         maker.log,
                                         maker.configInfo,
                                         allowExamples=True)
    dirs = map(lambda d: os.path.join(maker.petscDir, d), regdirs)
    for d in dirs:
        for root, files in walker.walk(d):
            baseDir = os.path.basename(root)
            if not baseDir == 'tests' and not baseDir == 'tutorials': continue
            maker.logPrint('Running regression tests in %s\n' % (baseDir, ),
                           debugSection='screen',
                           forceScroll=True)
            for f in files:
                basename, ext = os.path.splitext(f)
                if not basename.startswith('ex'): continue
                if not ext in ['.c', '.F']: continue
                ex = os.path.join(root, f)
                ret = checkSingleRun(maker, ex, False, isRegression=True)
                if ret:
                    gret = ret
                    if haltOnError: break
            if ret and haltOnError: break
        if ret and haltOnError: break
    if not gret:
        maker.logPrint('All regression tests pass\n',
                       debugSection='screen',
                       forceScroll=True)
    maker.cleanup()
    return gret
예제 #10
0
def build(args):
  '''Compile all out of date source and generate a new shared library
  Any files specified will be added to the source database if not already present'''
  # TODO: Make rootDir an option (this should really be a filter for sourceDB)
  maker = builder.PETScMaker()
  maker.setup()
  maker.updateDependencies('libpetsc', maker.rootDir)
  for p in args.files:
    filename = os.path.abspath(p)
    if not maker.sourceDatabase.hasNode(filename):
      maker.logPrint('Adding %s to the source database' % filename)
      maker.sourceDatabase.setNode(filename, [])
  if maker.buildLibraries('libpetsc', maker.rootDir, args.parallel) and args.rebuildDep:
    # This is overkill, but right now it is cheap
    maker.rebuildDependencies('libpetsc', maker.rootDir)
  maker.cleanup()
  return 0
예제 #11
0
def show(args):
    '''Show run information'''
    ret = 0
    extraArgs = ' ' + ' '.join(args.args)
    maker = builder.PETScMaker()
    maker.setup()
    # C test
    examples = []
    for f in args.files:
        if f[0] == '[':
            examples.append(map(os.path.abspath, f[1:-1].split(',')))
        else:
            examples.append(os.path.abspath(f))
    for ex in examples:
        ret = showSingleRun(maker, ex, extraArgs)
        if ret: break
    maker.cleanup()
    return ret
예제 #12
0
def check(args):
    '''Check that build is functional'''
    ret = 0
    extraArgs = ' ' + ' '.join(args.args)
    maker = builder.PETScMaker()
    maker.setup()
    # C test
    if len(args.files):
        examples = []
        for f in args.files:
            if f[0] == '[':
                examples.append(map(os.path.abspath, f[1:-1].split(',')))
            else:
                examples.append(os.path.abspath(f))
    else:
        examples = [
            os.path.join(maker.petscDir, 'src', 'snes', 'examples',
                         'tutorials', 'ex5.c')
        ]
    # Fortran test
    if not len(args.files):
        if hasattr(maker.configInfo.compilers, 'FC'):
            if maker.configInfo.fortrancpp.fortranDatatypes:
                examples.append(
                    os.path.join(maker.petscDir, 'src', 'snes', 'examples',
                                 'tutorials', 'ex5f90t.F'))
            elif maker.configInfo.compilers.fortranIsF90:
                examples.append(
                    os.path.join(maker.petscDir, 'src', 'snes', 'examples',
                                 'tutorials', 'ex5f90.F'))
            else:
                examples.append(
                    os.path.join(maker.petscDir, 'src', 'snes', 'examples',
                                 'tutorials', 'ex5f.F'))
    for ex in examples:
        ret = checkSingleRun(maker, ex, args.replace, extraArgs)
        if ret: break
    if not ret:
        print('All tests pass')
    maker.cleanup()
    return ret