From 27a66f70a5b14eeda874c72a0f965d145ab8ab75 Mon Sep 17 00:00:00 2001 From: Caio Oliveira Date: Thu, 27 Jul 2023 14:18:43 -0700 Subject: [PATCH] hasvk/tests: Link a single hasvk_tests binary using gtest Acked-by: Lionel Landwerlin Part-of: --- src/intel/vulkan_hasvk/meson.build | 52 +++++++++++++--------- .../vulkan_hasvk/tests/block_pool_grow_first.c | 4 +- src/intel/vulkan_hasvk/tests/block_pool_no_free.c | 6 ++- src/intel/vulkan_hasvk/tests/hasvk_tests.cpp | 16 +++++++ src/intel/vulkan_hasvk/tests/state_pool.c | 4 +- .../vulkan_hasvk/tests/state_pool_free_list_only.c | 7 ++- src/intel/vulkan_hasvk/tests/state_pool_no_free.c | 8 ++-- src/intel/vulkan_hasvk/tests/state_pool_padding.c | 4 +- 8 files changed, 67 insertions(+), 34 deletions(-) create mode 100644 src/intel/vulkan_hasvk/tests/hasvk_tests.cpp diff --git a/src/intel/vulkan_hasvk/meson.build b/src/intel/vulkan_hasvk/meson.build index 612fa41..7c1b719 100644 --- a/src/intel/vulkan_hasvk/meson.build +++ b/src/intel/vulkan_hasvk/meson.build @@ -236,26 +236,34 @@ if with_tests gnu_symbol_visibility : 'hidden', ) - foreach t : ['block_pool_no_free', 'block_pool_grow_first', - 'state_pool_no_free', 'state_pool_free_list_only', - 'state_pool', 'state_pool_padding'] - test( - 'anv_hasvk_@0@'.format(t), - executable( - t, - ['tests/@0@.c'.format(t), anv_hasvk_entrypoints[0]], - c_args : [ sse2_args ], - link_with : libvulkan_intel_hasvk_test, - dependencies : [ - dep_libdrm, dep_thread, dep_m, dep_valgrind, - idep_vulkan_util, idep_vulkan_wsi_headers, - idep_vulkan_runtime, idep_intel_driver_ds, - ], - include_directories : [ - inc_include, inc_src, inc_intel, inc_compiler, - ], - ), - suite : ['intel'], - ) - endforeach + files_hasvk_tests = files( + 'tests/hasvk_tests.cpp', + + 'tests/state_pool.c', + 'tests/state_pool_free_list_only.c', + 'tests/state_pool_no_free.c', + 'tests/state_pool_padding.c', + 'tests/block_pool_no_free.c', + 'tests/block_pool_grow_first.c', + ) + + test( + 'hasvk_tests', + executable( + 'hasvk_tests', + [files_hasvk_tests, anv_hasvk_entrypoints[0]], + c_args : [ sse2_args ], + link_with : libvulkan_intel_hasvk_test, + dependencies : [ + idep_gtest, dep_libdrm, dep_thread, dep_m, dep_valgrind, + idep_vulkan_util, idep_vulkan_wsi_headers, + idep_vulkan_runtime, idep_intel_driver_ds, idep_intel_dev, + ], + include_directories : [ + inc_include, inc_src, inc_intel, inc_compiler, + ], + ), + suite : ['intel'], + protocol : 'gtest', + ) endif diff --git a/src/intel/vulkan_hasvk/tests/block_pool_grow_first.c b/src/intel/vulkan_hasvk/tests/block_pool_grow_first.c index 109275b..76dced0 100644 --- a/src/intel/vulkan_hasvk/tests/block_pool_grow_first.c +++ b/src/intel/vulkan_hasvk/tests/block_pool_grow_first.c @@ -24,7 +24,9 @@ #include "anv_private.h" #include "test_common.h" -int main(void) +void block_pool_grow_first_test(void); + +void block_pool_grow_first_test(void) { struct anv_physical_device physical_device = { .use_softpin = true, diff --git a/src/intel/vulkan_hasvk/tests/block_pool_no_free.c b/src/intel/vulkan_hasvk/tests/block_pool_no_free.c index e0e24dc..5272887 100644 --- a/src/intel/vulkan_hasvk/tests/block_pool_no_free.c +++ b/src/intel/vulkan_hasvk/tests/block_pool_no_free.c @@ -30,7 +30,7 @@ #define BLOCKS_PER_THREAD 1024 #define NUM_RUNS 64 -struct job { +static struct job { pthread_t thread; unsigned id; struct anv_block_pool *pool; @@ -146,7 +146,9 @@ static void run_test() pthread_mutex_destroy(&device.mutex); } -int main(void) +void block_pool_no_free_test(void); + +void block_pool_no_free_test(void) { for (unsigned i = 0; i < NUM_RUNS; i++) run_test(); diff --git a/src/intel/vulkan_hasvk/tests/hasvk_tests.cpp b/src/intel/vulkan_hasvk/tests/hasvk_tests.cpp new file mode 100644 index 0000000..284f485 --- /dev/null +++ b/src/intel/vulkan_hasvk/tests/hasvk_tests.cpp @@ -0,0 +1,16 @@ +/* + * Copyright © 2023 Intel Corporation + * SPDX-License-Identifier: MIT + */ + +#include + +#define HASVK_C_TEST(S, N, C) extern "C" void C(void); TEST(S, N) { C(); } + +HASVK_C_TEST(StatePool, Regular, state_pool_test); +HASVK_C_TEST(StatePool, FreeListOnly, state_pool_free_list_only_test); +HASVK_C_TEST(StatePool, NoFree, state_pool_no_free_test); +HASVK_C_TEST(StatePool, Padding, state_pool_padding_test); + +HASVK_C_TEST(BlockPool, NoFree, block_pool_no_free_test); +HASVK_C_TEST(BlockPool, GrowFirst, block_pool_grow_first_test); diff --git a/src/intel/vulkan_hasvk/tests/state_pool.c b/src/intel/vulkan_hasvk/tests/state_pool.c index 88440ab..0fe0d3c 100644 --- a/src/intel/vulkan_hasvk/tests/state_pool.c +++ b/src/intel/vulkan_hasvk/tests/state_pool.c @@ -28,7 +28,9 @@ #include "state_pool_test_helper.h" -int main(void) +void state_pool_test(void); + +void state_pool_test(void) { const unsigned num_threads = 8; const unsigned states_per_thread = 1 << 10; diff --git a/src/intel/vulkan_hasvk/tests/state_pool_free_list_only.c b/src/intel/vulkan_hasvk/tests/state_pool_free_list_only.c index 8c01502..47082ff 100644 --- a/src/intel/vulkan_hasvk/tests/state_pool_free_list_only.c +++ b/src/intel/vulkan_hasvk/tests/state_pool_free_list_only.c @@ -26,12 +26,11 @@ #include "anv_private.h" #include "test_common.h" -#define STATES_PER_THREAD_LOG2 12 -#define STATES_PER_THREAD (1 << STATES_PER_THREAD_LOG2) - #include "state_pool_test_helper.h" -int main(void) +void state_pool_free_list_only_test(void); + +void state_pool_free_list_only_test(void) { const unsigned num_threads = 8; const unsigned states_per_thread = 1 << 12; diff --git a/src/intel/vulkan_hasvk/tests/state_pool_no_free.c b/src/intel/vulkan_hasvk/tests/state_pool_no_free.c index fe07683..e8bbb74 100644 --- a/src/intel/vulkan_hasvk/tests/state_pool_no_free.c +++ b/src/intel/vulkan_hasvk/tests/state_pool_no_free.c @@ -30,14 +30,14 @@ #define STATES_PER_THREAD 1024 #define NUM_RUNS 64 -struct job { +static struct job { pthread_t thread; unsigned id; struct anv_state_pool *pool; uint32_t offsets[STATES_PER_THREAD]; } jobs[NUM_THREADS]; -pthread_barrier_t barrier; +static pthread_barrier_t barrier; static void *alloc_states(void *_job) { @@ -112,7 +112,9 @@ static void run_test() pthread_mutex_destroy(&device.mutex); } -int main(void) +void state_pool_no_free_test(void); + +void state_pool_no_free_test(void) { for (unsigned i = 0; i < NUM_RUNS; i++) run_test(); diff --git a/src/intel/vulkan_hasvk/tests/state_pool_padding.c b/src/intel/vulkan_hasvk/tests/state_pool_padding.c index 0ed72e1..72754e3 100644 --- a/src/intel/vulkan_hasvk/tests/state_pool_padding.c +++ b/src/intel/vulkan_hasvk/tests/state_pool_padding.c @@ -24,7 +24,9 @@ #include "anv_private.h" #include "test_common.h" -int main(void) +void state_pool_padding_test(void); + +void state_pool_padding_test(void) { struct anv_physical_device physical_device = { .use_softpin = true, -- 2.7.4