xref: /aosp_15_r20/external/mesa3d/src/util/tests/perf/u_trace_test.cpp (revision 6104692788411f58d303aa86923a9ff6ecaded22)
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <gtest/gtest.h>
4 
5 #include "c11/threads.h"
6 #include "util/perf/u_trace.h"
7 
8 #define NUM_DEBUG_TEST_THREAD 8
9 
10 static int
test_thread(void * _state)11 test_thread(void *_state)
12 {
13    struct u_trace_context ctx = {};
14    u_trace_context_init(&ctx, NULL, 8, 0, NULL, NULL, NULL,
15                         NULL, NULL, NULL, NULL);
16    u_trace_context_fini(&ctx);
17 
18    return 0;
19 }
20 
TEST(UtilPerfTraceTest,Multithread)21 TEST(UtilPerfTraceTest, Multithread)
22 {
23    static char env_tracefile[] = "MESA_GPU_TRACEFILE=tracefile_for_test-b5ba5a0c-6ed1-4901-a38d-755991182663";
24    thrd_t threads[NUM_DEBUG_TEST_THREAD];
25    putenv(env_tracefile);
26    for (unsigned i = 0; i < NUM_DEBUG_TEST_THREAD; i++) {
27         thrd_create(&threads[i], test_thread, NULL);
28    }
29    for (unsigned i = 0; i < NUM_DEBUG_TEST_THREAD; i++) {
30       int ret;
31       thrd_join(threads[i], &ret);
32    }
33 }
34