Example #1
0
	def initialize(self):
		super().initialize()
		try:
			self.command = command.Command(self.path)
			self.version = "Currently not supported";
			self.arch = "Currently not supported";
			testr.writeln("Target renjin initialized:")
		except IOError:
			testr.fatalError("Target path {0} not found!".format(self.path))
Example #2
0
	def initialize(self, targets):
		testr.writeln("  initializing module test")
		if (not targets):
			testr.fatalError("module test must have at least one target specified")
		self.count = 0
		self.passed = [0] * len(targets)
		self.failed = [0] * len(targets)
		self.execFailed = [0] * len(targets)
		self.skipped = [0] * len(targets)
		self._targets = targets
		self._tlocal = Module.TL()
		self._longestTargetName = max([ len(i.name()) for i in targets])
Example #3
0
	def initialize(self, targets):
		testr.writeln("  initializing module timer")
		if (not targets):
			testr.fatalError("module timer must have at least one target specified")
		self.count = 0
		self._targets = targets
		self._tlocal = Module.TL()
		self._longestTargetName = max([ len(i.name()) for i in targets])
		self.write(testr.truncIfLonger("test name",70))
		for t in targets:
			self.write(" | {0:17}".format(t.name()))
		self.writeln("")
		self.writeln("-" * (70 + len(targets) * 20))
Example #4
0
	def doParseArgument(self, name, value):
		""" Analyzes the given argument specified by its name and value. This method should return True if the argument is recognized and the value is correct, and should return False if the argument is not recognized and should call the testr.fatalError function if the argument is recognized, but the value is not recognized.
	   
		Override this method while calling the inherited one to provide new functionality. 
	    """
		if (name in ("outputFile", "of")):
			if (self.outputFile != None):
				testr.fatalError("Output file for module {0} can only be specified once.".format(self.name()))
			try:
				self.outputFile = open(value,"w")
			except IOError:
				testr.fatalError("Unable to open output file {0} for write access.".format(value))
		else:
			return False
		return True
Example #5
0
	def initialize(self):
		super().initialize()
		try:
			self.command = command.Command(self.path)
			v = self.command.run(args= self._arguments() + ("--version",))
			print(v[1])
			v = v[1].split("\n") if command._isWindows else v[0].split("\n")
			self.version = v[0].strip().split(" ")[2]
			if (self.version[0] == "3"):
				self.arch = v[2].strip().split(" ")[1]
			else:
				self.arch = v[3].strip().split(" ")[1]
			testr.writeln("Target R initialized:")
			testr.writeln("  arch:    {0}".format(self.arch))
			testr.writeln("  version: {0}".format(self.version))
			testr.writeln("  path:    {0}".format(self.path))  
		except IOError:
			testr.fatalError("Target path {0} not found!".format(self.path))
Example #6
0
	def __init__(self, args):
		""" Initializes the test suite from the arguments parsed. """
		self.recursive = None # none so that we can check that it was specified only once
		self.roots = []
		self.whitelist = []
		self.blacklist = []
		i = 0
		testr.writeln("parsing arguments for the testsuite")
		while (i < len(args)):
			argName, argValue = args[i]
			if (argName in ("suite","s")):
				if (not os.path.exists(argValue)):
					testr.fatalError("test suite root directory {0} not found".format(argValue))
				testr.writeln("  suite {0} added".format(argValue))
				self.roots.append((argValue, argValue))
			elif (argName in ("recursive","r")):
				if (self.recursive != None):
					testr.fatalError("argument recursive, or r can be used only once")
				if (argValue not in (True, False)):
					testr.fatalError("only True, False, or empty value are allowed for argument {0}".format(argName))
				if (argValue):
					testr.writeln("  test suite will be scanned recursively")
				else:
					testr.writeln("  test suite will not be scanned recursively. Only suite roots will be analyzed for test files") 
				self.recursive = argValue
			elif (argName in ("whitelist", "wl")):
				if (self.blacklist):
					testr.fatalError("whitelist cannot be specified together with blacklist")
				self.whitelist += [ item.strip() for item in argValue.split(",")]
				testr.writeln("  whitelist is now {0}".format(",".join(self.whitelist)))
			elif (argName in ("blacklist", "bl")):
				if (self.whitelist):
					testr.fatalError("blacklist cannot be specified together with whitelist")
				self.blacklist += [ item.strip() for item in argValue.split(",")]
				testr.writeln("  blacklist is now {0}".format(",".join(self.blacklist)))
			else:
				i += 1
				continue
			args.pop(i)
		if (self.recursive == None): # if recursive was not set set it to its default value
			self.recursive = True
		self._lock = threading.Lock()
		self._i = self._ennumerate()
Example #7
0
	def initialize(self):
		super().initialize()
		try:
			self.command = command.Command(self.path)
			self.version = "Currently not supported";
			self.arch = "Currently not supported";
			#v = self.command.run(args= self.cmdArguments)
			#v = v[1].split("\n") if command._isWindows else v[0].split("\n")
			#self.LAPACK = v[0].split(" ")[2].strip()
			#self.BLAS = v[1].split(" ")[2].strip()
			#self.GNUR = v[2].split(" ")[2].strip()
			testr.writeln("Target fastr initialized:")
			testr.writeln("  arch:    {0}".format(self.arch))
			testr.writeln("  version: {0}".format(self.version))
			testr.writeln("  path:    {0}".format(self.path))  
			#testr.writeln("  LAPACK: {0}".format(self.LAPACK))
			#testr.writeln("  BLAS:   {0}".format(self.BLAS))
			#testr.writeln("  GNUR:   {0}".format(self.GNUR))  
		except IOError:
			testr.fatalError("Target path {0} not found!".format(self.path))
