• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# -*- coding: utf-8 -*-
2
3#-------------------------------------------------------------------------
4# drawElements Quality Program utilities
5# --------------------------------------
6#
7# Copyright 2015 The Android Open Source Project
8#
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
12#
13#      http://www.apache.org/licenses/LICENSE-2.0
14#
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.
20#
21#-------------------------------------------------------------------------
22
23import os
24import sys
25import string
26import argparse
27import tempfile
28import shutil
29
30sys.path.append(os.path.join(os.path.dirname(__file__), "..", "..", "..", "scripts"))
31
32from ctsbuild.common import *
33from ctsbuild.config import *
34from ctsbuild.build import *
35
36
37class Module:
38	def __init__ (self, name, api):
39		self.name		= name
40		self.api        = api
41
42MODULES = [
43	Module("dEQP-EGL",		"EGL"),
44	Module("dEQP-GLES2",	"GLES2"),
45	Module("dEQP-GLES3",	"GLES3"),
46	Module("dEQP-GLES31",	"GLES31"),
47	Module("dEQP-GL45-ES3",	"GL45"),
48	Module("dEQP-GL45-ES31","GL45"),
49	Module("KHR-GLES3",		"GLES3"),
50	Module("KHR-GLES2",		"GLES2"),
51	Module("KHR-GLES31",	"GLES31"),
52	Module("KHR-GLES32",	"GLES32"),
53	Module("KHR-NOCTX-ES2",	"GLES2"),
54	Module("KHR-NOCTX-ES32","GLES32"),
55	Module("GTF-GLES2",		"GLES2" ),
56	Module("GTF-GLES3",		"GLES3" ),
57	Module("GTF-GLES31",	"GLES31"),
58	Module("KHR-GL46",		"GL46"),
59	Module("KHR-GL45",		"GL45"),
60	Module("KHR-GL44",		"GL44"),
61	Module("KHR-GL43",		"GL43"),
62	Module("KHR-GL42",		"GL42"),
63	Module("KHR-GL42-COMPAT",	"GL42-COMPAT"),
64	Module("KHR-GL41",		"GL41"),
65	Module("KHR-GL40",		"GL40"),
66	Module("KHR-GL33",		"GL33"),
67	Module("KHR-GL32",		"GL32"),
68	Module("KHR-GL31",		"GL31"),
69	Module("KHR-GL30",		"GL30"),
70	Module("GTF-GL46",		"GL46"),
71	Module("GTF-GL45",		"GL45"),
72	Module("GTF-GL44",		"GL44"),
73	Module("GTF-GL43",		"GL43"),
74	Module("GTF-GL42",		"GL42"),
75	Module("GTF-GL41",		"GL41"),
76	Module("GTF-GL40",		"GL40"),
77	Module("GTF-GL33",		"GL33"),
78	Module("GTF-GL32",		"GL32"),
79	Module("GTF-GL31",		"GL31"),
80	Module("GTF-GL30",		"GL30"),
81	Module("KHR-NOCTX-GL30","GL30"),
82	Module("KHR-NOCTX-GL40","GL40"),
83	Module("KHR-NOCTX-GL43","GL43"),
84	Module("KHR-NOCTX-GL45","GL45"),
85	Module("KHR-Single-GL43","GL43"),
86	Module("KHR-Single-GL44","GL44"),
87	Module("KHR-Single-GL45","GL45"),
88	Module("KHR-Single-GL46","GL46"),
89	Module("KHR-Single-GLES32","GLES32"),
90]
91GLCTS_BIN_NAME = "glcts"
92GLCTS_DIR_NAME = "external/openglcts/modules/"
93DEFAULT_BUILD_DIR	= os.path.join(tempfile.gettempdir(), "deqp-caselists", "{targetName}-{buildType}")
94DEFAULT_TARGET		= "null"
95
96def getModuleByName (name):
97	for module in MODULES:
98		if module.name == name:
99			return module
100	else:
101		raise Exception("Unknown module %s" % name)
102
103def getBuildConfig (buildPathPtrn, targetName, buildType):
104	buildPath = buildPathPtrn.format(
105		targetName	= targetName,
106		buildType	= buildType)
107
108	return BuildConfig(buildPath, buildType, ["-DDEQP_TARGET=%s" % targetName])
109
110def getModulesPath (buildCfg):
111	return os.path.join(buildCfg.getBuildDir(), GLCTS_DIR_NAME)
112
113def getCaseListFileName (module, caseListType):
114	mname = module.name
115	if mname == "KHR-NOCTX-ES2" or mname == "KHR-NOCTX-ES32" or mname == "KHR-NOCTX-GL30" or mname == "KHR-NOCTX-GL40" or mname == "KHR-NOCTX-GL43" or mname == "KHR-NOCTX-GL45":
116		mname =  "KHR-NoContext"
117	return "%s-cases.%s" % (mname, caseListType)
118
119def getCaseListPath (buildCfg, module, caseListType):
120	workDir = getModulesPath(buildCfg)
121
122	return os.path.join(workDir, getCaseListFileName(module, caseListType))
123
124def genCaseList (buildCfg, generator, caseListType):
125	workDir = getModulesPath(buildCfg)
126
127	pushWorkingDir(workDir)
128
129	try:
130		binPath = generator.getBinaryPath(buildCfg.getBuildType(), os.path.join(".", GLCTS_BIN_NAME))
131		execute([binPath, "--deqp-runmode=%s-caselist" % caseListType])
132	finally:
133		popWorkingDir()
134
135def genAndCopyCaseList (buildCfg, generator, module, dstDir, caseListType):
136	caseListFile	= getCaseListFileName(module, caseListType)
137	srcPath			= getCaseListPath(buildCfg, module, caseListType)
138	dstPath			= os.path.join(dstDir, caseListFile)
139
140	if os.path.exists(srcPath):
141		os.remove(srcPath)
142
143	genCaseList(buildCfg, generator, module, caseListType)
144
145	if not os.path.exists(srcPath):
146		raise Exception("%s not generated" % srcPath)
147
148	shutil.copyfile(srcPath, dstPath)
149