xref: /oneTBB/cmake/python/test_launcher.cmake (revision d86ed7fb)
1# Copyright (c) 2020 Intel Corporation
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#     http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15find_package(PythonInterp 3.5 REQUIRED)
16
17file(GLOB_RECURSE MODULES_LIST "${PYTHON_MODULE_BUILD_PATH}/*TBB.py*" )
18list(LENGTH MODULES_LIST MODULES_COUNT)
19
20if (MODULES_COUNT EQUAL 0)
21    message(FATAL_ERROR "Cannot find oneTBB Python module")
22elseif (MODULES_COUNT GREATER 1)
23    message(WARNING "Found more than oneTBB Python modules, the only first found module will be tested")
24endif()
25
26list(GET MODULES_LIST 0 PYTHON_MODULE)
27get_filename_component(PYTHON_MODULE_PATH ${PYTHON_MODULE} DIRECTORY)
28
29execute_process(
30    COMMAND
31        ${CMAKE_COMMAND} -E env LD_LIBRARY_PATH=${TBB_BINARIES_PATH}
32        ${PYTHON_EXECUTABLE} -m tbb test
33    WORKING_DIRECTORY ${PYTHON_MODULE_PATH}
34    RESULT_VARIABLE CMD_RESULT
35)
36if (CMD_RESULT)
37    message(FATAL_ERROR "Error while test execution: ${cmd} error_code: ${CMD_RESULT}")
38endif()
39