1 # -*- coding: utf-8 -*-
3 from build.common import *
4 from build.config import *
5 from build.build import *
15 def __init__ (self, name, dirName, binName):
17 self.dirName = dirName
18 self.binName = binName
21 Module("dE-IT", "internal", "de-internal-tests"),
22 Module("dEQP-EGL", "egl", "deqp-egl"),
23 Module("dEQP-GLES2", "gles2", "deqp-gles2"),
24 Module("dEQP-GLES3", "gles3", "deqp-gles3"),
25 Module("dEQP-GLES31", "gles31", "deqp-gles31"),
28 DEFAULT_BUILD_DIR = os.path.join(tempfile.gettempdir(), "deqp-caselists", "{targetName}-{buildType}")
29 DEFAULT_TARGET = "null"
31 def getModuleByName (name):
32 for module in MODULES:
33 if module.name == name:
36 raise Exception("Unknown module %s" % name)
38 def getBuildConfig (buildPathPtrn, targetName, buildType):
39 buildPath = buildPathPtrn.format(
40 targetName = targetName,
41 buildType = buildType)
43 return BuildConfig(buildPath, buildType, ["-DDEQP_TARGET=%s" % targetName])
45 def getModulesPath (buildCfg):
46 return os.path.join(buildCfg.getBuildDir(), "modules")
48 def getBuiltModules (buildCfg):
50 modulesDir = getModulesPath(buildCfg)
51 modMap = {m.dirName: m for m in MODULES}
53 for entry in os.listdir(modulesDir):
54 fullPath = os.path.join(modulesDir, entry)
55 if os.path.isdir(fullPath) and entry in modMap:
56 modules.append(modMap[entry])
60 def getCaseListFileName (module):
61 return "%s-cases.xml" % module.name
63 def genCaseList (buildCfg, generator, module):
64 workDir = os.path.join(getModulesPath(buildCfg), module.dirName)
66 pushWorkingDir(workDir)
69 binPath = generator.getBinaryPath(buildCfg.getBuildType(), os.path.join(".", module.binName))
70 execute([binPath, "--deqp-runmode=xml-caselist"])
74 def genAndCopyCaseList (buildCfg, generator, module, dstDir):
75 caseListFile = getCaseListFileName(module)
76 srcPath = os.path.join(getModulesPath(buildCfg), module.dirName, caseListFile)
77 dstPath = os.path.join(dstDir, caseListFile)
79 if os.path.exists(srcPath):
82 genCaseList(buildCfg, generator, module)
84 if not os.path.exists(srcPath):
85 raise Exception("%s not generated" % srcPath)
87 shutil.copyfile(srcPath, dstPath)
90 parser = argparse.ArgumentParser(description = "Build test case lists",
91 formatter_class=argparse.ArgumentDefaultsHelpFormatter)
92 parser.add_argument("-b",
95 default=DEFAULT_BUILD_DIR,
96 help="Temporary build directory")
97 parser.add_argument("-t",
102 parser.add_argument("-c",
105 default=DEFAULT_TARGET,
106 help="dEQP build target")
107 parser.add_argument("-m",
110 help="Comma-separated list of modules to update")
111 parser.add_argument("dst",
112 help="Destination directory for test case lists")
113 return parser.parse_args()
115 if __name__ == "__main__":
118 generator = ANY_GENERATOR
119 buildCfg = getBuildConfig(args.buildDir, args.targetName, args.buildType)
124 for m in args.modules.split(","):
125 modules.append(getModuleByName(m))
128 build(buildCfg, generator, [m.binName for m in modules])
130 build(buildCfg, generator)
131 modules = getBuiltModules(buildCfg)
133 for module in modules:
134 print "Generating test case list for %s" % module.name
135 genAndCopyCaseList(buildCfg, generator, module, args.dst)