| Pyry Haulos | c15aafb | 2015-01-07 11:50:55 -0800 | [diff] [blame] | 1 | # -*- coding: utf-8 -*- | 
 | 2 |  | 
| Pyry Haulos | 484aa20 | 2015-04-02 11:08:39 -0700 | [diff] [blame] | 3 | #------------------------------------------------------------------------- | 
 | 4 | # drawElements Quality Program utilities | 
 | 5 | # -------------------------------------- | 
 | 6 | # | 
 | 7 | # Copyright 2015 The Android Open Source Project | 
 | 8 | # | 
 | 9 | # Licensed under the Apache License, Version 2.0 (the "License"); | 
 | 10 | # you may not use this file except in compliance with the License. | 
 | 11 | # You may obtain a copy of the License at | 
 | 12 | # | 
 | 13 | #      http://www.apache.org/licenses/LICENSE-2.0 | 
 | 14 | # | 
 | 15 | # Unless required by applicable law or agreed to in writing, software | 
 | 16 | # distributed under the License is distributed on an "AS IS" BASIS, | 
 | 17 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 
 | 18 | # See the License for the specific language governing permissions and | 
 | 19 | # limitations under the License. | 
 | 20 | # | 
 | 21 | #------------------------------------------------------------------------- | 
 | 22 |  | 
| Pyry Haulos | c15aafb | 2015-01-07 11:50:55 -0800 | [diff] [blame] | 23 | from build.common import * | 
 | 24 | from build.config import * | 
 | 25 | from build.build import * | 
 | 26 |  | 
 | 27 | import os | 
 | 28 | import sys | 
 | 29 | import string | 
 | 30 | import argparse | 
 | 31 | import tempfile | 
 | 32 | import shutil | 
 | 33 |  | 
 | 34 | class Module: | 
 | 35 | 	def __init__ (self, name, dirName, binName): | 
 | 36 | 		self.name		= name | 
 | 37 | 		self.dirName	= dirName | 
 | 38 | 		self.binName	= binName | 
 | 39 |  | 
 | 40 | MODULES = [ | 
| Pyry Haulos | 846cc3c | 2015-06-29 14:28:58 -0700 | [diff] [blame] | 41 | 	Module("dE-IT",			"internal",								"de-internal-tests"), | 
 | 42 | 	Module("dEQP-EGL",		"egl",									"deqp-egl"), | 
 | 43 | 	Module("dEQP-GLES2",	"gles2",								"deqp-gles2"), | 
 | 44 | 	Module("dEQP-GLES3",	"gles3",								"deqp-gles3"), | 
 | 45 | 	Module("dEQP-GLES31",	"gles31",								"deqp-gles31"), | 
 | 46 | 	Module("dEQP-VK",		"../external/vulkancts/modules/vulkan",	"deqp-vk"), | 
| Pyry Haulos | c15aafb | 2015-01-07 11:50:55 -0800 | [diff] [blame] | 47 | ] | 
 | 48 |  | 
 | 49 | DEFAULT_BUILD_DIR	= os.path.join(tempfile.gettempdir(), "deqp-caselists", "{targetName}-{buildType}") | 
 | 50 | DEFAULT_TARGET		= "null" | 
 | 51 |  | 
 | 52 | def getModuleByName (name): | 
 | 53 | 	for module in MODULES: | 
 | 54 | 		if module.name == name: | 
 | 55 | 			return module | 
 | 56 | 	else: | 
 | 57 | 		raise Exception("Unknown module %s" % name) | 
 | 58 |  | 
 | 59 | def getBuildConfig (buildPathPtrn, targetName, buildType): | 
 | 60 | 	buildPath = buildPathPtrn.format( | 
 | 61 | 		targetName	= targetName, | 
 | 62 | 		buildType	= buildType) | 
 | 63 |  | 
 | 64 | 	return BuildConfig(buildPath, buildType, ["-DDEQP_TARGET=%s" % targetName]) | 
 | 65 |  | 
 | 66 | def getModulesPath (buildCfg): | 
 | 67 | 	return os.path.join(buildCfg.getBuildDir(), "modules") | 
 | 68 |  | 
 | 69 | def getBuiltModules (buildCfg): | 
 | 70 | 	modules		= [] | 
 | 71 | 	modulesDir	= getModulesPath(buildCfg) | 
| Pyry Haulos | c15aafb | 2015-01-07 11:50:55 -0800 | [diff] [blame] | 72 |  | 
| Pyry Haulos | 3eedc58 | 2015-08-04 12:46:55 -0700 | [diff] [blame] | 73 | 	for module in MODULES: | 
 | 74 | 		fullPath = os.path.join(modulesDir, module.dirName) | 
 | 75 | 		if os.path.exists(fullPath) and os.path.isdir(fullPath): | 
 | 76 | 			modules.append(module) | 
| Pyry Haulos | c15aafb | 2015-01-07 11:50:55 -0800 | [diff] [blame] | 77 |  | 
 | 78 | 	return modules | 
 | 79 |  | 
| Pyry Haulos | 484aa20 | 2015-04-02 11:08:39 -0700 | [diff] [blame] | 80 | def getCaseListFileName (module, caseListType): | 
 | 81 | 	return "%s-cases.%s" % (module.name, caseListType) | 
| Pyry Haulos | c15aafb | 2015-01-07 11:50:55 -0800 | [diff] [blame] | 82 |  | 
| Pyry Haulos | 484aa20 | 2015-04-02 11:08:39 -0700 | [diff] [blame] | 83 | def getCaseListPath (buildCfg, module, caseListType): | 
 | 84 | 	return os.path.join(getModulesPath(buildCfg), module.dirName, getCaseListFileName(module, caseListType)) | 
 | 85 |  | 
 | 86 | def genCaseList (buildCfg, generator, module, caseListType): | 
