Пример #1
0
def buildTest(test, path):
	os.chdir(path)
	result = doCommand("/usr/bin/make",test)
	if result['status'] != 0:
		print "Failed to Build %s" % test
		print "**STDOUT**\n%s" % result['stdout']
		print "**STDERR**\n%s" % result['stderr']
		raise StandardError
	log_note("Built %s successfully" % test)
Пример #2
0
def executeTest(testObject,path):
	os.chdir(path)
	test = testObject.getName()
	executable_path = os.path.join(path, test)
	print "[TEST] %s" % test
	print "[BEGIN] %s" % test
	try:
		result = runSimpleProcess(executable_path,testName()+"_"+test, wait_time=120)
		testObject.exitValue = result['status']
		if result['status'] == 0:
			print "[PASS] %s returned %d" % (test,result['status'])
	except:
		print "[FAIL] %s returned %d" % (test, result['status'])
		testObject.comments = "Failed due to timeout or file not found error"
	log_note("Completed running test %s" % test)
Пример #3
0
def runTest(params):
	# Change to /tmp, because make doesn't support directory paths with spaces
	os.chdir("/private/tmp")	
	output= {'status': 1 }
	try:
		output = svnCheckoutTestTool("unit_tests")
	except:
		pass
	if output['status'] != 0 :
		# since we are not fully published yet. lets get data from a branch
		print "Fetching unit_test roots from Branch instead of trunk"
		baseURL = "http://src.apple.com/svn/xnu/branches/PR-10938974/tools/tests/unit_tests/"
		output = svnCheckoutToPath(baseURL)
		if output['status'] != 0 : 
			logFail("[FAIL] error in checkout from branch")
			sys.exit(1)
		
	local_path = os.path.join(os.getcwd(), "unit_tests")
	makefile_path = os.path.join(local_path, "Makefile")
	build_path = os.path.join(local_path, "BUILD")
	
	
	tests_to_run = getTestsFromMakeFile(makefile_path)
	log_note("Starting raft tests for XNU")
	stats = {"total":len(tests_to_run) , "pass":0, "fail":0}
	for testObject in tests_to_run:
		test = testObject.getName()
		if test == "clean":
			stats["pass"]+=1
			testObject.buildStatus = True
			testObject.executeStatus = True
			testObject.exitValue = 0
			continue

		log_note("Running test :%s" % test)
		try:
			buildTest(test,local_path)
			testObject.buildStatus = True
			res = executeTest(testObject,build_path)
			testObject.executeStatus = True
			if testObject.exitValue == 0 :
				stats["pass"]+=1
			else:
				stats["fail"]+=1
			removeTestExecutable(test,build_path)
			logPass(test)
		except: 
			logFail("[FAIL] %s failed." % test)
	print "Finished running tests. Cleaning up"
	doCommand("/usr/bin/make","clean")
	#Now to print the Summary and statistics
	print "\n\n Test Summary \n"
	print xnuTest.getSummaryHeader()
	for testObject in tests_to_run:
		print testObject.getSummary()
	print "\n===============================\n"
	print "[SUMMARY]"
	print "Total tests: %d" % stats["total"]
	print "Passed     : %d" % stats["pass"]
	print "Failed     : %d" % stats["fail"]
	print "================================\n\n"

	logPass() # This line is implicit and can be removed