| # Licensed to the Apache Software Foundation (ASF) under one or more contributor |
| # license agreements. See the NOTICE file distributed with this work for |
| # additional information regarding copyright ownership. The ASF licenses this |
| # file to you under the Apache License, Version 2.0 (the "License"); you may not |
| # use this file except in compliance with the License. You may obtain a copy of |
| # the License at |
| # |
| # http://www.apache.org/licenses/LICENSE-2.0 |
| # |
| # Unless required by applicable law or agreed to in writing, software |
| # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| # License for the specific language governing permissions and limitations under |
| # the License. |
| |
| # Set the LD_LIBRARY_PATH or equivalent to the libraries can be loaded when |
| # running the test. |
| if(CMAKE_SYSTEM_NAME MATCHES "Darwin") |
| set(ld_library_path_var "DYLD_LIBRARY_PATH") |
| elseif(CMAKE_SYSTEM_NAME MATCHES "Linux") |
| set(ld_library_path_var "LD_LIBRARY_PATH") |
| elseif(CMAKE_SYSTEM_NAME MATCHES "Windows") |
| set(ld_library_path_var "PATH") |
| endif() |
| |
| # Prepend the env dynamic library path with the mpc path |
| set(dynamic_library_path ${PROJECT_BINARY_DIR}/src:$ENV{${ld_library_path_var}}) |
| |
| function(add_python_test name source) |
| add_test(${name} python3 ${source}) |
| |
| set_tests_properties(${name} PROPERTIES ENVIRONMENT "${ld_library_path_var}=${dynamic_library_path}") |
| endfunction() |
| |
| # Tests |
| file(GLOB TESTS *.py) |
| file(COPY ${TESTS} DESTINATION "${PROJECT_BINARY_DIR}/python/test") |
| |
| # MPC test vectors |
| file(GLOB MPC_TV "${PROJECT_SOURCE_DIR}/testVectors/mpc/*.json") |
| file(COPY ${MPC_TV} DESTINATION "${PROJECT_BINARY_DIR}/python/test/mpc/") |
| |
| # Schnorr test vectors |
| file(GLOB SCHNORR_TV "${PROJECT_SOURCE_DIR}/testVectors/schnorr/*.json") |
| file(COPY ${SCHNORR_TV} DESTINATION "${PROJECT_BINARY_DIR}/python/test/schnorr/") |
| |
| # NM Commitment test vector |
| file( |
| COPY ${PROJECT_SOURCE_DIR}/testVectors/commitments/nm_commit.json |
| DESTINATION "${PROJECT_BINARY_DIR}/python/test/commitments/") |
| |
| if(NOT CMAKE_BUILD_TYPE STREQUAL "ASan") |
| add_python_test(test_python_mpc_mta test_mta.py) |
| add_python_test(test_python_mpc_r test_r.py) |
| add_python_test(test_python_mpc_s test_s.py) |
| add_python_test(test_python_mpc_ecdsa test_ecdsa.py) |
| add_python_test(test_python_mpc_schnorr test_schnorr.py) |
| add_python_test(test_python_mpc_nm_commit test_nm_commit.py) |
| endif(NOT CMAKE_BUILD_TYPE STREQUAL "ASan") |