Example #8
0
	def initialize(self, targets):
		testr.writeln("  initializing module counter")
		if (targets):
			testr.fatalError("  module counter can only be used with no targets")
		self.count = 0
Example #9
0
	def defaultPath(self):
		""" Returns the default path of the target, which will be used if no other path is specified. This method must be overriden in subclasses of specific targets. """
		testr.fatalError("Target.defaultPath() must be overriden for specific targets")
Example #10
0
	def exec(self, test):
		""" Runs the given test on the target and returns an ExecResult object.
	   
		Override this method to provide the target functionality. 
	    """
		testr.fatalError("exec() method must be overriden in target {0}".format(self.name()))
Example #11
0
	def analyze(self, test, execResult):
		target = execResult.target
		# if it is a new test, increase the count of the tests
		if (test != self._tlocal.lastTest):
			with (self._lock):
				self.count += 1
			self._tlocal.lastTest = test
			self._tlocal.tidx = -1
		self._tlocal.tidx += 1
		if (self._targets[self._tlocal.tidx] != target):
			self._tlocal.tidx = 0
			while (self._targets[self._tlocal.tidx] != target):
				self._tlocal.tidx += 1
		# run the preconditions - if they fail, the test is marked as skipped
		for cmd in test.preRunCommands():
			msg = eval(cmd)
			if (msg):
				with (self._lock):
					self.skipped[self._tlocal.tidx] += 1
					self.writeln("SKIPPED Test {0} from file {1} skipped for target {2}:".format(test.name(), test.filename(), target.name()))
					self.writeln("  {0}".format(msg))
					self.markAsSkip(test)
					return
		if (execResult.stderr.find("at r.")!=-1):
			execResult.result = "NOT IMPLEMENTED YET"
		if (execResult.stderr.find("at org.renjin.")!=-1):
			execResult.result = "NOT IMPLEMENTED YET"
		# check that the execution was a success
		if (execResult.result != ExecResult.PASS):
			with (self._lock):
				self.execFailed[self._tlocal.tidx] += 1
				self.writeln("FAILED  Test {0} from file {1} failed to execute for target {2}:".format(test.name(), test.filename(), target.name()), force = self._failAfterError)
				if (execResult.returnCode == ExecResult.TIMEOUT):
					self.writeln("  TIMEOUT", force = self._failAfterError)
				else:
					self.writeln("  {0}".format(execResult.result), force = self._failAfterError)
				if (self._failAfterError):
					testr.fatalError("Terminating after a test error.")
				self.markAsExecFail(test)
				return
		# check that the execution code is a success or a stderr or stdout are present
		output = execResult.stdout
		error = execResult.stderr
		if ((execResult.returnCode != Command.SUCCESS) and not output and not error):
			with (self._lock):
				self.failed[self._tlocal.tidx] += 1
				self.writeln("FAILED  Test {0} from file {1} failed to execute for target {2}:".format(test.name(), test.filename(), target.name()), force = self._failAfterError)
				if (execResult.returnCode == ExecResult.TIMEOUT):
					self.writeln("  TIMEOUT", force = self._failAfterError)
				else:
					self.writeln("  return code is {0} and no output or error given".format(execResult.returnCode), force = self._failAfterError)
				if (self._failAfterError):
					testr.fatalError("Terminating after a test error.")
				self.markAsFail(test)
				return
		# run the post condition checks
		for cmd in test.postRunCommands():
			msg = eval(cmd)
			if (msg):
				with (self._lock):
					self.failed[self._tlocal.tidx] += 1
					self.writeln("-------------------------------------------------------------------------------------------------", force = self._failAfterError)
					self.writeln("FAILED  Test {0} from file {1} failed to execute for target {2}:".format(test.name(), test.filename(), target.name()), force = self._failAfterError)
					self.writeln("  " + "\n  ".join([ i.rstrip() for i in msg.split("\n")]), force = self._failAfterError)
					self.writeln("  Output:", force = self._failAfterError)
					self.writeln("    " + "\n    ".join([ i.rstrip() for i in output.split("\n")]), force = self._failAfterError)
					self.writeln("  Error:", force = self._failAfterError)
					self.writeln("    " + "\n    ".join([ i.rstrip() for i in error.split("\n")]), force = self._failAfterError)
					if (self._showCodeOnError):
						self.writeln("  Code:", force = self._failAfterError)
						self.writeln("    " + "\n    ".join([i.rstrip() for i in test.code().split("\n")]), force = self._failAfterError)
					self.writeln("-------------------------------------------------------------------------------------------------", force = self._failAfterError)
					if (self._failAfterError):
						testr.fatalError("Terminating after a test error.")
					self.markAsFail(test)
					return
		# all done ok, write as success
		with (self._lock):
			self.passed[self._tlocal.tidx] += 1
			if (not self._showOnlyErrors):
				self.writeln("PASSED  Test {0} from file {1} passed for target {2}".format(test.name(), test.filename(), target.name()))
			self.markAsPass(test)