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