Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- Makefile.am | 2 ++ tests/preproc-invalid.shader_test | 8 ++++++++ tests/shader_runner_d3d12.c | 25 +++++++++++++++++++++++++ 3 files changed, 35 insertions(+) create mode 100644 tests/preproc-invalid.shader_test
diff --git a/Makefile.am b/Makefile.am index 59e054fe..ec827076 100644 --- a/Makefile.am +++ b/Makefile.am @@ -67,6 +67,7 @@ vkd3d_shader_tests = \ tests/preproc-if.shader_test \ tests/preproc-ifdef.shader_test \ tests/preproc-if-expr.shader_test \ + tests/preproc-invalid.shader_test \ tests/preproc-macro.shader_test \ tests/swizzle-0.shader_test \ tests/swizzle-1.shader_test \ @@ -213,6 +214,7 @@ XFAIL_TESTS = \ tests/preproc-if.shader_test \ tests/preproc-ifdef.shader_test \ tests/preproc-if-expr.shader_test \ + tests/preproc-invalid.shader_test \ tests/preproc-macro.shader_test \ tests/swizzle-0.shader_test \ tests/swizzle-1.shader_test \ diff --git a/tests/preproc-invalid.shader_test b/tests/preproc-invalid.shader_test new file mode 100644 index 00000000..8a30aad3 --- /dev/null +++ b/tests/preproc-invalid.shader_test @@ -0,0 +1,8 @@ +[preproc fail] +#error + +[preproc fail] +#include <nonexistent_file> + +[preproc fail] +#include "nonexistent_file" diff --git a/tests/shader_runner_d3d12.c b/tests/shader_runner_d3d12.c index 39495fa2..bf5c3e08 100644 --- a/tests/shader_runner_d3d12.c +++ b/tests/shader_runner_d3d12.c @@ -103,6 +103,7 @@ enum parse_state { STATE_NONE, STATE_PREPROC, + STATE_PREPROC_INVALID, STATE_SHADER_INVALID_PIXEL, STATE_SHADER_PIXEL, STATE_TEST, @@ -347,6 +348,27 @@ START_TEST(shader_runner_d3d12) break; }
+ case STATE_PREPROC_INVALID: + { + ID3D10Blob *blob = NULL, *errors = NULL; + HRESULT hr; + + hr = D3DPreprocess(shader_source, strlen(shader_source), NULL, NULL, NULL, &blob, &errors); + ok(hr == E_FAIL, "Got unexpected hr %#x.\n", hr); + ok(!blob, "Expected no compiled shader blob.\n"); + ok(!!errors, "Expected non-NULL error blob.\n"); + + if (errors) + { + if (vkd3d_test_state.debug_level) + trace("%s\n", (char *)ID3D10Blob_GetBufferPointer(errors)); + ID3D10Blob_Release(errors); + } + + shader_source_len = 0; + break; + } + case STATE_PREPROC: { ID3D10Blob *blob = NULL, *errors = NULL; @@ -389,6 +411,8 @@ START_TEST(shader_runner_d3d12) state = STATE_TEST; else if (!strcmp(line, "[preproc]\n")) state = STATE_PREPROC; + else if (!strcmp(line, "[preproc fail]\n")) + state = STATE_PREPROC_INVALID;
vkd3d_test_set_context("Section %.*s, line %u", strlen(line) - 1, line, line_number); } @@ -402,6 +426,7 @@ START_TEST(shader_runner_d3d12) break;
case STATE_PREPROC: + case STATE_PREPROC_INVALID: case STATE_SHADER_INVALID_PIXEL: case STATE_SHADER_PIXEL: {