Skip to content

Commit

Permalink
Add test for _Halide_target_export_single_symbol (halide#6983)
Browse files Browse the repository at this point in the history
Add test for _Halide_target_export_single_symbol
  • Loading branch information
steven-johnson authored and ardier committed Mar 3, 2024
1 parent 5b31623 commit cdd2c90
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions python_bindings/test/generators/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,15 @@ endforeach ()
add_halide_python_extension_library(pyext_multi_method_module
MODULE_NAME multi_method_module
HALIDE_LIBRARIES py_aot_simple py_aot_user_context)

# Add a test to verify that Python extensions export exactly one symbol (the PyInit symbol)
# TODO: _Halide_target_export_single_symbol() isn't implemented for MSVC, and even if it was,
# this test wouldn't work for it, but for Posixy systems (Linux, OSX, etc) this is fine.
# See https://github.com/halide/Halide/issues/6982
if(NOT MSVC)
# Verify that only one symbol is exported, and that symbol is the one we expect
add_test(NAME test_export_single_symbol
COMMAND $ENV{SHELL} -c "[ $(nm $<TARGET_FILE:pyext_multi_method_module> | grep ' T ' | wc -l) -eq 1 ] && \
[ $(nm $<TARGET_FILE:pyext_multi_method_module> | grep ' T ' | grep PyInit_multi_method_module | wc -l) -eq 1 ]"
VERBATIM)
endif ()

0 comments on commit cdd2c90

Please sign in to comment.