Add script for generating test case list files
authorPyry Haulos <phaulos@google.com>
Wed, 7 Jan 2015 19:50:55 +0000 (11:50 -0800)
committerPyry Haulos <phaulos@google.com>
Wed, 7 Jan 2015 20:29:45 +0000 (12:29 -0800)
This script builds dEQP to a temporary location, generates test case
lists in XML form, and copies them to a destination directory. Useful
with Cherry for example.

Change-Id: I00c7543268e8bfec7c31f4aaaba060c6c4802995

scripts/build/config.py
scripts/build_caselists.py [new file with mode: 0644]

index e94de67..733a224 100644 (file)
@@ -1,6 +1,7 @@
 # -*- coding: utf-8 -*-
 
 import os
+import sys
 import copy
 import platform
 import multiprocessing
@@ -108,7 +109,7 @@ class VSProjectGenerator(CMakeGenerator):
                        return False
 
        def isAvailable (self):
-               if _winreg != None:
+               if sys.platform == 'win32' and _winreg != None:
                        nativeArch = VSProjectGenerator.getNativeArch()
                        if nativeArch == self.ARCH_32BIT and self.arch == self.ARCH_64BIT:
                                return False
@@ -162,3 +163,13 @@ ANY_UNIX_GENERATOR         = selectFirstAvailableGenerator([
                                                                NINJA_GENERATOR,
                                                                MAKEFILE_GENERATOR,
                                                        ])
+ANY_GENERATOR                  = selectFirstAvailableGenerator([
+                                                               VS2013_X64_GENERATOR,
+                                                               VS2012_X64_GENERATOR,
+                                                               VS2010_X64_GENERATOR,
+                                                               VS2013_X32_GENERATOR,
+                                                               VS2012_X32_GENERATOR,
+                                                               VS2010_X32_GENERATOR,
+                                                               NINJA_GENERATOR,
+                                                               MAKEFILE_GENERATOR,
+                                                       ])
diff --git a/scripts/build_caselists.py b/scripts/build_caselists.py
new file mode 100644 (file)
index 0000000..33ea8d4
--- /dev/null
@@ -0,0 +1,135 @@
+# -*- 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)