hasvk/tests: Link a single hasvk_tests binary using gtest

Acked-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24355>
This commit is contained in:
Caio Oliveira 2023-07-27 14:18:43 -07:00
parent 66d3b4a8b2
commit 27a66f70a5
8 changed files with 67 additions and 34 deletions

View file

@ -236,26 +236,34 @@ if with_tests
gnu_symbol_visibility : 'hidden', gnu_symbol_visibility : 'hidden',
) )
foreach t : ['block_pool_no_free', 'block_pool_grow_first', files_hasvk_tests = files(
'state_pool_no_free', 'state_pool_free_list_only', 'tests/hasvk_tests.cpp',
'state_pool', 'state_pool_padding']
test( 'tests/state_pool.c',
'anv_hasvk_@0@'.format(t), 'tests/state_pool_free_list_only.c',
executable( 'tests/state_pool_no_free.c',
t, 'tests/state_pool_padding.c',
['tests/@0@.c'.format(t), anv_hasvk_entrypoints[0]], 'tests/block_pool_no_free.c',
c_args : [ sse2_args ], 'tests/block_pool_grow_first.c',
link_with : libvulkan_intel_hasvk_test, )
dependencies : [
dep_libdrm, dep_thread, dep_m, dep_valgrind, test(
idep_vulkan_util, idep_vulkan_wsi_headers, 'hasvk_tests',
idep_vulkan_runtime, idep_intel_driver_ds, executable(
], 'hasvk_tests',
include_directories : [ [files_hasvk_tests, anv_hasvk_entrypoints[0]],
inc_include, inc_src, inc_intel, inc_compiler, c_args : [ sse2_args ],
], link_with : libvulkan_intel_hasvk_test,
), dependencies : [
suite : ['intel'], idep_gtest, dep_libdrm, dep_thread, dep_m, dep_valgrind,
) idep_vulkan_util, idep_vulkan_wsi_headers,
endforeach 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 endif

View file

@ -24,7 +24,9 @@
#include "anv_private.h" #include "anv_private.h"
#include "test_common.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 = { struct anv_physical_device physical_device = {
.use_softpin = true, .use_softpin = true,

View file

@ -30,7 +30,7 @@
#define BLOCKS_PER_THREAD 1024 #define BLOCKS_PER_THREAD 1024
#define NUM_RUNS 64 #define NUM_RUNS 64
struct job { static struct job {
pthread_t thread; pthread_t thread;
unsigned id; unsigned id;
struct anv_block_pool *pool; struct anv_block_pool *pool;
@ -146,7 +146,9 @@ static void run_test()
pthread_mutex_destroy(&device.mutex); 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++) for (unsigned i = 0; i < NUM_RUNS; i++)
run_test(); run_test();

View file

@ -0,0 +1,16 @@
/*
* Copyright © 2023 Intel Corporation
* SPDX-License-Identifier: MIT
*/
#include <gtest/gtest.h>
#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);

View file

@ -28,7 +28,9 @@
#include "state_pool_test_helper.h" #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 num_threads = 8;
const unsigned states_per_thread = 1 << 10; const unsigned states_per_thread = 1 << 10;

View file

@ -26,12 +26,11 @@
#include "anv_private.h" #include "anv_private.h"
#include "test_common.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" #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 num_threads = 8;
const unsigned states_per_thread = 1 << 12; const unsigned states_per_thread = 1 << 12;

View file

@ -30,14 +30,14 @@
#define STATES_PER_THREAD 1024 #define STATES_PER_THREAD 1024
#define NUM_RUNS 64 #define NUM_RUNS 64
struct job { static struct job {
pthread_t thread; pthread_t thread;
unsigned id; unsigned id;
struct anv_state_pool *pool; struct anv_state_pool *pool;
uint32_t offsets[STATES_PER_THREAD]; uint32_t offsets[STATES_PER_THREAD];
} jobs[NUM_THREADS]; } jobs[NUM_THREADS];
pthread_barrier_t barrier; static pthread_barrier_t barrier;
static void *alloc_states(void *_job) static void *alloc_states(void *_job)
{ {
@ -112,7 +112,9 @@ static void run_test()
pthread_mutex_destroy(&device.mutex); 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++) for (unsigned i = 0; i < NUM_RUNS; i++)
run_test(); run_test();

View file

@ -24,7 +24,9 @@
#include "anv_private.h" #include "anv_private.h"
#include "test_common.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 = { struct anv_physical_device physical_device = {
.use_softpin = true, .use_softpin = true,