xref: /oneTBB/cmake/python/test_launcher.cmake (revision b15aabb3)
1*b15aabb3Stbbdev# Copyright (c) 2020-2021 Intel Corporation
251c0b2f7Stbbdev#
351c0b2f7Stbbdev# Licensed under the Apache License, Version 2.0 (the "License");
451c0b2f7Stbbdev# you may not use this file except in compliance with the License.
551c0b2f7Stbbdev# You may obtain a copy of the License at
651c0b2f7Stbbdev#
751c0b2f7Stbbdev#     http://www.apache.org/licenses/LICENSE-2.0
851c0b2f7Stbbdev#
951c0b2f7Stbbdev# Unless required by applicable law or agreed to in writing, software
1051c0b2f7Stbbdev# distributed under the License is distributed on an "AS IS" BASIS,
1151c0b2f7Stbbdev# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1251c0b2f7Stbbdev# See the License for the specific language governing permissions and
1351c0b2f7Stbbdev# limitations under the License.
1451c0b2f7Stbbdev
1551c0b2f7Stbbdevfind_package(PythonInterp 3.5 REQUIRED)
1651c0b2f7Stbbdev
1751c0b2f7Stbbdevfile(GLOB_RECURSE MODULES_LIST "${PYTHON_MODULE_BUILD_PATH}/*TBB.py*" )
1851c0b2f7Stbbdevlist(LENGTH MODULES_LIST MODULES_COUNT)
1951c0b2f7Stbbdev
2051c0b2f7Stbbdevif (MODULES_COUNT EQUAL 0)
2151c0b2f7Stbbdev    message(FATAL_ERROR "Cannot find oneTBB Python module")
2251c0b2f7Stbbdevelseif (MODULES_COUNT GREATER 1)
2351c0b2f7Stbbdev    message(WARNING "Found more than oneTBB Python modules, the only first found module will be tested")
2451c0b2f7Stbbdevendif()
2551c0b2f7Stbbdev
2651c0b2f7Stbbdevlist(GET MODULES_LIST 0 PYTHON_MODULE)
2751c0b2f7Stbbdevget_filename_component(PYTHON_MODULE_PATH ${PYTHON_MODULE} DIRECTORY)
2851c0b2f7Stbbdev
2951c0b2f7Stbbdevexecute_process(
3051c0b2f7Stbbdev    COMMAND
3151c0b2f7Stbbdev        ${CMAKE_COMMAND} -E env LD_LIBRARY_PATH=${TBB_BINARIES_PATH}
3251c0b2f7Stbbdev        ${PYTHON_EXECUTABLE} -m tbb test
3351c0b2f7Stbbdev    WORKING_DIRECTORY ${PYTHON_MODULE_PATH}
3451c0b2f7Stbbdev    RESULT_VARIABLE CMD_RESULT
3551c0b2f7Stbbdev)
3651c0b2f7Stbbdevif (CMD_RESULT)
3751c0b2f7Stbbdev    message(FATAL_ERROR "Error while test execution: ${cmd} error_code: ${CMD_RESULT}")
3851c0b2f7Stbbdevendif()
39