Skip to content

Commit bdf2918

Browse files
committed
[UR] Add adapter leak-checking tests
1 parent 42874bc commit bdf2918

File tree

2 files changed

+41
-8
lines changed

2 files changed

+41
-8
lines changed

test/layers/validation/leaks.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,19 @@ TEST_F(urTest, testUrAdapterGetLeak) {
1111
ASSERT_NE(nullptr, adapter);
1212
}
1313

14+
TEST_F(urTest, testUrAdapterRetainLeak) {
15+
ur_adapter_handle_t adapter = nullptr;
16+
ASSERT_EQ(urAdapterGet(1, &adapter, nullptr), UR_RESULT_SUCCESS);
17+
ASSERT_NE(nullptr, adapter);
18+
ASSERT_EQ(urAdapterRetain(adapter), UR_RESULT_SUCCESS);
19+
}
20+
21+
TEST_F(urTest, testUrAdapterRetainNonexistent) {
22+
ur_adapter_handle_t adapter = (ur_adapter_handle_t)0xBEEF;
23+
ASSERT_EQ(urAdapterRetain(adapter), UR_RESULT_SUCCESS);
24+
ASSERT_NE(nullptr, adapter);
25+
}
26+
1427
TEST_F(valDeviceTest, testUrContextCreateLeak) {
1528
ur_context_handle_t context = nullptr;
1629
ASSERT_EQ(urContextCreate(1, &device, nullptr, &context),
Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,53 @@
1+
.*
2+
\[ RUN \] urTest.testUrAdapterGetLeak
13
<VALIDATION>\[DEBUG\]: Reference count for handle [0-9xa-fA-F]+ changed to 1
24
<VALIDATION>\[ERROR\]: Retained 1 reference\(s\) to handle [0-9xa-fA-F]+
35
<VALIDATION>\[ERROR\]: Handle [0-9xa-fA-F]+ was recorded for first time here:
4-
(.*)
6+
.*
7+
\[ RUN \] urTest.testUrAdapterRetainLeak
8+
<VALIDATION>\[DEBUG\]: Reference count for handle [0-9xa-fA-F]+ changed to 1
9+
<VALIDATION>\[DEBUG\]: Reference count for handle [0-9xa-fA-F]+ changed to 2
10+
<VALIDATION>\[ERROR\]: Retained 2 reference\(s\) to handle [0-9xa-fA-F]+
11+
<VALIDATION>\[ERROR\]: Handle [0-9xa-fA-F]+ was recorded for first time here:
12+
.*
13+
\[ RUN \] urTest.testUrAdapterRetainNonexistent
14+
<VALIDATION>\[ERROR\]: Attempting to retain nonexistent handle [0-9xa-fA-F]+
15+
.*
16+
\[ RUN \] valDeviceTest.testUrContextCreateLeak
517
<VALIDATION>\[DEBUG\]: Reference count for handle [0-9xa-fA-F]+ changed to 1
618
<VALIDATION>\[DEBUG\]: Reference count for handle [0-9xa-fA-F]+ changed to 1
719
<VALIDATION>\[DEBUG\]: Reference count for handle [0-9xa-fA-F]+ changed to 0
820
<VALIDATION>\[ERROR\]: Retained 1 reference\(s\) to handle [0-9xa-fA-F]+
921
<VALIDATION>\[ERROR\]: Handle [0-9xa-fA-F]+ was recorded for first time here:
10-
(.*)
22+
.*
23+
\[ RUN \] valDeviceTest.testUrContextRetainLeak
1124
<VALIDATION>\[DEBUG\]: Reference count for handle [0-9xa-fA-F]+ changed to 1
1225
<VALIDATION>\[DEBUG\]: Reference count for handle [0-9xa-fA-F]+ changed to 1
1326
<VALIDATION>\[DEBUG\]: Reference count for handle [0-9xa-fA-F]+ changed to 2
1427
<VALIDATION>\[DEBUG\]: Reference count for handle [0-9xa-fA-F]+ changed to 0
1528
<VALIDATION>\[ERROR\]: Retained 2 reference\(s\) to handle [0-9xa-fA-F]+
1629
<VALIDATION>\[ERROR\]: Handle [0-9xa-fA-F]+ was recorded for first time here:
17-
(.*)
30+
.*
31+
\[ RUN \] valDeviceTest.testUrContextRetainNonexistent
32+
<VALIDATION>\[DEBUG\]: Reference count for handle [0-9xa-fA-F]+ changed to 1
1833
<VALIDATION>\[ERROR\]: Attempting to retain nonexistent handle [0-9xa-fA-F]+
19-
(.*)
34+
<VALIDATION>\[DEBUG\]: Reference count for handle [0-9xa-fA-F]+ changed to 0
35+
.*
36+
\[ RUN \] valDeviceTest.testUrContextCreateSuccess
2037
<VALIDATION>\[DEBUG\]: Reference count for handle [0-9xa-fA-F]+ changed to 1
2138
<VALIDATION>\[DEBUG\]: Reference count for handle [0-9xa-fA-F]+ changed to 1
2239
<VALIDATION>\[DEBUG\]: Reference count for handle [0-9xa-fA-F]+ changed to 0
2340
<VALIDATION>\[DEBUG\]: Reference count for handle [0-9xa-fA-F]+ changed to 0
24-
(.*)
41+
.*
42+
\[ RUN \] valDeviceTest.testUrContextRetainSuccess
2543
<VALIDATION>\[DEBUG\]: Reference count for handle [0-9xa-fA-F]+ changed to 1
2644
<VALIDATION>\[DEBUG\]: Reference count for handle [0-9xa-fA-F]+ changed to 1
2745
<VALIDATION>\[DEBUG\]: Reference count for handle [0-9xa-fA-F]+ changed to 2
2846
<VALIDATION>\[DEBUG\]: Reference count for handle [0-9xa-fA-F]+ changed to 1
2947
<VALIDATION>\[DEBUG\]: Reference count for handle [0-9xa-fA-F]+ changed to 0
3048
<VALIDATION>\[DEBUG\]: Reference count for handle [0-9xa-fA-F]+ changed to 0
31-
(.*)
49+
.*
50+
\[ RUN \] valDeviceTest.testUrContextReleaseLeak
3251
<VALIDATION>\[DEBUG\]: Reference count for handle [0-9xa-fA-F]+ changed to 1
3352
<VALIDATION>\[DEBUG\]: Reference count for handle [0-9xa-fA-F]+ changed to 1
3453
<VALIDATION>\[DEBUG\]: Reference count for handle [0-9xa-fA-F]+ changed to 0
@@ -37,11 +56,12 @@
3756
<VALIDATION>\[DEBUG\]: Reference count for handle [0-9xa-fA-F]+ changed to 0
3857
<VALIDATION>\[ERROR\]: Retained -1 reference\(s\) to handle [0-9xa-fA-F]+
3958
<VALIDATION>\[ERROR\]: Handle [0-9xa-fA-F]+ was recorded for first time here:
40-
(.*)
59+
.*
60+
\[ RUN \] valDeviceTest.testUrContextReleaseNonexistent
4161
<VALIDATION>\[DEBUG\]: Reference count for handle [0-9xa-fA-F]+ changed to 1
4262
<VALIDATION>\[ERROR\]: Attempting to release nonexistent handle [0-9xa-fA-F]+
4363
<VALIDATION>\[DEBUG\]: Reference count for handle [0-9xa-fA-F]+ changed to -1
4464
<VALIDATION>\[DEBUG\]: Reference count for handle [0-9xa-fA-F]+ changed to 0
4565
<VALIDATION>\[ERROR\]: Retained -1 reference\(s\) to handle [0-9xa-fA-F]+
4666
<VALIDATION>\[ERROR\]: Handle [0-9xa-fA-F]+ was recorded for first time here:
47-
(.*)
67+
.*

0 commit comments

Comments
 (0)