Add recipe for amber-verify run mode
authorJari Komppa <jari.komppa@siru.fi>
Mon, 30 May 2022 09:28:04 +0000 (12:28 +0300)
committerMatthew Netsch <quic_mnetsch@quicinc.com>
Thu, 9 Jun 2022 19:03:30 +0000 (19:03 +0000)
Changes build check scripts to include a recipe for checking that amber
device requirements match with what CTS asks for.

Changes amber-verify code to also print out the errors in stderr to make
finding the errors easier by looking at the console log.

Affects: none

Components: Framework
VK-GL-CTS issue: 3368

Change-Id: Id064420425563111ac3e2038dd27d7becdccdcb6

external/vulkancts/modules/vulkan/amber/vktAmberTestCase.cpp
external/vulkancts/scripts/amber_verify.py [new file with mode: 0644]
scripts/check_build_sanity.py

index 9e00911..4ac9d6b 100644 (file)
@@ -505,6 +505,17 @@ bool AmberTestCase::validateRequirements()
                for (const auto& amberReq : allRequirements)
                        log << tcu::TestLog::Message << "    " << amberReq << tcu::TestLog::EndMessage;
 
+               // Repeat message for cerr so it's visible in console log.
+               std::cerr << "ERROR: CTS and Amber test requirement mismatch.\n";
+               std::cerr << "Amber filename: " << m_readFilename << "\n";
+               std::cerr << "CTS requirements:\n";
+               for (const auto& ctsReq : ctsRequirements)
+                       std::cerr << "    " << ctsReq << "\n";
+
+               std::cerr << "Amber requirements:\n";
+               for (const auto& amberReq : allRequirements)
+                       std::cerr << "    " << amberReq << "\n";
+
                return false;
        }
        return true;
diff --git a/external/vulkancts/scripts/amber_verify.py b/external/vulkancts/scripts/amber_verify.py
new file mode 100644 (file)
index 0000000..eecb0d2
--- /dev/null
@@ -0,0 +1,100 @@
+# -*- coding: utf-8 -*-
+
+#-------------------------------------------------------------------------
+# Vulkan CTS
+# ----------
+#
+# Copyright (c) 2022 Google LLC.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#-------------------------------------------------------------------------
+
+import os
+import sys
+import argparse
+import tempfile
+
+sys.path.append(os.path.join(os.path.dirname(__file__), "..", "..", "..", "scripts"))
+
+from build.common import *
+from build.config import *
+from build.build import *
+
+class Module:
+       def __init__ (self, name, dirName, binName):
+               self.name               = name
+               self.dirName    = dirName
+               self.binName    = binName
+
+VULKAN_MODULE          = Module("dEQP-VK", "../external/vulkancts/modules/vulkan", "deqp-vk")
+DEFAULT_BUILD_DIR      = os.path.join(tempfile.gettempdir(), "amber-verify", "{targetName}-{buildType}")
+DEFAULT_TARGET         = "null"
+DEFAULT_DST_DIR                = os.path.join(DEQP_DIR, "external", "vulkancts", "data", "vulkan", "prebuilt")
+
+def getBuildConfig (buildPathPtrn, targetName, buildType):
+       buildPath = buildPathPtrn.format(
+               targetName      = targetName,
+               buildType       = buildType)
+
+       return BuildConfig(buildPath, buildType, [f"-DDEQP_TARGET={targetName}"])
+
+def execBuildPrograms (buildCfg, generator, module):
+       workDir         = os.path.join(buildCfg.getBuildDir(), "modules", module.dirName)
+
+       pushWorkingDir(workDir)
+
+       try:
+               binPath = generator.getBinaryPath(buildCfg.getBuildType(), os.path.join(".", "deqp-vk"))
+               execute([binPath, "--deqp-runmode=amber-verify"])
+       finally:
+               popWorkingDir()
+
+def parseArgs ():
+       parser = argparse.ArgumentParser(description = "Verify amber device requirements between CTS and .amber file",
+                                                                        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="Release",
+                                               help="Build type")
+       parser.add_argument("-c",
+                                               "--deqp-target",
+                                               dest="targetName",
+                                               default=DEFAULT_TARGET,
+                                               help="dEQP build target")
+       parser.add_argument("-d",
+                                               "--dst-path",
+                                               dest="dstPath",
+                                               default=DEFAULT_DST_DIR,
+                                               help="Destination path")
+       return parser.parse_args()
+
+if __name__ == "__main__":
+       args = parseArgs()
+
+       generator       = ANY_GENERATOR
+       buildCfg        = getBuildConfig(args.buildDir, args.targetName, args.buildType)
+       module          = VULKAN_MODULE
+
+       build(buildCfg, generator, ["deqp-vk"])
+
+       if not os.path.exists(args.dstPath):
+               os.makedirs(args.dstPath)
+
+       execBuildPrograms(buildCfg, generator, module)
index 715e676..6a6ec6f 100644 (file)
@@ -212,6 +212,12 @@ LATE_SPECIAL_RECIPES       = [
                                                                        "--build-dir", os.path.join(env.tmpDir, "spirv-binaries"),
                                                                        "--dst-path", os.path.join(env.tmpDir, "spirv-binaries")]),
                ]),
+       ('amber-verify', [
+                       RunScript(os.path.join("external", "vulkancts", "scripts", "amber_verify.py"),
+                                         lambda env: ["--build-type", "Release",
+                                                                       "--build-dir", os.path.join(env.tmpDir, "amber-verify"),
+                                                                       "--dst-path", os.path.join(env.tmpDir, "amber-verify")]),
+               ]),
        ('check-all', [
                        RunScript(os.path.join("scripts", "src_util", "check_all.py")),
                ])