Skip to content
Snippets Groups Projects
Commit df1d8097 authored by Julien Malik's avatar Julien Malik
Browse files

TEST: verify that otbopenjpeg only exports mangled symbols

parent 59457d51
No related branches found
No related tags found
No related merge requests found
......@@ -525,9 +525,20 @@ classifyKNN2.cxx
)
#IF(OTB_COMPILE_JPEG2000)
IF(OTB_COMPILE_JPEG2000)
# SET(UtilitiesTests_SRCS ${UtilitiesTests_SRCS} openJpegEncoder.cxx openJpegDecoder.cxx)
#ENDIF(OTB_COMPILE_JPEG2000)
IF (UNIX AND OPJ_MANGLE_PREFIX)
# Rely on "nm" for this test, so enable it only on Unix platform
ADD_TEST(NAME utTvOpenJpegMangling
COMMAND ${CMAKE_COMMAND}
-DOPJ_TARGET_PATH=$<TARGET_FILE:otbopenjpeg>
-DOPJ_MANGLE_PREFIX=${OPJ_MANGLE_PREFIX}
-P ${CMAKE_CURRENT_SOURCE_DIR}/TestOpenJPEGMangling.cmake)
ENDIF()
ENDIF(OTB_COMPILE_JPEG2000)
IF(NOT OTB_USE_EXTERNAL_OPENTHREADS)
SET(UtilitiesTests_SRCS ${UtilitiesTests_SRCS}
......
find_program(NM nm REQUIRED)
execute_process(COMMAND ${NM} ${OPJ_TARGET_PATH}
OUTPUT_VARIABLE NM_OUTPUT)
# get a list, one item for each line
string(REPLACE "\n" ";" NM_OUTPUT ${NM_OUTPUT})
set(mangling_ok true)
# define the regex to match the nm output
set(regex "[a-z0-9]+ T ([a-zA-Z0-9_]+)")
foreach( NM_SYMBOL ${NM_OUTPUT})
if (NM_SYMBOL MATCHES ${regex})
# extract the symbol part
string (REGEX REPLACE "${regex}" "\\1" symbol "${NM_SYMBOL}" )
# check that the symbol begins with "${OPJ_MANGLE_PREFIX}_"
if (NOT ${symbol} MATCHES "^${OPJ_MANGLE_PREFIX}_")
# two additional symbols _fini and _init are added for the shared libraries
if (NOT ${symbol} MATCHES "(_fini|_init)")
message("Found unmangled symbol : ${symbol}")
# test fails as soon as there is one unmangled symbol
set(mangling_ok false)
endif()
endif()
endif()
endforeach()
if (NOT mangling_ok)
# outputing a fatal error will make the test fail
message(FATAL_ERROR "Not all symbols are properly mangled")
endif()
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment