Skip to content

Commit

Permalink
[UR] Add adapter leak-checking tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kswiecicki committed Nov 2, 2023
1 parent c053ce9 commit e31605c
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 8 deletions.
13 changes: 13 additions & 0 deletions test/layers/validation/leaks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,19 @@ TEST_F(urTest, testUrAdapterGetLeak) {
ASSERT_NE(nullptr, adapter);
}

TEST_F(urTest, testUrAdapterRetainLeak) {
ur_adapter_handle_t adapter = nullptr;
ASSERT_EQ(urAdapterGet(1, &adapter, nullptr), UR_RESULT_SUCCESS);
ASSERT_NE(nullptr, adapter);
ASSERT_EQ(urAdapterRetain(adapter), UR_RESULT_SUCCESS);
}

TEST_F(urTest, testUrAdapterRetainNonexistent) {
ur_adapter_handle_t adapter = (ur_adapter_handle_t)0xBEEF;
ASSERT_EQ(urAdapterRetain(adapter), UR_RESULT_SUCCESS);
ASSERT_NE(nullptr, adapter);
}

TEST_F(valDeviceTest, testUrContextCreateLeak) {
ur_context_handle_t context = nullptr;
ASSERT_EQ(urContextCreate(1, &device, nullptr, &context),
Expand Down
36 changes: 28 additions & 8 deletions test/layers/validation/leaks.out.match
Original file line number Diff line number Diff line change
@@ -1,34 +1,53 @@
.*
\[ RUN \] urTest.testUrAdapterGetLeak
<VALIDATION>\[DEBUG\]: Reference count for handle [0-9xa-fA-F]+ changed to 1
<VALIDATION>\[ERROR\]: Retained 1 reference\(s\) to handle [0-9xa-fA-F]+
<VALIDATION>\[ERROR\]: Handle [0-9xa-fA-F]+ was recorded for first time here:
(.*)
.*
\[ RUN \] urTest.testUrAdapterRetainLeak
<VALIDATION>\[DEBUG\]: Reference count for handle [0-9xa-fA-F]+ changed to 1
<VALIDATION>\[DEBUG\]: Reference count for handle [0-9xa-fA-F]+ changed to 2
<VALIDATION>\[ERROR\]: Retained 2 reference\(s\) to handle [0-9xa-fA-F]+
<VALIDATION>\[ERROR\]: Handle [0-9xa-fA-F]+ was recorded for first time here:
.*
\[ RUN \] urTest.testUrAdapterRetainNonexistent
<VALIDATION>\[ERROR\]: Attempting to retain nonexistent handle [0-9xa-fA-F]+
.*
\[ RUN \] valDeviceTest.testUrContextCreateLeak
<VALIDATION>\[DEBUG\]: Reference count for handle [0-9xa-fA-F]+ changed to 1
<VALIDATION>\[DEBUG\]: Reference count for handle [0-9xa-fA-F]+ changed to 1
<VALIDATION>\[DEBUG\]: Reference count for handle [0-9xa-fA-F]+ changed to 0
<VALIDATION>\[ERROR\]: Retained 1 reference\(s\) to handle [0-9xa-fA-F]+
<VALIDATION>\[ERROR\]: Handle [0-9xa-fA-F]+ was recorded for first time here:
(.*)
.*
\[ RUN \] valDeviceTest.testUrContextRetainLeak
<VALIDATION>\[DEBUG\]: Reference count for handle [0-9xa-fA-F]+ changed to 1
<VALIDATION>\[DEBUG\]: Reference count for handle [0-9xa-fA-F]+ changed to 1
<VALIDATION>\[DEBUG\]: Reference count for handle [0-9xa-fA-F]+ changed to 2
<VALIDATION>\[DEBUG\]: Reference count for handle [0-9xa-fA-F]+ changed to 0
<VALIDATION>\[ERROR\]: Retained 2 reference\(s\) to handle [0-9xa-fA-F]+
<VALIDATION>\[ERROR\]: Handle [0-9xa-fA-F]+ was recorded for first time here:
(.*)
.*
\[ RUN \] valDeviceTest.testUrContextRetainNonexistent
<VALIDATION>\[DEBUG\]: Reference count for handle [0-9xa-fA-F]+ changed to 1
<VALIDATION>\[ERROR\]: Attempting to retain nonexistent handle [0-9xa-fA-F]+
(.*)
<VALIDATION>\[DEBUG\]: Reference count for handle [0-9xa-fA-F]+ changed to 0
.*
\[ RUN \] valDeviceTest.testUrContextCreateSuccess
<VALIDATION>\[DEBUG\]: Reference count for handle [0-9xa-fA-F]+ changed to 1
<VALIDATION>\[DEBUG\]: Reference count for handle [0-9xa-fA-F]+ changed to 1
<VALIDATION>\[DEBUG\]: Reference count for handle [0-9xa-fA-F]+ changed to 0
<VALIDATION>\[DEBUG\]: Reference count for handle [0-9xa-fA-F]+ changed to 0
(.*)
.*
\[ RUN \] valDeviceTest.testUrContextRetainSuccess
<VALIDATION>\[DEBUG\]: Reference count for handle [0-9xa-fA-F]+ changed to 1
<VALIDATION>\[DEBUG\]: Reference count for handle [0-9xa-fA-F]+ changed to 1
<VALIDATION>\[DEBUG\]: Reference count for handle [0-9xa-fA-F]+ changed to 2
<VALIDATION>\[DEBUG\]: Reference count for handle [0-9xa-fA-F]+ changed to 1
<VALIDATION>\[DEBUG\]: Reference count for handle [0-9xa-fA-F]+ changed to 0
<VALIDATION>\[DEBUG\]: Reference count for handle [0-9xa-fA-F]+ changed to 0
(.*)
.*
\[ RUN \] valDeviceTest.testUrContextReleaseLeak
<VALIDATION>\[DEBUG\]: Reference count for handle [0-9xa-fA-F]+ changed to 1
<VALIDATION>\[DEBUG\]: Reference count for handle [0-9xa-fA-F]+ changed to 1
<VALIDATION>\[DEBUG\]: Reference count for handle [0-9xa-fA-F]+ changed to 0
Expand All @@ -37,11 +56,12 @@
<VALIDATION>\[DEBUG\]: Reference count for handle [0-9xa-fA-F]+ changed to 0
<VALIDATION>\[ERROR\]: Retained -1 reference\(s\) to handle [0-9xa-fA-F]+
<VALIDATION>\[ERROR\]: Handle [0-9xa-fA-F]+ was recorded for first time here:
(.*)
.*
\[ RUN \] valDeviceTest.testUrContextReleaseNonexistent
<VALIDATION>\[DEBUG\]: Reference count for handle [0-9xa-fA-F]+ changed to 1
<VALIDATION>\[ERROR\]: Attempting to release nonexistent handle [0-9xa-fA-F]+
<VALIDATION>\[DEBUG\]: Reference count for handle [0-9xa-fA-F]+ changed to -1
<VALIDATION>\[DEBUG\]: Reference count for handle [0-9xa-fA-F]+ changed to 0
<VALIDATION>\[ERROR\]: Retained -1 reference\(s\) to handle [0-9xa-fA-F]+
<VALIDATION>\[ERROR\]: Handle [0-9xa-fA-F]+ was recorded for first time here:
(.*)
.*

0 comments on commit e31605c

Please sign in to comment.