1 # -*- coding: utf-8 -*-
3 #-------------------------------------------------------------------------
4 # drawElements Quality Program utilities
5 # --------------------------------------
7 # Copyright 2015 The Android Open Source Project
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
13 # http://www.apache.org/licenses/LICENSE-2.0
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.
21 #-------------------------------------------------------------------------
34 return '"%s"' % s.replace('\\', '\\\\').replace('"', '\"').replace('$', '\$').replace('`', '\`')
36 def execute (args, workDir = None):
40 retcode = subprocess.call(args)
43 raise Exception("Failed to execute %s, got %d" % (str(args), retcode))
46 def __init__ (self, name, srcPath, buildPath, genParams, buildParams, testBinaryName, executor = 'executor', execserver = 'execserver', junitTool = 'testlog-to-junit'):
48 self.srcPath = srcPath
49 self.buildPath = buildPath
50 self.genParams = genParams
51 self.buildParams = buildParams
52 self.testBinaryName = testBinaryName
53 self.executor = executor
54 self.execserver = execserver
55 self.junitTool = junitTool
57 def initBuildDir (config):
58 if os.path.exists(config.buildPath):
59 shutil.rmtree(config.buildPath)
61 os.makedirs(config.buildPath)
62 execute(["cmake", os.path.realpath(config.srcPath)] + config.genParams, workDir = config.buildPath)
64 def prepareBuildDir (config):
65 # If build dir exists, try to refresh
66 if os.path.exists(config.buildPath):
68 execute(["cmake", "."], workDir = config.buildPath)
70 print "WARNING: Failed to refresh build dir, recreating"
76 prepareBuildDir(config)
77 execute(["cmake", "--build", "."] + config.buildParams, workDir = config.buildPath)
79 def runInternalTests (config):
80 batchResultFile = config.name + ".qpa"
81 infoLogFile = config.name + ".txt"
82 junitFile = config.name + ".xml"
84 testWorkDir = os.path.join(config.buildPath, "modules", "internal")
85 junitToolPath = os.path.join(config.buildPath, 'executor', config.junitTool)
88 for file in [batchResultFile, junitFile]:
89 if os.path.exists(file):
95 execute([config.testBinaryName, "--deqp-runmode=xml-caselist"], workDir = testWorkDir)
97 # Run test binary using executor
99 os.path.join(config.buildPath, 'executor', config.executor),
100 '--port=%d' % random.randint(50000, 60000),
101 '--start-server=%s' % os.path.join(config.buildPath, 'execserver', config.execserver),
102 '--binaryname=%s' % config.testBinaryName,
103 '--cmdline=--deqp-crashhandler=enable --deqp-watchdog=enable',
104 '--workdir=%s' % testWorkDir,
105 '--caselistdir=%s' % os.path.join(testWorkDir),
107 '--out=%s' % batchResultFile,
108 '--info=%s' % infoLogFile
112 # Convert log to junit format
113 execute([junitToolPath, batchResultFile, junitFile])
115 SRC_PATH = os.path.normpath(os.path.join(os.path.dirname(__file__), ".."))
116 BASE_BUILD_PATH = os.path.normpath(os.path.join(SRC_PATH, "..", "de-internal-tests"))
122 os.path.join(BASE_BUILD_PATH, "win32-vs10-debug"),
123 ['-GVisual Studio 10', '-DDEQP_TARGET=no_modules'],
124 ['--config', 'Debug', '--', '/m'],
125 'Debug\\de-internal-tests.exe',
126 'Debug\\executor.exe',
127 'Debug\\execserver.exe',
128 'Debug\\testlog-to-junit.exe'
131 "win32-vs10-release",
133 os.path.join(BASE_BUILD_PATH, "win32-vs10-release"),
134 ['-GVisual Studio 10', '-DDEQP_TARGET=no_modules'],
135 ['--config', 'Release', '--', '/m'],
136 'Release\\de-internal-tests.exe',
137 'Release\\executor.exe',
138 'Release\\execserver.exe',
139 'Release\\testlog-to-junit.exe'
144 os.path.join(BASE_BUILD_PATH, "win64-vs10-debug"),
145 ['-GVisual Studio 10 Win64', '-DDEQP_TARGET=no_modules'],
146 ['--config', 'Debug', '--', '/m'],
147 'Debug\\de-internal-tests.exe',
148 'Debug\\executor.exe',
149 'Debug\\execserver.exe',
150 'Debug\\testlog-to-junit.exe'
153 "win64-vs10-release",
155 os.path.join(BASE_BUILD_PATH, "win64-vs10-release"),
156 ['-GVisual Studio 10 Win64', '-DDEQP_TARGET=no_modules'],
157 ['--config', 'Release', '--', '/m'],
158 'Release\\de-internal-tests.exe',
159 'Release\\executor.exe',
160 'Release\\execserver.exe',
161 'Release\\testlog-to-junit.exe'
168 os.path.join(BASE_BUILD_PATH, "linux32-gcc-debug"),
169 ['-DDEQP_TARGET=no_modules', '-DCMAKE_BUILD_TYPE=Debug', '-DCMAKE_C_FLAGS=-m32', '-DCMAKE_CXX_FLAGS=-m32', '-DCMAKE_LIBRARY_PATH=/usr/lib32;usr/lib/i386-linux-gnu'],
171 './de-internal-tests'
174 "linux32-gcc-release",
176 os.path.join(BASE_BUILD_PATH, "linux32-gcc-release"),
177 ['-DDEQP_TARGET=no_modules', '-DCMAKE_BUILD_TYPE=Release', '-DCMAKE_C_FLAGS=-m32', '-DCMAKE_CXX_FLAGS=-m32', '-DCMAKE_LIBRARY_PATH=/usr/lib32;usr/lib/i386-linux-gnu'],
179 './de-internal-tests'
184 os.path.join(BASE_BUILD_PATH, "linux64-gcc-debug"),
185 ['-DDEQP_TARGET=no_modules', '-DCMAKE_BUILD_TYPE=Debug', '-DCMAKE_C_FLAGS=-m64', '-DCMAKE_CXX_FLAGS=-m64'],
187 './de-internal-tests'
190 "linux64-gcc-release",
192 os.path.join(BASE_BUILD_PATH, "linux64-gcc-release"),
193 ['-DDEQP_TARGET=no_modules', '-DCMAKE_BUILD_TYPE=Release', '-DCMAKE_C_FLAGS=-m64', '-DCMAKE_CXX_FLAGS=-m64'],
195 './de-internal-tests'
200 "linux32-clang-debug",
202 os.path.join(BASE_BUILD_PATH, "linux32-clang-debug"),
203 ['-DDEQP_TARGET=no_modules', '-DCMAKE_BUILD_TYPE=Debug', '-DCMAKE_C_FLAGS=-m32', '-DCMAKE_CXX_FLAGS=-m32', '-DCMAKE_LIBRARY_PATH=/usr/lib32;usr/lib/i386-linux-gnu', '-DCMAKE_C_COMPILER=clang', '-DCMAKE_CXX_COMPILER=clang++', '-DDE_COMPILER=DE_COMPILER_CLANG'],
205 './de-internal-tests'
208 "linux32-clang-release",
210 os.path.join(BASE_BUILD_PATH, "linux32-clang-release"),
211 ['-DDEQP_TARGET=no_modules', '-DCMAKE_BUILD_TYPE=Release', '-DCMAKE_C_FLAGS=-m32', '-DCMAKE_CXX_FLAGS=-m32', '-DCMAKE_LIBRARY_PATH=/usr/lib32;usr/lib/i386-linux-gnu', '-DCMAKE_C_COMPILER=clang', '-DCMAKE_CXX_COMPILER=clang++', '-DDE_COMPILER=DE_COMPILER_CLANG'],
213 './de-internal-tests'
216 "linux64-clang-debug",
218 os.path.join(BASE_BUILD_PATH, "linux64-clang-debug"),
219 ['-DDEQP_TARGET=no_modules', '-DCMAKE_BUILD_TYPE=Debug', '-DCMAKE_C_FLAGS=-m64', '-DCMAKE_CXX_FLAGS=-m64', '-DCMAKE_C_COMPILER=clang', '-DCMAKE_CXX_COMPILER=clang++', '-DDE_COMPILER=DE_COMPILER_CLANG'],
221 './de-internal-tests'
224 "linux64-clang-release",
226 os.path.join(BASE_BUILD_PATH, "linux64-clang-release"),
227 ['-DDEQP_TARGET=no_modules', '-DCMAKE_BUILD_TYPE=Release', '-DCMAKE_C_FLAGS=-m64', '-DCMAKE_CXX_FLAGS=-m64', '-DCMAKE_C_COMPILER=clang', '-DCMAKE_CXX_COMPILER=clang++', '-DDE_COMPILER=DE_COMPILER_CLANG'],
229 './de-internal-tests'
233 def findConfig (name):
234 for config in CONFIGS:
235 if config.name == name:
239 if __name__ == "__main__":
240 if len(sys.argv) != 2:
241 die("%s: [config]" % sys.argv[0])
243 config = findConfig(sys.argv[1])
245 die("Config '%s' not found" % sys.argv[1])
248 runInternalTests(config)