PageRenderTime 44ms CodeModel.GetById 17ms RepoModel.GetById 1ms app.codeStats 0ms

/scripts/run_internal_tests.py

https://gitlab.com/OBSERVER-DLL/deqp
Python | 248 lines | 196 code | 25 blank | 27 comment | 13 complexity | 80faa04118bbb57d7d22fed7598c9034 MD5 | raw file
  1. # -*- coding: utf-8 -*-
  2. #-------------------------------------------------------------------------
  3. # drawElements Quality Program utilities
  4. # --------------------------------------
  5. #
  6. # Copyright 2015 The Android Open Source Project
  7. #
  8. # Licensed under the Apache License, Version 2.0 (the "License");
  9. # you may not use this file except in compliance with the License.
  10. # You may obtain a copy of the License at
  11. #
  12. # http://www.apache.org/licenses/LICENSE-2.0
  13. #
  14. # Unless required by applicable law or agreed to in writing, software
  15. # distributed under the License is distributed on an "AS IS" BASIS,
  16. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  17. # See the License for the specific language governing permissions and
  18. # limitations under the License.
  19. #
  20. #-------------------------------------------------------------------------
  21. import os
  22. import sys
  23. import shutil
  24. import random
  25. import subprocess
  26. def die (msg):
  27. print msg
  28. exit(-1)
  29. def shellquote(s):
  30. return '"%s"' % s.replace('\\', '\\\\').replace('"', '\"').replace('$', '\$').replace('`', '\`')
  31. def execute (args, workDir = None):
  32. curPath = os.getcwd()
  33. if workDir != None:
  34. os.chdir(workDir)
  35. retcode = subprocess.call(args)
  36. os.chdir(curPath)
  37. if retcode != 0:
  38. raise Exception("Failed to execute %s, got %d" % (str(args), retcode))
  39. class Config:
  40. def __init__ (self, name, srcPath, buildPath, genParams, buildParams, testBinaryName, executor = 'executor', execserver = 'execserver', junitTool = 'testlog-to-junit'):
  41. self.name = name
  42. self.srcPath = srcPath
  43. self.buildPath = buildPath
  44. self.genParams = genParams
  45. self.buildParams = buildParams
  46. self.testBinaryName = testBinaryName
  47. self.executor = executor
  48. self.execserver = execserver
  49. self.junitTool = junitTool
  50. def initBuildDir (config):
  51. if os.path.exists(config.buildPath):
  52. shutil.rmtree(config.buildPath)
  53. os.makedirs(config.buildPath)
  54. execute(["cmake", os.path.realpath(config.srcPath)] + config.genParams, workDir = config.buildPath)
  55. def prepareBuildDir (config):
  56. # If build dir exists, try to refresh
  57. if os.path.exists(config.buildPath):
  58. try:
  59. execute(["cmake", "."], workDir = config.buildPath)
  60. except:
  61. print "WARNING: Failed to refresh build dir, recreating"
  62. initBuildDir(config)
  63. else:
  64. initBuildDir(config)
  65. def build (config):
  66. prepareBuildDir(config)
  67. execute(["cmake", "--build", "."] + config.buildParams, workDir = config.buildPath)
  68. def runInternalTests (config):
  69. batchResultFile = config.name + ".qpa"
  70. infoLogFile = config.name + ".txt"
  71. junitFile = config.name + ".xml"
  72. testWorkDir = os.path.join(config.buildPath, "modules", "internal")
  73. junitToolPath = os.path.join(config.buildPath, 'executor', config.junitTool)
  74. # Remove old files
  75. for file in [batchResultFile, junitFile]:
  76. if os.path.exists(file):
  77. os.remove(file)
  78. build(config)
  79. # Dump case list
  80. execute([config.testBinaryName, "--deqp-runmode=xml-caselist"], workDir = testWorkDir)
  81. # Run test binary using executor
  82. args = [
  83. os.path.join(config.buildPath, 'executor', config.executor),
  84. '--port=%d' % random.randint(50000, 60000),
  85. '--start-server=%s' % os.path.join(config.buildPath, 'execserver', config.execserver),
  86. '--binaryname=%s' % config.testBinaryName,
  87. '--cmdline=--deqp-crashhandler=enable --deqp-watchdog=enable',
  88. '--workdir=%s' % testWorkDir,
  89. '--caselistdir=%s' % os.path.join(testWorkDir),
  90. '--testset=dE-IT.*',
  91. '--out=%s' % batchResultFile,
  92. '--info=%s' % infoLogFile
  93. ]
  94. execute(args)
  95. # Convert log to junit format
  96. execute([junitToolPath, batchResultFile, junitFile])
  97. SRC_PATH = os.path.normpath(os.path.join(os.path.dirname(__file__), ".."))
  98. BASE_BUILD_PATH = os.path.normpath(os.path.join(SRC_PATH, "..", "de-internal-tests"))
  99. CONFIGS = [
  100. Config(
  101. "win32-vs10-debug",
  102. SRC_PATH,
  103. os.path.join(BASE_BUILD_PATH, "win32-vs10-debug"),
  104. ['-GVisual Studio 10', '-DDEQP_TARGET=no_modules'],
  105. ['--config', 'Debug', '--', '/m'],
  106. 'Debug\\de-internal-tests.exe',
  107. 'Debug\\executor.exe',
  108. 'Debug\\execserver.exe',
  109. 'Debug\\testlog-to-junit.exe'
  110. ),
  111. Config(
  112. "win32-vs10-release",
  113. SRC_PATH,
  114. os.path.join(BASE_BUILD_PATH, "win32-vs10-release"),
  115. ['-GVisual Studio 10', '-DDEQP_TARGET=no_modules'],
  116. ['--config', 'Release', '--', '/m'],
  117. 'Release\\de-internal-tests.exe',
  118. 'Release\\executor.exe',
  119. 'Release\\execserver.exe',
  120. 'Release\\testlog-to-junit.exe'
  121. ),
  122. Config(
  123. "win64-vs10-debug",
  124. SRC_PATH,
  125. os.path.join(BASE_BUILD_PATH, "win64-vs10-debug"),
  126. ['-GVisual Studio 10 Win64', '-DDEQP_TARGET=no_modules'],
  127. ['--config', 'Debug', '--', '/m'],
  128. 'Debug\\de-internal-tests.exe',
  129. 'Debug\\executor.exe',
  130. 'Debug\\execserver.exe',
  131. 'Debug\\testlog-to-junit.exe'
  132. ),
  133. Config(
  134. "win64-vs10-release",
  135. SRC_PATH,
  136. os.path.join(BASE_BUILD_PATH, "win64-vs10-release"),
  137. ['-GVisual Studio 10 Win64', '-DDEQP_TARGET=no_modules'],
  138. ['--config', 'Release', '--', '/m'],
  139. 'Release\\de-internal-tests.exe',
  140. 'Release\\executor.exe',
  141. 'Release\\execserver.exe',
  142. 'Release\\testlog-to-junit.exe'
  143. ),
  144. # GCC configs
  145. Config(
  146. "linux32-gcc-debug",
  147. SRC_PATH,
  148. os.path.join(BASE_BUILD_PATH, "linux32-gcc-debug"),
  149. ['-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'],
  150. ['--', '-j', '2'],
  151. './de-internal-tests'
  152. ),
  153. Config(
  154. "linux32-gcc-release",
  155. SRC_PATH,
  156. os.path.join(BASE_BUILD_PATH, "linux32-gcc-release"),
  157. ['-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'],
  158. ['--', '-j', '2'],
  159. './de-internal-tests'
  160. ),
  161. Config(
  162. "linux64-gcc-debug",
  163. SRC_PATH,
  164. os.path.join(BASE_BUILD_PATH, "linux64-gcc-debug"),
  165. ['-DDEQP_TARGET=no_modules', '-DCMAKE_BUILD_TYPE=Debug', '-DCMAKE_C_FLAGS=-m64', '-DCMAKE_CXX_FLAGS=-m64'],
  166. ['--', '-j', '2'],
  167. './de-internal-tests'
  168. ),
  169. Config(
  170. "linux64-gcc-release",
  171. SRC_PATH,
  172. os.path.join(BASE_BUILD_PATH, "linux64-gcc-release"),
  173. ['-DDEQP_TARGET=no_modules', '-DCMAKE_BUILD_TYPE=Release', '-DCMAKE_C_FLAGS=-m64', '-DCMAKE_CXX_FLAGS=-m64'],
  174. ['--', '-j', '2'],
  175. './de-internal-tests'
  176. ),
  177. # Clang configs
  178. Config(
  179. "linux32-clang-debug",
  180. SRC_PATH,
  181. os.path.join(BASE_BUILD_PATH, "linux32-clang-debug"),
  182. ['-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'],
  183. ['--', '-j', '2'],
  184. './de-internal-tests'
  185. ),
  186. Config(
  187. "linux32-clang-release",
  188. SRC_PATH,
  189. os.path.join(BASE_BUILD_PATH, "linux32-clang-release"),
  190. ['-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'],
  191. ['--', '-j', '2'],
  192. './de-internal-tests'
  193. ),
  194. Config(
  195. "linux64-clang-debug",
  196. SRC_PATH,
  197. os.path.join(BASE_BUILD_PATH, "linux64-clang-debug"),
  198. ['-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'],
  199. ['--', '-j', '2'],
  200. './de-internal-tests'
  201. ),
  202. Config(
  203. "linux64-clang-release",
  204. SRC_PATH,
  205. os.path.join(BASE_BUILD_PATH, "linux64-clang-release"),
  206. ['-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'],
  207. ['--', '-j', '2'],
  208. './de-internal-tests'
  209. )
  210. ]
  211. def findConfig (name):
  212. for config in CONFIGS:
  213. if config.name == name:
  214. return config
  215. return None
  216. if __name__ == "__main__":
  217. if len(sys.argv) != 2:
  218. die("%s: [config]" % sys.argv[0])
  219. config = findConfig(sys.argv[1])
  220. if config == None:
  221. die("Config '%s' not found" % sys.argv[1])
  222. random.seed()
  223. runInternalTests(config)