Exemple #1
0
	def run_list(self, command_list):
		RuntimeStates.reset_states()
		self.setup()
		self.cmdgen.setup()
		for command in command_list:
			cn, call, retval, symb_args, symb_kws = command
			if not self.cmdgen.test_call(call):
				return UNDEF
			# all symbolic args need to rebuild
			for sa in symb_args:
				if isinstance(sa, Symbol):
					sa.next_run()
			# now build current args
			args, kws = call.caller.get_args(symb_args, symb_kws) # build args
			try:
				call.check_preconditions(args, kws)
			except PreConditionNotMet:
				return UNDEF
			try:
				retval = call.wrapped(iargs=args, ikws=kws, record=False)
			except GeneratorMessage as e:
				try:
					self.cmdgen.check_exception(e)
				except:
					return FAIL
			except TestFailed as e:
				return FAIL
		return OK
Exemple #2
0
	def run(self):
		for prop in self.props:
			RuntimeStates.reset_states()
			try:
				prop.test(config.NUM_CALLS, config.MAX_TRIES)
			except TestFailed as e:
				print("Error: %s" % (e.message,))
				length = len(prop.command_list)
				print("after %d calls" % (length,))
				if config.PRINT_UNSHRINKED:
					print("(name, caller, retval, args, kws)")
					for l in prop.command_list:
						print(str(l))
				print("Shrinking...")
				shrunk_case = self.shrink(prop)
				if len(shrunk_case)<length:
					print("shrunk testcase from %d to %d" % (length, len(shrunk_case)))
					for l in shrunk_case:
						print("\t%s" %(str(l),))
				else:
					print("no smaller testcase found")

		if config.PRINT_STATS:
			self.print_stats()