Commit cccc419e authored by Paul Berry's avatar Paul Berry

Add comprehensive tests of builtin functions with uniform input.

This patch adds 462 tests to piglit, which comprehensively test the
behavior of GLSL built-in functions on vertex and fragment shaders.
The test vectors are auto-generated in Python, by using the numpy
library to simulate the behavior of the built-in functions on a
variety of inputs (in builtin_function.py), and then producing
shader_runner tests to verify the expected behavior (in
gen_builtin_uniform_tests.py).

Test generation happens as part of the piglit build process.  To run
the test generation step by itself, use "make gen-tests" from the root
of the piglit tree (after configuring using cmake).  The generated
tests may be found in generated_tests/spec.

The auto-generation code depends on Python 2.6 and on the numpy
library (www.numpy.org).  I've updated the README to reflect these
dependencies, and added code to CMakeLists.txt to check for them at
configure time.  (Note: other parts of Piglit already depend on Python
2.6, but the dependency wasn't previously explicit).
parent fb2d09ee
......@@ -13,6 +13,27 @@ find_package(GLUT REQUIRED)
find_package(PNG REQUIRED)
find_package(X11)
# Check for presence of Python 2.6 or greater.
execute_process(
COMMAND python -c "import sys; assert sys.version >= '2.6'"
OUTPUT_QUIET
ERROR_QUIET
RESULT_VARIABLE python_version_check_error_code)
if(NOT(python_version_check_error_code EQUAL 0))
message(FATAL_ERROR "python version 2.6 or greater required")
endif(NOT(python_version_check_error_code EQUAL 0))
# Check for the presence of numpy, which is needed to build generated
# tests.
execute_process(
COMMAND python -c "import numpy"
OUTPUT_QUIET
ERROR_QUIET
RESULT_VARIABLE import_numpy_error_code)
if(NOT(import_numpy_error_code EQUAL 0))
message(FATAL_ERROR "numpy library not found")
endif(NOT(import_numpy_error_code EQUAL 0))
if (NOT MSVC)
CHECK_C_COMPILER_FLAG("-Wall" C_COMPILER_FLAG_WALL)
IF (C_COMPILER_FLAG_WALL)
......@@ -81,3 +102,4 @@ configure_file(
include_directories(src)
add_subdirectory(cmake/target_api)
add_subdirectory(generated_tests)
......@@ -28,7 +28,8 @@ The original tests have been taken from
First of all, you need to make sure that the following are installed:
- Python 2.4 or greater
- Python 2.6 or greater
- numpy (http://www.numpy.org)
- cmake (http://www.cmake.org)
- GL, glu and glut libraries and development packages (i.e. headers)
- X11 libraries and development packages (i.e. headers)
......
# Execute gen_builtin_uniform_tests.py once during configure to find
# out what files it generates.
set(gen_builtin_uniform
${CMAKE_CURRENT_SOURCE_DIR}/gen_builtin_uniform_tests.py)
execute_process(
COMMAND python ${gen_builtin_uniform} --names-only
OUTPUT_VARIABLE builtin_uniform_tests
RESULT_VARIABLE builtin_uniform_tests_result)
if(NOT(builtin_uniform_tests_result EQUAL 0))
message(FATAL_ERROR "gen_builtin_uniform_tests.py failed")
endif(NOT(builtin_uniform_tests_result EQUAL 0))
string(REPLACE "\n" ";" builtin_uniform_tests ${builtin_uniform_tests})
# Add a custom command which executes gen_builtin_uniform_tests.py
# during the build.
add_custom_command(OUTPUT ${builtin_uniform_tests}
COMMAND python ${gen_builtin_uniform}
DEPENDS gen_builtin_uniform_tests.py builtin_function.py
VERBATIM)
# And add a "gen-tests" target that can be used to generate all the
# tests without doing any other compilation.
add_custom_target(gen-tests ALL
DEPENDS ${builtin_uniform_tests})
This diff is collapsed.
This diff is collapsed.
......@@ -20,6 +20,15 @@ blacklist = [
'shaders/glsl-vs-inline-explosion',
]
# Find the generated_tests directory, by looking either in
# $PIGLIT_BUILD_DIR (if that environment variable exists) or in the
# parent directory of the directory containing this file.
generatedTestDir = os.path.join(
os.environ.get(
'PIGLIT_BUILD_DIR',
os.path.join(os.path.dirname(__file__), '..')),
'generated_tests')
######
# Collecting all tests
profile = TestProfile()
......@@ -727,6 +736,9 @@ spec['glsl-1.10']['execution'] = Group()
add_shader_test_dir(spec['glsl-1.10']['execution'],
os.path.join(os.path.dirname(__file__), 'spec', 'glsl-1.10', 'execution'),
recursive=True)
add_shader_test_dir(spec['glsl-1.10']['execution'],
os.path.join(generatedTestDir, 'spec', 'glsl-1.10', 'execution'),
recursive=True)
# Group spec/glsl-1.20
spec['glsl-1.20'] = Group()
......@@ -737,6 +749,9 @@ spec['glsl-1.20']['execution'] = Group()
add_shader_test_dir(spec['glsl-1.20']['execution'],
os.path.join(os.path.dirname(__file__), 'spec', 'glsl-1.20', 'execution'),
recursive=True)
add_shader_test_dir(spec['glsl-1.20']['execution'],
os.path.join(generatedTestDir, 'spec', 'glsl-1.20', 'execution'),
recursive=True)
# Group spec/glsl-1.30
spec['glsl-1.30'] = Group()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment