def commands_for(self, batch, settings=None): if 'commands' not in batch: return [] cmdnames = [i.strip() for i in token_split(batch['commands'])] commands = OrderedDict() while cmdnames: c = cmdnames.pop(0) if not c or c in commands: continue if c not in self.commands: raise RuntimeError("Can't find command '%s' when expanding " "batch command." % c) cmd = self.apply_args(self.commands[c], batch, settings) # Don't include disabled commands if cmd.get('disabled', False) or not cmd.get('enabled', True): continue # Commands can specify extra commands to run; expand those, use the # dictionary to prevent duplicates extra = [ i.strip() for i in token_split(cmd.get('extra_commands', '')) if i.strip() ] for e in reversed(extra): cmdnames.insert(0, e) commands[c] = cmd return commands.values()
def commands_for(self, batch, settings=None): if 'commands' not in batch: return [] cmdnames = [i.strip() for i in token_split(batch['commands'])] commands = OrderedDict() while cmdnames: c = cmdnames.pop(0) if not c or c in commands: continue if c not in self.commands: raise RuntimeError("Can't find command '%s' when expanding " "batch command." % c) cmd = self.apply_args(self.commands[c], batch, settings) # Don't include disabled commands if cmd.get('disabled', False) or not cmd.get('enabled', True): continue # Commands can specify extra commands to run; expand those, use the # dictionary to prevent duplicates extra = [i.strip() for i in token_split(cmd.get('extra_commands', '')) if i.strip()] for e in reversed(extra): cmdnames.insert(0, e) commands[c] = cmd return commands.values()
def parse_rcvalues(self, items): vals = {} for k, v in items: k = k.upper() t = parser.get_type(k) if t == bool: if type(v) == bool: vals[k] = v elif v.lower() in ('1', 'yes', 'true', 'on'): vals[k] = True elif v.lower() in ('0', 'no', 'false', 'off'): vals[k] = False else: raise ValueError("Not a boolean: %s" % v) continue elif t: val = t(v) c = parser.get_choices(k) if c and val not in c: logger.warning("Invalid RC value '%s' for key %s. Ignoring", val, k) continue if isinstance(val, dict) and k in vals: vals[k].update(val) elif parser.is_list(k): vals[k] = [t(i.strip()) for i in token_split(v)] else: vals[k] = val return vals
def get_test_parameter(self, name, default=_no_default, split=False): try: ret = self.env['TEST_PARAMETERS'][name] if split: ret = token_split(ret) return ret except KeyError: if default is not _no_default: return default if self.informational: return None raise RuntimeError("Missing required test parameter: %s" % name)
def get_test_parameter(self, name, default=_no_default, split=False, cast=None): try: ret = self.env['TEST_PARAMETERS'][name] if split: ret = token_split(ret) if cast: ret = list(map(cast, ret)) elif cast: ret = cast(ret) return ret except KeyError: if default is not _no_default: return default if self.informational: return None raise RuntimeError("Missing required test parameter: %s" % name)
def get_argsets(self, batch): argsets = [] for k in batch.keys(): if k.startswith("for_"): argset = [] for a in token_split(batch[k]): a = a.strip().lower() matches = [arg for arg in self.args if fnmatch(arg, a)] if not matches: raise RuntimeError("No matches for arg: '%s'." % a) argset.extend(matches) argsets.append(argset) reps = range(1, int(batch.get('repetitions', 1)) + 1) argsets.append(reps) return argsets
def get_test_parameter(self, name, default=_no_default, split=False, cast=None): try: ret = self.env['TEST_PARAMETERS'][name] if split: ret = token_split(ret) if cast: ret = list(map(cast, ret)) elif cast: ret = cast(ret) return ret except KeyError: if name in GLOBAL_TEST_PARAMS_MAP: ret = self.env[GLOBAL_TEST_PARAMS_MAP[name]] if ret: return ret if default is not _no_default: return default if self.informational: return None raise RuntimeError("Missing required test parameter: %s" % name)