Skip to content

Commit 2e10197

Browse files
committed
Refactor leak checking match tests
1 parent d6930c7 commit 2e10197

File tree

3 files changed

+187
-163
lines changed

3 files changed

+187
-163
lines changed

test/layers/validation/CMakeLists.txt

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,32 +4,49 @@
44
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
55

66
set(UR_VALIDATION_TEST_DIR ${CMAKE_CURRENT_SOURCE_DIR})
7+
set(VAL_TEST_PREFIX validation_test)
78

8-
function(add_validation_test name)
9-
set(TEST_TARGET_NAME validation_test-${name})
10-
add_ur_executable(${TEST_TARGET_NAME}
9+
function(add_validation_test_executable name)
10+
add_ur_executable(${VAL_TEST_PREFIX}-${name}
1111
${ARGN})
12-
target_link_libraries(${TEST_TARGET_NAME}
12+
target_link_libraries(${VAL_TEST_PREFIX}-${name}
1313
PRIVATE
1414
${PROJECT_NAME}::loader
1515
${PROJECT_NAME}::headers
1616
${PROJECT_NAME}::testing
1717
GTest::gtest_main)
18-
add_test(NAME ${name}
19-
COMMAND ${TEST_TARGET_NAME}
20-
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
18+
endfunction()
19+
20+
function(set_validation_test_properties name)
2121
set_tests_properties(${name} PROPERTIES LABELS "validation")
2222
set_property(TEST ${name} PROPERTY ENVIRONMENT
2323
"UR_ENABLE_LAYERS=UR_LAYER_FULL_VALIDATION"
2424
"UR_ADAPTERS_FORCE_LOAD=\"$<TARGET_FILE:ur_adapter_null>\""
2525
"UR_LOG_VALIDATION=level:debug\;flush:debug\;output:stdout")
2626
endfunction()
2727

28-
function(add_validation_match_test name match_file)
29-
add_validation_test(${name} ${ARGN})
30-
file(READ ${match_file} MATCH_STRING)
31-
set_tests_properties(${name} PROPERTIES
32-
PASS_REGULAR_EXPRESSION "${MATCH_STRING}")
28+
function(add_validation_test name)
29+
add_validation_test_executable(${name} ${ARGN})
30+
31+
add_test(NAME ${name}
32+
COMMAND ${VAL_TEST_PREFIX}-${name}
33+
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
34+
35+
set_validation_test_properties(${name})
36+
endfunction()
37+
38+
function(add_validation_match_test name)
39+
add_validation_test_executable(${name} ${ARGN})
40+
41+
add_test(NAME ${name}
42+
COMMAND ${CMAKE_COMMAND}
43+
-D MODE=stdout
44+
-D TEST_FILE=$<TARGET_FILE:${VAL_TEST_PREFIX}-${name}>
45+
-D MATCH_FILE=${CMAKE_CURRENT_SOURCE_DIR}/${name}.out.match
46+
-P ${PROJECT_SOURCE_DIR}/cmake/match.cmake
47+
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
48+
49+
set_validation_test_properties(${name})
3350
endfunction()
3451

3552
add_validation_test(parameters parameters.cpp)
Lines changed: 67 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,67 @@
1-
.*
2-
\[ RUN \] urTest.testUrAdapterGetLeak
3-
<VALIDATION>\[DEBUG\]: Reference count for handle [0-9xa-fA-F]+ changed to 1
4-
<VALIDATION>\[ERROR\]: Retained 1 reference\(s\) to handle [0-9xa-fA-F]+
5-
<VALIDATION>\[ERROR\]: Handle [0-9xa-fA-F]+ was recorded for first time here:
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
17-
<VALIDATION>\[DEBUG\]: Reference count for handle [0-9xa-fA-F]+ changed to 1
18-
<VALIDATION>\[DEBUG\]: Reference count for handle [0-9xa-fA-F]+ changed to 1
19-
<VALIDATION>\[DEBUG\]: Reference count for handle [0-9xa-fA-F]+ changed to 0
20-
<VALIDATION>\[ERROR\]: Retained 1 reference\(s\) to handle [0-9xa-fA-F]+
21-
<VALIDATION>\[ERROR\]: Handle [0-9xa-fA-F]+ was recorded for first time here:
22-
.*
23-
\[ RUN \] valDeviceTest.testUrContextRetainLeak
24-
<VALIDATION>\[DEBUG\]: Reference count for handle [0-9xa-fA-F]+ changed to 1
25-
<VALIDATION>\[DEBUG\]: Reference count for handle [0-9xa-fA-F]+ changed to 1
26-
<VALIDATION>\[DEBUG\]: Reference count for handle [0-9xa-fA-F]+ changed to 2
27-
<VALIDATION>\[DEBUG\]: Reference count for handle [0-9xa-fA-F]+ changed to 0
28-
<VALIDATION>\[ERROR\]: Retained 2 reference\(s\) to handle [0-9xa-fA-F]+
29-
<VALIDATION>\[ERROR\]: Handle [0-9xa-fA-F]+ was recorded for first time here:
30-
.*
31-
\[ RUN \] valDeviceTest.testUrContextRetainNonexistent
32-
<VALIDATION>\[DEBUG\]: Reference count for handle [0-9xa-fA-F]+ changed to 1
33-
<VALIDATION>\[ERROR\]: Attempting to retain nonexistent handle [0-9xa-fA-F]+
34-
<VALIDATION>\[DEBUG\]: Reference count for handle [0-9xa-fA-F]+ changed to 0
35-
.*
36-
\[ RUN \] valDeviceTest.testUrContextCreateSuccess
37-
<VALIDATION>\[DEBUG\]: Reference count for handle [0-9xa-fA-F]+ changed to 1
38-
<VALIDATION>\[DEBUG\]: Reference count for handle [0-9xa-fA-F]+ changed to 1
39-
<VALIDATION>\[DEBUG\]: Reference count for handle [0-9xa-fA-F]+ changed to 0
40-
<VALIDATION>\[DEBUG\]: Reference count for handle [0-9xa-fA-F]+ changed to 0
41-
.*
42-
\[ RUN \] valDeviceTest.testUrContextRetainSuccess
43-
<VALIDATION>\[DEBUG\]: Reference count for handle [0-9xa-fA-F]+ changed to 1
44-
<VALIDATION>\[DEBUG\]: Reference count for handle [0-9xa-fA-F]+ changed to 1
45-
<VALIDATION>\[DEBUG\]: Reference count for handle [0-9xa-fA-F]+ changed to 2
46-
<VALIDATION>\[DEBUG\]: Reference count for handle [0-9xa-fA-F]+ changed to 1
47-
<VALIDATION>\[DEBUG\]: Reference count for handle [0-9xa-fA-F]+ changed to 0
48-
<VALIDATION>\[DEBUG\]: Reference count for handle [0-9xa-fA-F]+ changed to 0
49-
.*
50-
\[ RUN \] valDeviceTest.testUrContextReleaseLeak
51-
<VALIDATION>\[DEBUG\]: Reference count for handle [0-9xa-fA-F]+ changed to 1
52-
<VALIDATION>\[DEBUG\]: Reference count for handle [0-9xa-fA-F]+ changed to 1
53-
<VALIDATION>\[DEBUG\]: Reference count for handle [0-9xa-fA-F]+ changed to 0
54-
<VALIDATION>\[ERROR\]: Attempting to release nonexistent handle [0-9xa-fA-F]+
55-
<VALIDATION>\[DEBUG\]: Reference count for handle [0-9xa-fA-F]+ changed to -1
56-
<VALIDATION>\[DEBUG\]: Reference count for handle [0-9xa-fA-F]+ changed to 0
57-
<VALIDATION>\[ERROR\]: Retained -1 reference\(s\) to handle [0-9xa-fA-F]+
58-
<VALIDATION>\[ERROR\]: Handle [0-9xa-fA-F]+ was recorded for first time here:
59-
.*
60-
\[ RUN \] valDeviceTest.testUrContextReleaseNonexistent
61-
<VALIDATION>\[DEBUG\]: Reference count for handle [0-9xa-fA-F]+ changed to 1
62-
<VALIDATION>\[ERROR\]: Attempting to release nonexistent handle [0-9xa-fA-F]+
63-
<VALIDATION>\[DEBUG\]: Reference count for handle [0-9xa-fA-F]+ changed to -1
64-
<VALIDATION>\[DEBUG\]: Reference count for handle [0-9xa-fA-F]+ changed to 0
65-
<VALIDATION>\[ERROR\]: Retained -1 reference\(s\) to handle [0-9xa-fA-F]+
66-
<VALIDATION>\[ERROR\]: Handle [0-9xa-fA-F]+ was recorded for first time here:
67-
.*
1+
{{IGNORE}}
2+
[ RUN ] urTest.testUrAdapterGetLeak
3+
<VALIDATION>[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1
4+
<VALIDATION>[ERROR]: Retained 1 reference(s) to handle {{[0-9xa-fA-F]+}}
5+
<VALIDATION>[ERROR]: Handle {{[0-9xa-fA-F]+}} was recorded for first time here:
6+
{{IGNORE}}
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+
{{IGNORE}}
13+
[ RUN ] urTest.testUrAdapterRetainNonexistent
14+
<VALIDATION>[ERROR]: Attempting to retain nonexistent handle {{[0-9xa-fA-F]+}}
15+
{{IGNORE}}
16+
[ RUN ] valDeviceTest.testUrContextCreateLeak
17+
<VALIDATION>[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1
18+
<VALIDATION>[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1
19+
<VALIDATION>[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 0
20+
<VALIDATION>[ERROR]: Retained 1 reference(s) to handle {{[0-9xa-fA-F]+}}
21+
<VALIDATION>[ERROR]: Handle {{[0-9xa-fA-F]+}} was recorded for first time here:
22+
{{IGNORE}}
23+
[ RUN ] valDeviceTest.testUrContextRetainLeak
24+
<VALIDATION>[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1
25+
<VALIDATION>[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1
26+
<VALIDATION>[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 2
27+
<VALIDATION>[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 0
28+
<VALIDATION>[ERROR]: Retained 2 reference(s) to handle {{[0-9xa-fA-F]+}}
29+
<VALIDATION>[ERROR]: Handle {{[0-9xa-fA-F]+}} was recorded for first time here:
30+
{{IGNORE}}
31+
[ RUN ] valDeviceTest.testUrContextRetainNonexistent
32+
<VALIDATION>[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1
33+
<VALIDATION>[ERROR]: Attempting to retain nonexistent handle {{[0-9xa-fA-F]+}}
34+
<VALIDATION>[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 0
35+
{{IGNORE}}
36+
[ RUN ] valDeviceTest.testUrContextCreateSuccess
37+
<VALIDATION>[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1
38+
<VALIDATION>[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1
39+
<VALIDATION>[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 0
40+
<VALIDATION>[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 0
41+
{{IGNORE}}
42+
[ RUN ] valDeviceTest.testUrContextRetainSuccess
43+
<VALIDATION>[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1
44+
<VALIDATION>[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1
45+
<VALIDATION>[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 2
46+
<VALIDATION>[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1
47+
<VALIDATION>[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 0
48+
<VALIDATION>[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 0
49+
{{IGNORE}}
50+
[ RUN ] valDeviceTest.testUrContextReleaseLeak
51+
<VALIDATION>[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1
52+
<VALIDATION>[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1
53+
<VALIDATION>[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 0
54+
<VALIDATION>[ERROR]: Attempting to release nonexistent handle {{[0-9xa-fA-F]+}}
55+
<VALIDATION>[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to -1
56+
<VALIDATION>[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 0
57+
<VALIDATION>[ERROR]: Retained -1 reference(s) to handle {{[0-9xa-fA-F]+}}
58+
<VALIDATION>[ERROR]: Handle {{[0-9xa-fA-F]+}} was recorded for first time here:
59+
{{IGNORE}}
60+
[ RUN ] valDeviceTest.testUrContextReleaseNonexistent
61+
<VALIDATION>[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1
62+
<VALIDATION>[ERROR]: Attempting to release nonexistent handle {{[0-9xa-fA-F]+}}
63+
<VALIDATION>[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to -1
64+
<VALIDATION>[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 0
65+
<VALIDATION>[ERROR]: Retained -1 reference(s) to handle {{[0-9xa-fA-F]+}}
66+
<VALIDATION>[ERROR]: Handle {{[0-9xa-fA-F]+}} was recorded for first time here:
67+
{{IGNORE}}

0 commit comments

Comments
 (0)