blob: 33ea8d447a47aa843f85d5331ce7f47ba8f03800 [file] [log] [blame]
# -*- coding: utf-8 -*-
from build.common import *
from build.config import *
from build.build import *
import os
import sys
import string
import argparse
import tempfile
import shutil
class Module:
def __init__ (self, name, dirName, binName):
self.name = name
self.dirName = dirName
self.binName = binName
MODULES = [
Module("dE-IT", "internal", "de-internal-tests"),
Module("dEQP-EGL", "egl", "deqp-egl"),
Module("dEQP-GLES2", "gles2", "deqp-gles2"),
Module("dEQP-GLES3", "gles3", "deqp-gles3"),
Module("dEQP-GLES31", "gles31", "deqp-gles31"),
]
DEFAULT_BUILD_DIR = os.path.join(tempfile.gettempdir(), "deqp-caselists", "{targetName}-{buildType}")
DEFAULT_TARGET = "null"
def getModuleByName (name):
for module in MODULES:
if module.name == name:
return module
else:
raise Exception("Unknown module %s" % name)
def getBuildConfig (buildPathPtrn, targetName, buildType):
buildPath = buildPathPtrn.format(
targetName = targetName,
buildType = buildType)
return BuildConfig(buildPath, buildType, ["-DDEQP_TARGET=%s" % targetName])
def getModulesPath (buildCfg):
return os.path.join(buildCfg.getBuildDir(), "modules")
def getBuiltModules (buildCfg):
modules = []
modulesDir = getModulesPath(buildCfg)
modMap = {m.dirName: m for m in MODULES}
for entry in os.listdir(modulesDir):
fullPath = os.path.join(modulesDir, entry)
if os.path.isdir(fullPath) and entry in modMap:
modules.append(modMap[entry])
return modules
def getCaseListFileName (module):
return "%s-cases.xml" % module.name
def genCaseList (buildCfg, generator, module):
workDir = os.path.join(getModulesPath(buildCfg), module.dirName)
pushWorkingDir(workDir)
try:
binPath = generator.getBinaryPath(buildCfg.getBuildType(), os.path.join(".", module.binName))
execute([binPath, "--deqp-runmode=xml-caselist"])
finally:
popWorkingDir()
def genAndCopyCaseList (buildCfg, generator, module, dstDir):
caseListFile = getCaseListFileName(module)
srcPath = os.path.join(getModulesPath(buildCfg), module.dirName, caseListFile)
dstPath = os.path.join(dstDir, caseListFile)
if os.path.exists(srcPath):
os.remove(srcPath)
genCaseList(buildCfg, generator, module)
if not os.path.exists(srcPath):
raise Exception("%s not generated" % srcPath)
shutil.copyfile(srcPath, dstPath)
def parseArgs ():
parser = argparse.ArgumentParser(description = "Build test case lists",
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument("-b",
"--build-dir",
dest="buildDir",
default=DEFAULT_BUILD_DIR,
help="Temporary build directory")
parser.add_argument("-t",
"--build-type",
dest="buildType",
default="Debug",
help="Build type")
parser.add_argument("-c",
"--deqp-target",
dest="targetName",
default=DEFAULT_TARGET,
help="dEQP build target")
parser.add_argument("-m",
"--modules",
dest="modules",
help="Comma-separated list of modules to update")
parser.add_argument("dst",
help="Destination directory for test case lists")
return parser.parse_args()
if __name__ == "__main__":
args = parseArgs()
generator = ANY_GENERATOR
buildCfg = getBuildConfig(args.buildDir, args.targetName, args.buildType)
modules = None
if args.modules:
modules = []
for m in args.modules.split(","):
modules.append(getModuleByName(m))
if modules:
build(buildCfg, generator, [m.binName for m in modules])
else:
build(buildCfg, generator)
modules = getBuiltModules(buildCfg)
for module in modules:
print "Generating test case list for %s" % module.name
genAndCopyCaseList(buildCfg, generator, module, args.dst)