Пример #1
0
    def _getLoopVars(self, inDict, testname, isSubtest=False):
        """
    Given: 'args: -bs {{1 2 3 4 5}} -pc_type {{cholesky sor}} -ksp_monitor'
    Return:
      inDict['args']: -ksp_monitor
      inDict['subargs']: -bs ${bs} -pc_type ${pc_type}
      loopVars['subargs']['varlist']=['bs' 'pc_type']   # Don't worry about OrderedDict
      loopVars['subargs']['bs']=[["bs"],["1 2 3 4 5"]]
      loopVars['subargs']['pc_type']=[["pc_type"],["cholesky sor"]]
    subst should be passed in instead of inDict
    """
        loopVars = {}
        newargs = []
        lsuffix = '_'
        argregex = re.compile(' (?=-[a-zA-Z])')
        from testparse import parseLoopArgs
        for key in inDict:
            if key in ('SKIP', 'regexes'):
                continue
            akey = ('subargs' if key == 'args' else key)  # what to assign
            if akey not in inDict: inDict[akey] = ''
            if akey == 'nsize' and not inDict['nsize'].startswith('{{'):
                # Always generate a loop over nsize, even if there is only one value
                inDict['nsize'] = '{{' + inDict['nsize'] + '}}'
            keystr = str(inDict[key])
            varlist = []
            for varset in argregex.split(keystr):
                if not varset.strip(): continue
                if '{{' in varset:
                    keyvar, lvars, ftype = parseLoopArgs(varset)
                    if akey not in loopVars: loopVars[akey] = {}
                    varlist.append(keyvar)
                    loopVars[akey][keyvar] = [keyvar, lvars]
                    if akey == 'nsize':
                        if len(lvars.split()) > 1:
                            lsuffix += akey + '-${' + keyvar + '}'
                    else:
                        inDict[akey] += ' -' + keyvar + ' ${' + keyvar + '}'
                        lsuffix += keyvar + '-${' + keyvar + '}_'
                else:
                    if key == 'args':
                        newargs.append(varset.strip())
                if varlist:
                    loopVars[akey]['varlist'] = varlist

        # For subtests, args are always substituted in (not top level)
        if isSubtest:
            inDict['subargs'] += " ".join(newargs)
            inDict['args'] = ''
            if 'label_suffix' in inDict:
                inDict['label_suffix'] += lsuffix.rstrip('_')
            else:
                inDict['label_suffix'] = lsuffix.rstrip('_')
        else:
            if loopVars:
                inDict['args'] = ' '.join(newargs)
                inDict['label_suffix'] = lsuffix.rstrip('_')
        return loopVars
Пример #2
0
  def _getLoopVars(self,inDict,testname, isSubtest=False):
    """
    Given: 'args: -bs {{1 2 3 4 5}} -pc_type {{cholesky sor}} -ksp_monitor'
    Return:
      inDict['args']: -ksp_monitor
      inDict['subargs']: -bs ${bs} -pc_type ${pc_type}
      loopVars['subargs']['varlist']=['bs' 'pc_type']   # Don't worry about OrderedDict
      loopVars['subargs']['bs']=[["bs"],["1 2 3 4 5"]]
      loopVars['subargs']['pc_type']=[["pc_type"],["cholesky sor"]]
    subst should be passed in instead of inDict
    """
    loopVars={}; newargs=[]
    lsuffix='_'
    argregex = re.compile(' (?=-[a-zA-Z])')
    from testparse import parseLoopArgs
    for key in inDict:
      if key in ('SKIP', 'regexes'):
        continue
      akey=('subargs' if key=='args' else key)  # what to assign
      if akey not in inDict: inDict[akey]=''
      if akey == 'nsize' and not inDict['nsize'].startswith('{{'):
        # Always generate a loop over nsize, even if there is only one value
        inDict['nsize'] = '{{' + inDict['nsize'] + '}}'
      keystr = str(inDict[key])
      varlist = []
      for varset in argregex.split(keystr):
        if not varset.strip(): continue
        if '{{' in varset:
          keyvar,lvars,ftype=parseLoopArgs(varset)
          if akey not in loopVars: loopVars[akey]={}
          varlist.append(keyvar)
          loopVars[akey][keyvar]=[keyvar,lvars]
          if akey=='nsize':
            if len(lvars.split()) > 1:
              lsuffix += akey +'-${' + keyvar + '}'
          else:
            inDict[akey] += ' -'+keyvar+' ${' + keyvar + '}'
            lsuffix+=keyvar+'-${' + keyvar + '}_'
        else:
          if key=='args':
            newargs.append(varset.strip())
        if varlist:
          loopVars[akey]['varlist']=varlist

    # For subtests, args are always substituted in (not top level)
    if isSubtest:
      inDict['subargs'] += " ".join(newargs)
      inDict['args']=''
      if 'label_suffix' in inDict:
        inDict['label_suffix']+=lsuffix.rstrip('_')
      else:
        inDict['label_suffix']=lsuffix.rstrip('_')
    else:
      if loopVars:
        inDict['args'] = ' '.join(newargs)
        inDict['label_suffix']=lsuffix.rstrip('_')
    return loopVars
Пример #3
0
    def _getLoopVars(self, inDict, testname, isSubtest=False):
        """
    Given: 'args: -bs {{1 2 3 4 5}} -pc_type {{cholesky sor}} -ksp_monitor'
    Return: 
      inDict['args']: -ksp_monitor
      inDict['subargs']: -bs ${bs} -pc_type ${pc_type}
      loopVars['subargs']['varlist']=['bs' 'pc_type']   # Don't worry about OrderedDict
      loopVars['subargs']['bs']=[["bs"],["1 2 3 4 5"]]
      loopVars['subargs']['pc_type']=[["pc_type"],["cholesky sor"]]
    subst should be passed in instead of inDict
    """
        loopVars = {}
        newargs = ""
        lkeys = inDict.keys()
        lsuffix = '_'
        argregex = re.compile('(?<![a-zA-Z])-(?=[a-zA-Z])')
        from testparse import parseLoopArgs
        for key in lkeys:
            if type(inDict[key]) != bytes: continue
            keystr = str(inDict[key])
            akey = ('subargs' if key == 'args' else key)  # what to assign
            if akey not in inDict: inDict[akey] = ''
            varlist = []
            for varset in argregex.split(keystr):
                if not varset.strip(): continue
                if '{{' in varset:
                    keyvar, lvars, ftype = parseLoopArgs(varset)
                    if akey not in loopVars: loopVars[akey] = {}
                    varlist.append(keyvar)
                    loopVars[akey][keyvar] = [keyvar, lvars]
                    if akey == 'nsize':
                        inDict[akey] = '${' + keyvar + '}'
                        lsuffix += akey + '-' + inDict[akey] + '_'
                    else:
                        inDict[akey] += ' -' + keyvar + ' ${' + keyvar + '}'
                        lsuffix += keyvar + '-${' + keyvar + '}_'
                else:
                    if key == 'args': newargs += " -" + varset.strip()
                if varlist: loopVars[akey]['varlist'] = varlist

        # For subtests, args are always substituted in (not top level)
        if isSubtest:
            inDict['subargs'] += " " + newargs.strip()
            inDict['args'] = ''
            if 'label_suffix' in inDict:
                inDict['label_suffix'] += lsuffix.rstrip('_')
            else:
                inDict['label_suffix'] = lsuffix.rstrip('_')
        else:
            if loopVars.keys():
                inDict['args'] = newargs.strip()
                inDict['label_suffix'] = lsuffix.rstrip('_')
        if loopVars.keys():
            return loopVars
        else:
            return None