Jonathan Peyton | 2e01335 | 2015-07-15 16:05:30 +0000 | [diff] [blame] | 1 | # |
| 2 | #//===----------------------------------------------------------------------===// |
| 3 | #// |
| 4 | #// The LLVM Compiler Infrastructure |
| 5 | #// |
| 6 | #// This file is dual licensed under the MIT and the University of Illinois Open |
| 7 | #// Source Licenses. See LICENSE.txt for details. |
| 8 | #// |
| 9 | #//===----------------------------------------------------------------------===// |
| 10 | # |
| 11 | |
| 12 | # The following micro-tests are small tests to perform on the library just created. |
| 13 | # There are currently five micro-tests: |
| 14 | # (1) test-touch |
Jonathan Peyton | 5b4acbd | 2015-07-15 16:57:19 +0000 | [diff] [blame] | 15 | # - Compile and run a small program using newly created libomp library |
| 16 | # - Fails if test-touch.c does not compile or if test-touch.c does not run after compilation |
| 17 | # - Program dependencies: gcc or g++, grep, bourne shell |
| 18 | # - Available for all Unix,Mac,Windows builds. Not available on Intel(R) MIC Architecture builds. |
Jonathan Peyton | 2e01335 | 2015-07-15 16:05:30 +0000 | [diff] [blame] | 19 | # (2) test-relo |
Jonathan Peyton | 5b4acbd | 2015-07-15 16:57:19 +0000 | [diff] [blame] | 20 | # - Tests dynamic libraries for position-dependent code (can not have any position dependent code) |
| 21 | # - Fails if TEXTREL is in output of readelf -d libomp.so command |
| 22 | # - Program dependencies: readelf, grep, bourne shell |
| 23 | # - Available for Unix, Intel(R) MIC Architecture dynamic library builds. Not available otherwise. |
Jonathan Peyton | 2e01335 | 2015-07-15 16:05:30 +0000 | [diff] [blame] | 24 | # (3) test-execstack |
Jonathan Peyton | 5b4acbd | 2015-07-15 16:57:19 +0000 | [diff] [blame] | 25 | # - Tests if stack is executable |
| 26 | # - Fails if stack is executable. Should only be readable and writable. Not exectuable. |
| 27 | # - Program dependencies: perl, readelf |
| 28 | # - Available for Unix dynamic library builds. Not available otherwise. |
Jonathan Peyton | 2e01335 | 2015-07-15 16:05:30 +0000 | [diff] [blame] | 29 | # (4) test-instr (Intel(R) MIC Architecutre only) |
Jonathan Peyton | 5b4acbd | 2015-07-15 16:57:19 +0000 | [diff] [blame] | 30 | # - Tests Intel(R) MIC Architecture libraries for valid instruction set |
| 31 | # - Fails if finds invalid instruction for Intel(R) MIC Architecture (wasn't compiled with correct flags) |
| 32 | # - Program dependencies: perl, objdump |
| 33 | # - Available for Intel(R) MIC Architecture and i386 builds. Not available otherwise. |
Jonathan Peyton | 2e01335 | 2015-07-15 16:05:30 +0000 | [diff] [blame] | 34 | # (5) test-deps |
Jonathan Peyton | 5b4acbd | 2015-07-15 16:57:19 +0000 | [diff] [blame] | 35 | # - Tests newly created libomp for library dependencies |
| 36 | # - Fails if sees a dependence not listed in td_exp variable below |
| 37 | # - Program dependencies: perl, (unix)readelf, (mac)otool[64], (windows)link.exe |
| 38 | # - Available for Unix,Mac,Windows, Intel(R) MIC Architecture dynamic builds and Windows |
| 39 | # static builds. Not available otherwise. |
Jonathan Peyton | 2e01335 | 2015-07-15 16:05:30 +0000 | [diff] [blame] | 40 | |
| 41 | # get library location |
| 42 | if(WIN32) |
Jonathan Peyton | 5b4acbd | 2015-07-15 16:57:19 +0000 | [diff] [blame] | 43 | get_target_property(LIBOMP_OUTPUT_DIRECTORY omp RUNTIME_OUTPUT_DIRECTORY) |
| 44 | get_target_property(LIBOMPIMP_OUTPUT_DIRECTORY ompimp ARCHIVE_OUTPUT_DIRECTORY) |
| 45 | if(NOT LIBOMPIMP_OUTPUT_DIRECTORY) |
| 46 | set(LIBOMPIMP_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) |
| 47 | endif() |
Jonathan Peyton | 2e01335 | 2015-07-15 16:05:30 +0000 | [diff] [blame] | 48 | else() |
Jonathan Peyton | 5b4acbd | 2015-07-15 16:57:19 +0000 | [diff] [blame] | 49 | get_target_property(LIBOMP_OUTPUT_DIRECTORY omp LIBRARY_OUTPUT_DIRECTORY) |
Jonathan Peyton | 2e01335 | 2015-07-15 16:05:30 +0000 | [diff] [blame] | 50 | endif() |
| 51 | if(NOT LIBOMP_OUTPUT_DIRECTORY) |
Jonathan Peyton | 5b4acbd | 2015-07-15 16:57:19 +0000 | [diff] [blame] | 52 | set(LIBOMP_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) |
Jonathan Peyton | 2e01335 | 2015-07-15 16:05:30 +0000 | [diff] [blame] | 53 | endif() |
| 54 | |
| 55 | # test-touch |
| 56 | find_program(LIBOMP_SHELL sh) |
| 57 | if(WIN32) |
Jonathan Peyton | 5b4acbd | 2015-07-15 16:57:19 +0000 | [diff] [blame] | 58 | if(LIBOMP_SHELL) |
| 59 | set(libomp_test_touch_targets test-touch-md/.success test-touch-mt/.success) |
| 60 | endif() |
| 61 | # pick test-touch compiler |
| 62 | set(libomp_test_touch_compiler ${CMAKE_C_COMPILER}) |
| 63 | # test-touch compilation flags |
| 64 | libomp_append(libomp_test_touch_cflags /nologo) |
| 65 | libomp_append(libomp_test_touch_libs ${LIBOMPIMP_OUTPUT_DIRECTORY}/${LIBOMP_IMP_LIB_FILE}) |
| 66 | if(${IA32}) |
| 67 | libomp_append(libomp_test_touch_ldflags /safeseh) |
| 68 | endif() |
Jonathan Peyton | 2e01335 | 2015-07-15 16:05:30 +0000 | [diff] [blame] | 69 | else() # (Unix based systems, Intel(R) MIC Architecture, and Mac) |
Jonathan Peyton | 5b4acbd | 2015-07-15 16:57:19 +0000 | [diff] [blame] | 70 | if(LIBOMP_SHELL) |
| 71 | set(libomp_test_touch_targets test-touch-rt/.success) |
| 72 | endif() |
| 73 | # pick test-touch compiler |
| 74 | if(${LIBOMP_USE_STDCPPLIB}) |
| 75 | set(libomp_test_touch_compiler ${CMAKE_CXX_COMPILER}) |
| 76 | else() |
| 77 | set(libomp_test_touch_compiler ${CMAKE_C_COMPILER}) |
| 78 | endif() |
| 79 | # test-touch compilation flags |
| 80 | libomp_append(libomp_test_touch_libs "${CMAKE_THREAD_LIBS_INIT}") |
| 81 | if(${IA32}) |
| 82 | libomp_append(libomp_test_touch_cflags -m32 LIBOMP_HAVE_M32_FLAG) |
| 83 | endif() |
| 84 | libomp_append(libomp_test_touch_libs ${LIBOMP_OUTPUT_DIRECTORY}/${LIBOMP_LIB_FILE}) |
Jonathan Peyton | 01dcf36 | 2015-11-30 20:02:59 +0000 | [diff] [blame] | 85 | libomp_append(libomp_test_touch_libs "${LIBOMP_HWLOC_LIBRARY}" LIBOMP_USE_HWLOC) |
Jonathan Peyton | 5b4acbd | 2015-07-15 16:57:19 +0000 | [diff] [blame] | 86 | if(APPLE) |
| 87 | set(libomp_test_touch_env "DYLD_LIBRARY_PATH=.:${LIBOMP_OUTPUT_DIRECTORY}:$ENV{DYLD_LIBRARY_PATH}") |
Jonathan Peyton | 01dcf36 | 2015-11-30 20:02:59 +0000 | [diff] [blame] | 88 | libomp_append(libomp_test_touch_ldflags "-Wl,-rpath,${LIBOMP_HWLOC_LIBRARY_DIR}" LIBOMP_USE_HWLOC) |
Jonathan Peyton | 5b4acbd | 2015-07-15 16:57:19 +0000 | [diff] [blame] | 89 | else() |
| 90 | set(libomp_test_touch_env "LD_LIBRARY_PATH=.:${LIBOMP_OUTPUT_DIRECTORY}:$ENV{LD_LIBRARY_PATH}") |
Jonathan Peyton | 01dcf36 | 2015-11-30 20:02:59 +0000 | [diff] [blame] | 91 | libomp_append(libomp_test_touch_ldflags "-Wl,-rpath=${LIBOMP_HWLOC_LIBRARY_DIR}" LIBOMP_USE_HWLOC) |
Jonathan Peyton | 5b4acbd | 2015-07-15 16:57:19 +0000 | [diff] [blame] | 92 | endif() |
Jonathan Peyton | 2e01335 | 2015-07-15 16:05:30 +0000 | [diff] [blame] | 93 | endif() |
| 94 | macro(libomp_test_touch_recipe test_touch_dir) |
Jonathan Peyton | 5b4acbd | 2015-07-15 16:57:19 +0000 | [diff] [blame] | 95 | set(libomp_test_touch_dependencies ${LIBOMP_SRC_DIR}/test-touch.c omp) |
| 96 | set(libomp_test_touch_exe ${test_touch_dir}/test-touch${CMAKE_EXECUTABLE_SUFFIX}) |
| 97 | set(libomp_test_touch_obj ${test_touch_dir}/test-touch${CMAKE_C_OUTPUT_EXTENSION}) |
| 98 | if(WIN32) |
| 99 | if(${RELEASE_BUILD} OR ${RELWITHDEBINFO_BUILD}) |
| 100 | if(${test_touch_dir} MATCHES "test-touch-mt") |
| 101 | libomp_append(libomp_test_touch_cflags /MT) |
| 102 | else() |
| 103 | libomp_append(libomp_test_touch_cflags /MD) |
| 104 | endif() |
Jonathan Peyton | 2e01335 | 2015-07-15 16:05:30 +0000 | [diff] [blame] | 105 | else() |
Jonathan Peyton | 5b4acbd | 2015-07-15 16:57:19 +0000 | [diff] [blame] | 106 | if(${test_touch_dir} MATCHES "test-touch-mt") |
| 107 | libomp_append(libomp_test_touch_cflags /MTd) |
| 108 | else() |
| 109 | libomp_append(libomp_test_touch_cflags /MDd) |
| 110 | endif() |
Jonathan Peyton | 2e01335 | 2015-07-15 16:05:30 +0000 | [diff] [blame] | 111 | endif() |
Jonathan Peyton | 5b4acbd | 2015-07-15 16:57:19 +0000 | [diff] [blame] | 112 | set(libomp_test_touch_out_flags -Fe${libomp_test_touch_exe} -Fo${libomp_test_touch_obj}) |
| 113 | list(APPEND libomp_test_touch_dependencies ompimp) |
| 114 | else() |
| 115 | set(libomp_test_touch_out_flags -o ${libomp_test_touch_exe}) |
| 116 | endif() |
| 117 | add_custom_command( |
| 118 | OUTPUT ${test_touch_dir}/.success ${libomp_test_touch_exe} ${libomp_test_touch_obj} |
| 119 | COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/${test_touch_dir} |
| 120 | COMMAND ${CMAKE_COMMAND} -E remove -f ${test_touch_dir}/* |
| 121 | COMMAND ${libomp_test_touch_compiler} ${libomp_test_touch_out_flags} ${libomp_test_touch_cflags} |
| 122 | ${LIBOMP_SRC_DIR}/test-touch.c ${libomp_test_touch_ldflags} ${libomp_test_touch_libs} |
| 123 | COMMAND ${LIBOMP_SHELL} -c \"${libomp_test_touch_env} ${libomp_test_touch_exe}\" |
| 124 | COMMAND ${CMAKE_COMMAND} -E touch ${test_touch_dir}/.success |
| 125 | DEPENDS ${libomp_test_touch_dependencies} |
| 126 | ) |
Jonathan Peyton | 2e01335 | 2015-07-15 16:05:30 +0000 | [diff] [blame] | 127 | endmacro() |
| 128 | libomp_append(libomp_test_touch_env "KMP_VERSION=1") |
| 129 | add_custom_target(libomp-test-touch DEPENDS ${libomp_test_touch_targets}) |
| 130 | if(WIN32) |
Jonathan Peyton | 5b4acbd | 2015-07-15 16:57:19 +0000 | [diff] [blame] | 131 | libomp_test_touch_recipe(test-touch-mt) |
| 132 | libomp_test_touch_recipe(test-touch-md) |
Jonathan Peyton | 2e01335 | 2015-07-15 16:05:30 +0000 | [diff] [blame] | 133 | else() |
Jonathan Peyton | 5b4acbd | 2015-07-15 16:57:19 +0000 | [diff] [blame] | 134 | libomp_test_touch_recipe(test-touch-rt) |
Jonathan Peyton | 2e01335 | 2015-07-15 16:05:30 +0000 | [diff] [blame] | 135 | endif() |
| 136 | |
| 137 | # test-relo |
| 138 | add_custom_target(libomp-test-relo DEPENDS test-relo/.success) |
| 139 | add_custom_command( |
Jonathan Peyton | 5b4acbd | 2015-07-15 16:57:19 +0000 | [diff] [blame] | 140 | OUTPUT test-relo/.success test-relo/readelf.log |
| 141 | COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/test-relo |
| 142 | COMMAND readelf -d ${LIBOMP_OUTPUT_DIRECTORY}/${LIBOMP_LIB_FILE} > test-relo/readelf.log |
Hans Wennborg | fd4dfdc | 2015-07-24 21:24:48 +0000 | [diff] [blame] | 143 | COMMAND grep -e TEXTREL test-relo/readelf.log \; test $$? -eq 1 |
Jonathan Peyton | 5b4acbd | 2015-07-15 16:57:19 +0000 | [diff] [blame] | 144 | COMMAND ${CMAKE_COMMAND} -E touch test-relo/.success |
| 145 | DEPENDS omp |
Jonathan Peyton | 2e01335 | 2015-07-15 16:05:30 +0000 | [diff] [blame] | 146 | ) |
| 147 | |
| 148 | # test-execstack |
| 149 | add_custom_target(libomp-test-execstack DEPENDS test-execstack/.success) |
| 150 | add_custom_command( |
Jonathan Peyton | 5b4acbd | 2015-07-15 16:57:19 +0000 | [diff] [blame] | 151 | OUTPUT test-execstack/.success |
| 152 | COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/test-execstack |
Jonathan Peyton | 4c91ad1 | 2016-01-26 19:44:31 +0000 | [diff] [blame] | 153 | COMMAND ${PERL_EXECUTABLE} ${LIBOMP_TOOLS_DIR}/check-execstack.pl |
| 154 | --arch=${LIBOMP_PERL_SCRIPT_ARCH} ${LIBOMP_OUTPUT_DIRECTORY}/${LIBOMP_LIB_FILE} |
Jonathan Peyton | 5b4acbd | 2015-07-15 16:57:19 +0000 | [diff] [blame] | 155 | COMMAND ${CMAKE_COMMAND} -E touch test-execstack/.success |
| 156 | DEPENDS omp |
Jonathan Peyton | 2e01335 | 2015-07-15 16:05:30 +0000 | [diff] [blame] | 157 | ) |
| 158 | |
| 159 | # test-instr |
| 160 | add_custom_target(libomp-test-instr DEPENDS test-instr/.success) |
| 161 | add_custom_command( |
Jonathan Peyton | 5b4acbd | 2015-07-15 16:57:19 +0000 | [diff] [blame] | 162 | OUTPUT test-instr/.success |
| 163 | COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/test-instr |
| 164 | COMMAND ${PERL_EXECUTABLE} ${LIBOMP_TOOLS_DIR}/check-instruction-set.pl --os=${LIBOMP_PERL_SCRIPT_OS} |
Jonathan Peyton | 4c91ad1 | 2016-01-26 19:44:31 +0000 | [diff] [blame] | 165 | --arch=${LIBOMP_PERL_SCRIPT_ARCH} --show --mic-arch=${LIBOMP_MIC_ARCH} ${LIBOMP_OUTPUT_DIRECTORY}/${LIBOMP_LIB_FILE} |
Jonathan Peyton | 5b4acbd | 2015-07-15 16:57:19 +0000 | [diff] [blame] | 166 | COMMAND ${CMAKE_COMMAND} -E touch test-instr/.success |
| 167 | DEPENDS omp ${LIBOMP_TOOLS_DIR}/check-instruction-set.pl |
Jonathan Peyton | 2e01335 | 2015-07-15 16:05:30 +0000 | [diff] [blame] | 168 | ) |
| 169 | |
| 170 | # test-deps |
| 171 | add_custom_target(libomp-test-deps DEPENDS test-deps/.success) |
| 172 | set(libomp_expected_library_deps) |
| 173 | if(CMAKE_SYSTEM_NAME MATCHES "FreeBSD") |
Jonathan Peyton | 5b4acbd | 2015-07-15 16:57:19 +0000 | [diff] [blame] | 174 | set(libomp_expected_library_deps libc.so.7 libthr.so.3) |
Jonathan Peyton | 01dcf36 | 2015-11-30 20:02:59 +0000 | [diff] [blame] | 175 | libomp_append(libomp_expected_library_deps libhwloc.so.5 LIBOMP_USE_HWLOC) |
Joerg Sonnenberger | f16f649 | 2015-09-21 19:40:59 +0000 | [diff] [blame] | 176 | elseif(CMAKE_SYSTEM_NAME MATCHES "NetBSD") |
| 177 | set(libomp_expected_library_deps libc.so.12 libpthread.so.1 libm.so.0) |
Jonathan Peyton | 01dcf36 | 2015-11-30 20:02:59 +0000 | [diff] [blame] | 178 | libomp_append(libomp_expected_library_deps libhwloc.so.5 LIBOMP_USE_HWLOC) |
Jonathan Peyton | 2e01335 | 2015-07-15 16:05:30 +0000 | [diff] [blame] | 179 | elseif(APPLE) |
Jonathan Peyton | 5b4acbd | 2015-07-15 16:57:19 +0000 | [diff] [blame] | 180 | set(libomp_expected_library_deps /usr/lib/libSystem.B.dylib) |
Jonathan Peyton | 2e01335 | 2015-07-15 16:05:30 +0000 | [diff] [blame] | 181 | elseif(WIN32) |
Jonathan Peyton | 5b4acbd | 2015-07-15 16:57:19 +0000 | [diff] [blame] | 182 | set(libomp_expected_library_deps kernel32.dll) |
Jonathan Peyton | 69e596a | 2015-10-29 20:56:24 +0000 | [diff] [blame] | 183 | libomp_append(libomp_expected_library_deps psapi.dll LIBOMP_OMPT_SUPPORT) |
Jonathan Peyton | 2e01335 | 2015-07-15 16:05:30 +0000 | [diff] [blame] | 184 | else() |
Jonathan Peyton | 5b4acbd | 2015-07-15 16:57:19 +0000 | [diff] [blame] | 185 | if(${MIC}) |
| 186 | set(libomp_expected_library_deps libc.so.6 libpthread.so.0 libdl.so.2) |
| 187 | if("${LIBOMP_MIC_ARCH}" STREQUAL "knf") |
| 188 | libomp_append(libomp_expected_library_deps ld-linux-l1om.so.2) |
| 189 | libomp_append(libomp_expected_library_deps libgcc_s.so.1) |
| 190 | elseif("${LIBOMP_MIC_ARCH}" STREQUAL "knc") |
| 191 | libomp_append(libomp_expected_library_deps ld-linux-k1om.so.2) |
Jonathan Peyton | 2e01335 | 2015-07-15 16:05:30 +0000 | [diff] [blame] | 192 | endif() |
Jonathan Peyton | 5b4acbd | 2015-07-15 16:57:19 +0000 | [diff] [blame] | 193 | else() |
| 194 | set(libomp_expected_library_deps libdl.so.2 libgcc_s.so.1) |
| 195 | if(${IA32}) |
| 196 | libomp_append(libomp_expected_library_deps libc.so.6) |
| 197 | libomp_append(libomp_expected_library_deps ld-linux.so.2) |
| 198 | elseif(${INTEL64}) |
| 199 | libomp_append(libomp_expected_library_deps libc.so.6) |
| 200 | libomp_append(libomp_expected_library_deps ld-linux-x86-64.so.2) |
| 201 | elseif(${ARM}) |
| 202 | libomp_append(libomp_expected_library_deps libc.so.6) |
| 203 | libomp_append(libomp_expected_library_deps libffi.so.6) |
| 204 | libomp_append(libomp_expected_library_deps libffi.so.5) |
| 205 | libomp_append(libomp_expected_library_deps ld-linux-armhf.so.3) |
| 206 | elseif(${PPC64}) |
| 207 | libomp_append(libomp_expected_library_deps libc.so.6) |
| 208 | libomp_append(libomp_expected_library_deps ld64.so.1) |
| 209 | endif() |
| 210 | libomp_append(libomp_expected_library_deps libpthread.so.0 IF_FALSE STUBS_LIBRARY) |
Jonathan Peyton | 01dcf36 | 2015-11-30 20:02:59 +0000 | [diff] [blame] | 211 | libomp_append(libomp_expected_library_deps libhwloc.so.5 LIBOMP_USE_HWLOC) |
Jonathan Peyton | 5b4acbd | 2015-07-15 16:57:19 +0000 | [diff] [blame] | 212 | endif() |
| 213 | libomp_append(libomp_expected_library_deps libstdc++.so.6 LIBOMP_USE_STDCPPLIB) |
Jonathan Peyton | 4b1aad3 | 2015-12-17 16:15:39 +0000 | [diff] [blame] | 214 | libomp_append(libomp_expected_library_deps libm.so.6 LIBOMP_STATS) |
Jonathan Peyton | 2e01335 | 2015-07-15 16:05:30 +0000 | [diff] [blame] | 215 | endif() |
| 216 | # Perl script expects comma separated list |
| 217 | string(REPLACE ";" "," libomp_expected_library_deps "${libomp_expected_library_deps}") |
| 218 | add_custom_command( |
Jonathan Peyton | 5b4acbd | 2015-07-15 16:57:19 +0000 | [diff] [blame] | 219 | OUTPUT test-deps/.success |
| 220 | COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/test-deps |
| 221 | COMMAND ${PERL_EXECUTABLE} ${LIBOMP_TOOLS_DIR}/check-depends.pl --os=${LIBOMP_PERL_SCRIPT_OS} |
Jonathan Peyton | 4c91ad1 | 2016-01-26 19:44:31 +0000 | [diff] [blame] | 222 | --arch=${LIBOMP_PERL_SCRIPT_ARCH} --expected="${libomp_expected_library_deps}" ${LIBOMP_OUTPUT_DIRECTORY}/${LIBOMP_LIB_FILE} |
Jonathan Peyton | 5b4acbd | 2015-07-15 16:57:19 +0000 | [diff] [blame] | 223 | COMMAND ${CMAKE_COMMAND} -E touch test-deps/.success |
| 224 | DEPENDS omp ${LIBOMP_TOOLS_DIR}/check-depends.pl |
Jonathan Peyton | 2e01335 | 2015-07-15 16:05:30 +0000 | [diff] [blame] | 225 | ) |