Skip to content

Commit

Permalink
Refactor leak checking match tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kswiecicki committed Jan 10, 2024
1 parent 0289192 commit 876ba5b
Show file tree
Hide file tree
Showing 3 changed files with 187 additions and 163 deletions.
41 changes: 29 additions & 12 deletions test/layers/validation/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,49 @@
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

set(UR_VALIDATION_TEST_DIR ${CMAKE_CURRENT_SOURCE_DIR})
set(VAL_TEST_PREFIX validation_test)

function(add_validation_test name)
set(TEST_TARGET_NAME validation_test-${name})
add_ur_executable(${TEST_TARGET_NAME}
function(add_validation_test_executable name)
add_ur_executable(${VAL_TEST_PREFIX}-${name}
${ARGN})
target_link_libraries(${TEST_TARGET_NAME}
target_link_libraries(${VAL_TEST_PREFIX}-${name}
PRIVATE
${PROJECT_NAME}::loader
${PROJECT_NAME}::headers
${PROJECT_NAME}::testing
GTest::gtest_main)
add_test(NAME ${name}
COMMAND ${TEST_TARGET_NAME}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
endfunction()

function(set_validation_test_properties name)
set_tests_properties(${name} PROPERTIES LABELS "validation")
set_property(TEST ${name} PROPERTY ENVIRONMENT
"UR_ENABLE_LAYERS=UR_LAYER_FULL_VALIDATION"
"UR_ADAPTERS_FORCE_LOAD=\"$<TARGET_FILE:ur_adapter_null>\""
"UR_LOG_VALIDATION=level:debug\;flush:debug\;output:stdout")
endfunction()

function(add_validation_match_test name match_file)
add_validation_test(${name} ${ARGN})
file(READ ${match_file} MATCH_STRING)
set_tests_properties(${name} PROPERTIES
PASS_REGULAR_EXPRESSION "${MATCH_STRING}")
function(add_validation_test name)
add_validation_test_executable(${name} ${ARGN})

add_test(NAME ${name}
COMMAND ${VAL_TEST_PREFIX}-${name}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})

set_validation_test_properties(${name})
endfunction()

function(add_validation_match_test name)
add_validation_test_executable(${name} ${ARGN})

add_test(NAME ${name}
COMMAND ${CMAKE_COMMAND}
-D MODE=stdout
-D TEST_FILE=$<TARGET_FILE:${VAL_TEST_PREFIX}-${name}>
-D MATCH_FILE=${CMAKE_CURRENT_SOURCE_DIR}/${name}.out.match
-P ${PROJECT_SOURCE_DIR}/cmake/match.cmake
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})

set_validation_test_properties(${name})
endfunction()

add_validation_test(parameters parameters.cpp)
Expand Down
134 changes: 67 additions & 67 deletions test/layers/validation/leaks.out.match
Original file line number Diff line number Diff line change
@@ -1,67 +1,67 @@
.*
\[ 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
<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:
.*
\[ 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:
.*
{{IGNORE}}
[ 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:
{{IGNORE}}
[ 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:
{{IGNORE}}
[ RUN ] urTest.testUrAdapterRetainNonexistent
<VALIDATION>[ERROR]: Attempting to retain nonexistent handle {{[0-9xa-fA-F]+}}
{{IGNORE}}
[ 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:
{{IGNORE}}
[ 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:
{{IGNORE}}
[ 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
{{IGNORE}}
[ 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
{{IGNORE}}
[ 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
{{IGNORE}}
[ 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
<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:
{{IGNORE}}
[ 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:
{{IGNORE}}
Loading

0 comments on commit 876ba5b

Please sign in to comment.