Skip to content
This repository was archived by the owner on Jan 6, 2025. It is now read-only.

Commit bdb31e3

Browse files
committed
More cmdline filter test cases
1 parent 51ef411 commit bdb31e3

File tree

2 files changed

+27
-4
lines changed

2 files changed

+27
-4
lines changed

test/CMakeLists.txt

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,12 +165,10 @@ add_test(NAME "filter_none"
165165
set_tests_properties("filter_none"
166166
PROPERTIES PASS_REGULAR_EXPRESSION "hooked - allowed")
167167

168-
get_filename_component(filter_test_filename $<TARGET_FILE:filter_test> NAME)
169-
170168
add_test(NAME "filter_positive"
171169
COMMAND ${CMAKE_COMMAND}
172170
-DTEST_EXTRA_PRELOAD=${TEST_EXTRA_PRELOAD}
173-
-DFILTER=${filter_test_filename}
171+
-DFILTER=$<TARGET_FILE_NAME:filter_test>
174172
-DTEST_PROG=$<TARGET_FILE:filter_test>
175173
-P ${CMAKE_CURRENT_SOURCE_DIR}/check.cmake)
176174
set_tests_properties("filter_positive"
@@ -185,6 +183,26 @@ add_test(NAME "filter_negative"
185183
set_tests_properties("filter_negative"
186184
PROPERTIES PASS_REGULAR_EXPRESSION "disallowed")
187185

186+
# the filter is a substring of the executable name
187+
add_test(NAME "filter_negative_substring0"
188+
COMMAND ${CMAKE_COMMAND}
189+
-DTEST_EXTRA_PRELOAD=${TEST_EXTRA_PRELOAD}
190+
-DFILTER_PLUS_ONECHAR=$<TARGET_FILE_NAME:filter_test>
191+
-DTEST_PROG=$<TARGET_FILE:filter_test>
192+
-P ${CMAKE_CURRENT_SOURCE_DIR}/check.cmake)
193+
set_tests_properties("filter_negative_substring0"
194+
PROPERTIES PASS_REGULAR_EXPRESSION "disallowed")
195+
196+
# the executable name is a substring of the filter
197+
add_test(NAME "filter_negative_substring1"
198+
COMMAND ${CMAKE_COMMAND}
199+
-DTEST_EXTRA_PRELOAD=${TEST_EXTRA_PRELOAD}
200+
-DFILTER=A$<TARGET_FILE_NAME:filter_test>
201+
-DTEST_PROG=$<TARGET_FILE:filter_test>
202+
-P ${CMAKE_CURRENT_SOURCE_DIR}/check.cmake)
203+
set_tests_properties("filter_negative_substring1"
204+
PROPERTIES PASS_REGULAR_EXPRESSION "disallowed")
205+
188206
add_executable(test_clone_thread test_clone_thread.c)
189207
target_link_libraries(test_clone_thread PRIVATE ${CMAKE_THREAD_LIBS_INIT})
190208
add_library(test_clone_thread_preload SHARED test_clone_thread_preload.c)

test/check.cmake

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,13 @@
3030
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3131

3232

33+
if(FILTER_PLUS_ONECHAR)
34+
string(SUBSTRING "${FILTER_PLUS_ONECHAR}" 1 -1 FILTER)
35+
endif()
36+
3337
if(FILTER)
34-
set(ENV{INTERCEPT_HOOK_CMDLINE_FILTER} ${FILTER})
38+
set(ENV{INTERCEPT_HOOK_CMDLINE_FILTER} ${FILTER})
39+
message("FILTER: ${FILTER}")
3540
endif()
3641

3742
if(LIB_FILE)

0 commit comments

Comments
 (0)