1 # -*- coding: utf-8 -*-
3 #-------------------------------------------------------------------------
4 # drawElements Quality Program utilities
5 # --------------------------------------
7 # Copyright 2015 The Android Open Source Project
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
13 # http://www.apache.org/licenses/LICENSE-2.0
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.
21 #-------------------------------------------------------------------------
23 from build.common import *
24 from build.config import *
25 from build.build import *
35 def __init__ (self, name, dirName, binName):
37 self.dirName = dirName
38 self.binName = binName
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"),
48 DEFAULT_BUILD_DIR = os.path.join(tempfile.gettempdir(), "deqp-caselists", "{targetName}-{buildType}")
49 DEFAULT_TARGET = "null"
51 def getModuleByName (name):
52 for module in MODULES:
53 if module.name == name:
56 raise Exception("Unknown module %s" % name)
58 def getBuildConfig (buildPathPtrn, targetName, buildType):
59 buildPath = buildPathPtrn.format(
60 targetName = targetName,
61 buildType = buildType)
63 return BuildConfig(buildPath, buildType, ["-DDEQP_TARGET=%s" % targetName])
65 def getModulesPath (buildCfg):
66 return os.path.join(buildCfg.getBuildDir(), "modules")
68 def getBuiltModules (buildCfg):
70 modulesDir = getModulesPath(buildCfg)
72 for module in MODULES:
73 fullPath = os.path.join(modulesDir, module.dirName)
74 if os.path.exists(fullPath) and os.path.isdir(fullPath):
75 modules.append(module)
79 def getCaseListFileName (module, caseListType):
80 return "%s-cases.%s" % (module.name, caseListType)
82 def getCaseListPath (buildCfg, module, caseListType):
83 return os.path.join(getModulesPath(buildCfg), module.dirName, getCaseListFileName(module, caseListType))
85 def genCaseList (buildCfg, generator, module, caseListType):
86 workDir = os.path.join(getModulesPath(buildCfg), module.dirName)
88 pushWorkingDir(workDir)
91 binPath = generator.getBinaryPath(buildCfg.getBuildType(), os.path.join(".", module.binName))
92 execute([binPath, "--deqp-runmode=%s-caselist" % caseListType])
96 def genAndCopyCaseList (buildCfg, generator, module, dstDir, caseListType):
97 caseListFile = getCaseListFileName(module, caseListType)
98 srcPath = getCaseListPath(buildCfg, module, caseListType)
99 dstPath = os.path.join(dstDir, caseListFile)
101 if os.path.exists(srcPath):
104 genCaseList(buildCfg, generator, module, caseListType)
106 if not os.path.exists(srcPath):
107 raise Exception("%s not generated" % srcPath)
109 shutil.copyfile(srcPath, dstPath)
112 parser = argparse.ArgumentParser(description = "Build test case lists",
113 formatter_class=argparse.ArgumentDefaultsHelpFormatter)
114 parser.add_argument("-b",
117 default=DEFAULT_BUILD_DIR,
118 help="Temporary build directory")
119 parser.add_argument("-t",
124 parser.add_argument("-c",
127 default=DEFAULT_TARGET,
128 help="dEQP build target")
129 parser.add_argument("--case-list-type",
132 help="Case list type (xml, txt)")
133 parser.add_argument("-m",
136 help="Comma-separated list of modules to update")
137 parser.add_argument("dst",
138 help="Destination directory for test case lists")
139 return parser.parse_args()
141 if __name__ == "__main__":
144 generator = ANY_GENERATOR
145 buildCfg = getBuildConfig(args.buildDir, args.targetName, args.buildType)
150 for m in args.modules.split(","):
151 modules.append(getModuleByName(m))
154 build(buildCfg, generator, [m.binName for m in modules])
156 build(buildCfg, generator)
157 modules = getBuiltModules(buildCfg)
159 for module in modules:
160 print "Generating test case list for %s" % module.name
161 genAndCopyCaseList(buildCfg, generator, module, args.dst, args.caseListType)