| Pyry Haulos | c15aafb | 2015-01-07 11:50:55 -0800 | [diff] [blame] | 87 | 	workDir = os.path.join(getModulesPath(buildCfg), module.dirName) | 
 | 88 |  | 
 | 89 | 	pushWorkingDir(workDir) | 
 | 90 |  | 
 | 91 | 	try: | 
 | 92 | 		binPath = generator.getBinaryPath(buildCfg.getBuildType(), os.path.join(".", module.binName)) | 
| Pyry Haulos | 484aa20 | 2015-04-02 11:08:39 -0700 | [diff] [blame] | 93 | 		execute([binPath, "--deqp-runmode=%s-caselist" % caseListType]) | 
| Pyry Haulos | c15aafb | 2015-01-07 11:50:55 -0800 | [diff] [blame] | 94 | 	finally: | 
 | 95 | 		popWorkingDir() | 
 | 96 |  | 
| Pyry Haulos | 484aa20 | 2015-04-02 11:08:39 -0700 | [diff] [blame] | 97 | def genAndCopyCaseList (buildCfg, generator, module, dstDir, caseListType): | 
 | 98 | 	caseListFile	= getCaseListFileName(module, caseListType) | 
 | 99 | 	srcPath			= getCaseListPath(buildCfg, module, caseListType) | 
| Pyry Haulos | c15aafb | 2015-01-07 11:50:55 -0800 | [diff] [blame] | 100 | 	dstPath			= os.path.join(dstDir, caseListFile) | 
 | 101 |  | 
 | 102 | 	if os.path.exists(srcPath): | 
 | 103 | 		os.remove(srcPath) | 
 | 104 |  | 
| Pyry Haulos | 484aa20 | 2015-04-02 11:08:39 -0700 | [diff] [blame] | 105 | 	genCaseList(buildCfg, generator, module, caseListType) | 
| Pyry Haulos | c15aafb | 2015-01-07 11:50:55 -0800 | [diff] [blame] | 106 |  | 
 | 107 | 	if not os.path.exists(srcPath): | 
 | 108 | 		raise Exception("%s not generated" % srcPath) | 
 | 109 |  | 
 | 110 | 	shutil.copyfile(srcPath, dstPath) | 
 | 111 |  | 
 | 112 | def parseArgs (): | 
 | 113 | 	parser = argparse.ArgumentParser(description = "Build test case lists", | 
 | 114 | 									 formatter_class=argparse.ArgumentDefaultsHelpFormatter) | 
 | 115 | 	parser.add_argument("-b", | 
 | 116 | 						"--build-dir", | 
 | 117 | 						dest="buildDir", | 
 | 118 | 						default=DEFAULT_BUILD_DIR, | 
 | 119 | 						help="Temporary build directory") | 
 | 120 | 	parser.add_argument("-t", | 
 | 121 | 						"--build-type", | 
 | 122 | 						dest="buildType", | 
 | 123 | 						default="Debug", | 
 | 124 | 						help="Build type") | 
 | 125 | 	parser.add_argument("-c", | 
 | 126 | 						"--deqp-target", | 
 | 127 | 						dest="targetName", | 
 | 128 | 						default=DEFAULT_TARGET, | 
 | 129 | 						help="dEQP build target") | 
| Pyry Haulos | 484aa20 | 2015-04-02 11:08:39 -0700 | [diff] [blame] | 130 | 	parser.add_argument("--case-list-type", | 
 | 131 | 						dest="caseListType", | 
 | 132 | 						default="xml", | 
 | 133 | 						help="Case list type (xml, txt)") | 
| Pyry Haulos | c15aafb | 2015-01-07 11:50:55 -0800 | [diff] [blame] | 134 | 	parser.add_argument("-m", | 
 | 135 | 						"--modules", | 
 | 136 | 						dest="modules", | 
 | 137 | 						help="Comma-separated list of modules to update") | 
 | 138 | 	parser.add_argument("dst", | 
 | 139 | 						help="Destination directory for test case lists") | 
 | 140 | 	return parser.parse_args() | 
 | 141 |  | 
 | 142 | if __name__ == "__main__": | 
 | 143 | 	args = parseArgs() | 
 | 144 |  | 
 | 145 | 	generator	= ANY_GENERATOR | 
 | 146 | 	buildCfg	= getBuildConfig(args.buildDir, args.targetName, args.buildType) | 
 | 147 | 	modules		= None | 
 | 148 |  | 
 | 149 | 	if args.modules: | 
 | 150 | 		modules = [] | 
 | 151 | 		for m in args.modules.split(","): | 
 | 152 | 			modules.append(getModuleByName(m)) | 
 | 153 |  | 
 | 154 | 	if modules: | 
 | 155 | 		build(buildCfg, generator, [m.binName for m in modules]) | 
 | 156 | 	else: | 
 | 157 | 		build(buildCfg, generator) | 
 | 158 | 		modules = getBuiltModules(buildCfg) | 
 | 159 |  | 
 | 160 | 	for module in modules: | 
 | 161 | 		print "Generating test case list for %s" % module.name | 
| Pyry Haulos | 484aa20 | 2015-04-02 11:08:39 -0700 | [diff] [blame] | 162 | 		genAndCopyCaseList(buildCfg, generator, module, args.dst, args.caseListType) |