From: Józef Kucia jkucia@codeweavers.com
Useful for table-based tests.
Signed-off-by: Józef Kucia jkucia@codeweavers.com --- include/private/vkd3d_test.h | 31 +++++++++++++++++++++++++------ tests/d3d12.c | 3 +++ 2 files changed, 28 insertions(+), 6 deletions(-)
diff --git a/include/private/vkd3d_test.h b/include/private/vkd3d_test.h index a2649dd64f76..ccc5350a2acb 100644 --- a/include/private/vkd3d_test.h +++ b/include/private/vkd3d_test.h @@ -93,6 +93,8 @@ static struct
unsigned int todo_level; bool todo_do_loop; + + char context[1024]; } vkd3d_test_state;
static bool @@ -116,13 +118,13 @@ vkd3d_test_check_ok(unsigned int line, bool result, const char *fmt, va_list arg { if (result) { - printf("%s:%d Todo succeeded: ", vkd3d_test_name, line); + printf("%s:%d%s: Todo succeeded: ", vkd3d_test_name, line, vkd3d_test_state.context); vprintf(fmt, args); InterlockedIncrement(&vkd3d_test_state.todo_success_count); } else { - printf("%s:%d: Todo: ", vkd3d_test_name, line); + printf("%s:%d%s: Todo: ", vkd3d_test_name, line, vkd3d_test_state.context); vprintf(fmt, args); InterlockedIncrement(&vkd3d_test_state.todo_count); } @@ -130,12 +132,12 @@ vkd3d_test_check_ok(unsigned int line, bool result, const char *fmt, va_list arg else if (result) { if (vkd3d_test_state.debug_level > 1) - printf("%s:%d: Test succeeded.\n", vkd3d_test_name, line); + printf("%s:%d%s: Test succeeded.\n", vkd3d_test_name, line, vkd3d_test_state.context); InterlockedIncrement(&vkd3d_test_state.success_count); } else { - printf("%s:%d: Test failed: ", vkd3d_test_name, line); + printf("%s:%d%s: Test failed: ", vkd3d_test_name, line, vkd3d_test_state.context); vprintf(fmt, args); InterlockedIncrement(&vkd3d_test_state.failure_count); } @@ -156,7 +158,7 @@ vkd3d_test_skip(unsigned int line, const char *fmt, ...) { va_list args; va_start(args, fmt); - printf("%s:%d: Test skipped: ", vkd3d_test_name, line); + printf("%s:%d%s: Test skipped: ", vkd3d_test_name, line, vkd3d_test_state.context); vprintf(fmt, args); va_end(args); InterlockedIncrement(&vkd3d_test_state.skip_count); @@ -167,7 +169,7 @@ vkd3d_test_trace(unsigned int line, const char *fmt, ...) { va_list args; va_start(args, fmt); - printf("%s:%d: ", vkd3d_test_name, line); + printf("%s:%d%s: ", vkd3d_test_name, line, vkd3d_test_state.context); vprintf(fmt, args); va_end(args); } @@ -304,6 +306,23 @@ static inline void vkd3d_test_end_todo(void) vkd3d_test_state.todo_level >>= 1; }
+static inline void vkd3d_test_set_context(const char *fmt, ...) +{ + va_list args; + + if (!fmt) + { + vkd3d_test_state.context[0] = '\0'; + return; + } + + vkd3d_test_state.context[0] = ':'; + va_start(args, fmt); + vsnprintf(&vkd3d_test_state.context[1], sizeof(vkd3d_test_state.context) - 1, fmt, args); + va_end(args); + vkd3d_test_state.context[sizeof(vkd3d_test_state.context) - 1] = '\0'; +} + #define run_test(test_pfn) \ vkd3d_run_test(#test_pfn, test_pfn)
diff --git a/tests/d3d12.c b/tests/d3d12.c index 1598910718f4..03308639e4e1 100644 --- a/tests/d3d12.c +++ b/tests/d3d12.c @@ -18734,6 +18734,8 @@ static void test_instance_id(void)
for (i = 0; i < ARRAY_SIZE(tests); ++i) { + vkd3d_test_set_context("Test %u", i); + layout_desc[1].InstanceDataStepRate = tests[i].color_step_rate; input_layout.pInputElementDescs = layout_desc; input_layout.NumElements = ARRAY_SIZE(layout_desc); @@ -18784,6 +18786,7 @@ static void test_instance_id(void) ID3D12PipelineState_Release(context.pipeline_state); context.pipeline_state = NULL; } + vkd3d_test_set_context(NULL);
ID3D12CommandSignature_Release(command_signature); ID3D12Resource_Release(argument_buffer);