def parseTimeExpression(timeExpression): # Starts with <, >, <=, >= ? if timeExpression == "": return "", 0 if timeExpression.startswith("<="): return "<=", plugins.getNumberOfSeconds(timeExpression[2:]) if timeExpression.startswith("<"): return "<", plugins.getNumberOfSeconds(timeExpression[1:]) if timeExpression.startswith(">="): return ">=", plugins.getNumberOfSeconds(timeExpression[2:]) if timeExpression.startswith(">"): return ">", plugins.getNumberOfSeconds(timeExpression[1:]) else: raise plugins.TextTestError, "Could not parse time expression '" + timeExpression + "' : all expressions must begin with '<' or '>'."
def forceOnPerformanceMachines(self): if self.optionMap.has_key("perf"): return 1 minTimeForce = plugins.getNumberOfSeconds(str(self.test.getConfigValue("min_time_for_performance_force"))) if minTimeForce >= 0 and getTestPerformance(self.test) > minTimeForce: return 1 # If we haven't got a log_file yet, we should do this so we collect performance reliably logFile = self.test.getFileName(self.test.getConfigValue("log_file")) return logFile is None
def __init__(self, timeLimit, *args): self.minTime = 0.0 self.maxTime = sys.maxint times = plugins.commasplit(timeLimit) if timeLimit.count("<") == 0 and timeLimit.count(">") == 0: # Backwards compatible if len(times) == 1: self.maxTime = plugins.getNumberOfSeconds(timeLimit) else: self.minTime = plugins.getNumberOfSeconds(times[0]) if len(times[1]): self.maxTime = plugins.getNumberOfSeconds(times[1]) else: for expression in times: parsedExpression = parseTimeExpression(expression) if parsedExpression[0] == "": continue elif parsedExpression[0] == "<": self.adjustMaxTime(parsedExpression[1] - 1) # We don't care about fractions of seconds ... elif parsedExpression[0] == "<=": self.adjustMaxTime(parsedExpression[1]) elif parsedExpression[0] == ">": self.adjustMinTime(parsedExpression[1] + 1) # We don't care about fractions of seconds ... else: self.adjustMinTime(parsedExpression[1])