[Piglit] [PATCH v3 1/2] framework: Add a vulkan tests profile

Neil Roberts nroberts at igalia.com
Sat Nov 3 07:03:43 UTC 2018


This searches for files named *.vk_shader_test in the tests/vulkan
directory and runs them with VkRunner. VkRunner is executed as an
external dependency. It is found either in the path or by setting the
PIGLIT_VKRUNNER_BINARY environment variable.

v2: Move VkShaderTest to piglit_test.py and rename to VkRunnerTest.
    Add future imports. Remove unused import.
v3: Support the PIGLIT_VKRUNNER_BINARY variable to specify the
    location of VkRunner.
---
 framework/test/piglit_test.py | 17 +++++++++++++++++
 tests/vulkan.py               | 33 +++++++++++++++++++++++++++++++++
 2 files changed, 50 insertions(+)
 create mode 100644 tests/vulkan.py

diff --git a/framework/test/piglit_test.py b/framework/test/piglit_test.py
index f52915d18..e56f3a37d 100644
--- a/framework/test/piglit_test.py
+++ b/framework/test/piglit_test.py
@@ -44,6 +44,7 @@ __all__ = [
     'PiglitCLTest',
     'PiglitGLTest',
     'PiglitBaseTest',
+    'VkRunnerTest',
     'CL_CONCURRENT',
     'ROOT_DIR',
     'TEST_BIN_DIR',
@@ -229,3 +230,19 @@ class CLProgramTester(PiglitCLTest):
         command = super(CLProgramTester, self).command
         command.insert(1, os.path.join(ROOT_DIR, self.filename))
         return command
+
+
+class VkRunnerTest(PiglitBaseTest):
+    """ Make a PiglitTest instance for a VkRunner shader test file """
+
+    def __init__(self, filename):
+        super(VkRunnerTest, self).__init__(
+            [os.getenv('PIGLIT_VKRUNNER_BINARY', 'vkrunner'), filename],
+            run_concurrent=True)
+
+    @PiglitBaseTest.command.getter
+    def command(self):
+        # This is overriden because we don’t want PiglitBaseTest to
+        # prepend TEST_BIN_DIR so that it will look for vkrunner in
+        # the search path.
+        return self._command
diff --git a/tests/vulkan.py b/tests/vulkan.py
new file mode 100644
index 000000000..7058f3108
--- /dev/null
+++ b/tests/vulkan.py
@@ -0,0 +1,33 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+"""All Vulkan tests that come with piglit, using default settings."""
+
+from __future__ import (
+    absolute_import, division, print_function, unicode_literals
+)
+
+import os
+
+from framework.profile import TestProfile
+from framework import grouptools
+from framework.test.piglit_test import VkRunnerTest
+from .py_modules.constants import TESTS_DIR, GENERATED_TESTS_DIR
+
+__all__ = ['profile']
+
+profile = TestProfile()
+
+# Find and add all shader tests.
+for basedir in [TESTS_DIR, GENERATED_TESTS_DIR]:
+    _basedir = os.path.join(basedir, 'vulkan')
+    for dirpath, _, filenames in os.walk(_basedir):
+        groupname = grouptools.from_path(os.path.relpath(dirpath, _basedir))
+        for filename in filenames:
+            testname, ext = os.path.splitext(filename)
+            if ext != '.vk_shader_test':
+                continue
+            test = VkRunnerTest(os.path.join(dirpath, filename))
+            group = grouptools.join(groupname, testname)
+            assert group not in profile.test_list, group
+
+            profile.test_list[group] = test
-- 
2.17.1



More information about the Piglit mailing list