コード例 #1
0
ファイル: qatest.py プロジェクト: pruan/TestDepot
	def run_tests(self):
		#for test, testargs, testkwargs in self._tests:
		for i, entry in enumerate(self._tests):
			if not self.check_prerequisites(entry, i):
				continue
			try:
				self.config.logfile.note("%s: %r" % (timelib.localtimestamp(), entry))
				rv = entry()
			except KeyboardInterrupt:
				self.info("Test suite aborted by user.")
				if self._nested:
					raise TestSuiteAbort, "aborted by user"
				else:
					break
			except TestSuiteAbort, err:
				self.info("Suite aborted by test %s (%s)." % (entry.name(), err))
				rv = ABORT
			# this should only happen with incorrectly written test_method().
			if rv is None:
				self.report.diagnostic("warning: test returned None, assuming failed. Please fix the %s.test_method()" % (entry.name()))
				rv = FAILED
			# keep return value in results
			# check for abort condition and abort if so
			if rv == ABORT:
				break
コード例 #2
0
ファイル: trapreceiver.py プロジェクト: pruan/TestDepot
def _handler(ip, community, pdu):
	global trap
	trap = pdu
	print "%s: from %s with ID %s for %s:" % (localtimestamp("%b %d %H:%M:%S"), ip, pdu.request_id, community)
	print pdu.varbinds[0] # uptime
	trapoid = pdu.varbinds[1]
	print "%s (%s)" % (trapoid, trapoid.value.get_object().__name__)
	for vb in pdu.varbinds[2:]:
		print vb
	print
コード例 #3
0
ファイル: stratatest.py プロジェクト: pruan/TestDepot
	def run_tests(self):
        self.config.rv_dict = {}
		for i, entry in enumerate(self._tests):
			if not self.check_prerequisites(entry, i):
				continue
			try:
				self.config.logfile.note("%s: %r" % (timelib.localtimestamp(), entry))
                rv = entry()
			except KeyboardInterrupt:
				self.info("Test suite aborted by user.")
				if self._nested:
					raise TestSuiteAbort, "aborted by user"
				else:
					break
コード例 #4
0
ファイル: stratatestrunner.py プロジェクト: pruan/TestDepot
                    uut = self.get_uut(rpt)
                    self.print_uut_rpt(uut, rpt)
                    try:
                        uut.close()
                        print "closing serial session..."
                        time.sleep(2)
                    except:
                        pass

                ok_to_run = self.check_run_permission(cf.serno, self.test_name)
                if ok_to_run:
                    suite()  # just run instance of the suite
                else:
                    raise TestSuiteAbort, "You can not run this test again with your current user profile"

            rpt.add_message("MODULEEND", timelib.localtimestamp())
            rpt.finalize()

            # lastly, run the module-level finalize function.
            if hasattr(mod, "finalize") and callable(mod.finalize):
                if cf.flags.DEBUG:
                    try:
                        mod.finalize(cf)
                    except:
                        ex, val, tb = sys.exc_info()
                        import debugger
                        debugger.post_mortem(ex, val, tb)
                else:
                    mod.finalize(cf)
            # release the testbed resources
            del cf.testbed # also resets controllers
コード例 #5
0
ファイル: testrunner.py プロジェクト: pruan/TestDepot
	def run_module(self, mod):
		"""run_module(module)
	Runs the module. The parameter should be a module object, but if it is a
	string then a module object with that name will be imported. 
	"""
		cf = self._config
		if type(mod) is str:
			mod = self.get_module(mod)
		if mod:
			try:
				cf.module_ID = mod._ID
			except AttributeError:
				cf.module_ID = "<unknown>"
			cf.reportbasename = mod.__name__.replace(".", "_")
			cf.logbasename = "%s.log" % (cf.reportbasename,)
			# merge any test-module specific config files.
			testconf = os.path.join(os.path.dirname(mod.__file__) , "%s.conf" % (mod.__name__.split(".")[-1],))
			cf.mergefile(testconf)
			# resultsdir is where you would place any resulting data files.
			starttime = timelib.now()
			cf.resultsdir = os.path.join(
					cf.get("resultsdirbase", os.environ["HOME"]),
					"%s-%s" % (cf.reportbasename, timelib.strftime("%Y%m%d%H%M", timelib.localtime(starttime)))
			)
			# make collection dir 
			try:
				os.mkdir(cf.resultsdir)
			except OSError, errno:
				if errno[0] == EEXIST:
					pass
				else:
					raise
			# firstly, run the module-level initialize function.
			if hasattr(mod, "initialize") and callable(mod.initialize):
				if cf.flags.DEBUG:
					try:
						mod.initialize(cf)
					except:
						ex, val, tb = sys.exc_info()
						import debugger
						debugger.post_mortem(ex, val, tb)
				else:
					mod.initialize(cf)

			rpt = cf.get_report()
			cf.reportfilenames = rpt.filenames # Report file's names. save for future use.
			rpt.initialize()
			rpt.logfile(cf.logfilename)
			rpt.add_title("Test Results for module %r." % (mod.__name__, ))
			rpt.add_message("ARGUMENTS", " ".join(cf.arguments))
			note = self.get_note()
			if note:
				rpt.add_message("NOTE", note)
				self._config.comment = note
			else:
				self._config.comment = "<none>"
			self._reporturl(rpt)
			rpt.add_message("MODULESTART", timelib.strftime("%a, %d %b %Y %H:%M:%S %Z", timelib.localtime(starttime)))
			mod.run(cf) # run the test!
			rpt.add_message("MODULEEND", timelib.localtimestamp())
			rpt.finalize()
			# force close of report and logfile between modules
			cf.logfile.flush()
			del cf.report ; del cf.logfile 

			# lastly, run the module-level finalize function.
			if hasattr(mod, "finalize") and callable(mod.finalize):
				if cf.flags.DEBUG:
					try:
						mod.finalize(cf)
					except:
						ex, val, tb = sys.exc_info()
						import debugger
						debugger.post_mortem(ex, val, tb)
				else:
					mod.finalize(cf)