From 96f9b1b7717a07337b5f2c00a7c9fe2322e90b6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B3zef=20Kucia?= Date: Tue, 4 Dec 2018 15:56:02 +0100 Subject: [PATCH] tests: Introduce parse_args() helper function. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Józef Kucia Signed-off-by: Henri Verbeet Signed-off-by: Alexandre Julliard --- tests/d3d12.c | 21 +-------------------- tests/d3d12_crosstest.h | 23 +++++++++++++++++++++++ tests/d3d12_invalid_usage.c | 21 +-------------------- 3 files changed, 25 insertions(+), 40 deletions(-) diff --git a/tests/d3d12.c b/tests/d3d12.c index 3123018a..aee2ccca 100644 --- a/tests/d3d12.c +++ b/tests/d3d12.c @@ -21809,26 +21809,7 @@ static void test_primitive_restart(void) START_TEST(d3d12) { - bool enable_debug_layer = false; - ID3D12Debug *debug; - unsigned int i; - - for (i = 1; i < argc; ++i) - { - if (!strcmp(argv[i], "--validate")) - enable_debug_layer = true; - else if (!strcmp(argv[i], "--warp")) - use_warp_device = true; - else if (!strcmp(argv[i], "--adapter") && i + 1 < argc) - use_adapter_idx = atoi(argv[++i]); - } - - if (enable_debug_layer && SUCCEEDED(D3D12GetDebugInterface(&IID_ID3D12Debug, (void **)&debug))) - { - ID3D12Debug_EnableDebugLayer(debug); - ID3D12Debug_Release(debug); - } - + parse_args(argc, argv); print_adapter_info(); run_test(test_create_device); diff --git a/tests/d3d12_crosstest.h b/tests/d3d12_crosstest.h index ddba9fea..8f522e88 100644 --- a/tests/d3d12_crosstest.h +++ b/tests/d3d12_crosstest.h @@ -316,4 +316,27 @@ static ID3D12Device *create_device(void) return SUCCEEDED(hr) ? device : NULL; } +static void parse_args(int argc, char **argv) +{ + bool enable_debug_layer = false; + ID3D12Debug *debug; + unsigned int i; + + for (i = 1; i < argc; ++i) + { + if (!strcmp(argv[i], "--validate")) + enable_debug_layer = true; + else if (!strcmp(argv[i], "--warp")) + use_warp_device = true; + else if (!strcmp(argv[i], "--adapter") && i + 1 < argc) + use_adapter_idx = atoi(argv[++i]); + } + + if (enable_debug_layer && SUCCEEDED(D3D12GetDebugInterface(&IID_ID3D12Debug, (void **)&debug))) + { + ID3D12Debug_EnableDebugLayer(debug); + ID3D12Debug_Release(debug); + } +} + #endif /* __VKD3D_D3D12_CROSSTEST_H */ diff --git a/tests/d3d12_invalid_usage.c b/tests/d3d12_invalid_usage.c index ce354b8a..40935428 100644 --- a/tests/d3d12_invalid_usage.c +++ b/tests/d3d12_invalid_usage.c @@ -152,26 +152,7 @@ static void test_invalid_texture_resource_barriers(void) START_TEST(d3d12_invalid_usage) { - bool enable_debug_layer = false; - ID3D12Debug *debug; - unsigned int i; - - for (i = 1; i < argc; ++i) - { - if (!strcmp(argv[i], "--validate")) - enable_debug_layer = true; - else if (!strcmp(argv[i], "--warp")) - use_warp_device = true; - else if (!strcmp(argv[i], "--adapter") && i + 1 < argc) - use_adapter_idx = atoi(argv[++i]); - } - - if (enable_debug_layer && SUCCEEDED(D3D12GetDebugInterface(&IID_ID3D12Debug, (void **)&debug))) - { - ID3D12Debug_EnableDebugLayer(debug); - ID3D12Debug_Release(debug); - } - + parse_args(argc, argv); print_adapter_info(); run_test(test_invalid_texture_resource_barriers);