1#!/bin/sh
2#
3# Copyright 2017-2021 The OpenSSL Project Authors. All Rights Reserved.
4# Copyright (c) 2017, Oracle and/or its affiliates.  All rights reserved.
5#
6# Licensed under the Apache License 2.0 (the "License").  You may not use
7# this file except in compliance with the License.  You can obtain a copy
8# in the file LICENSE in the source distribution or at
9# https://www.openssl.org/source/license.html
10
11#
12# OpenSSL external testing using the Python Cryptography module
13#
14set -e
15set -x
16
17O_EXE=`pwd`/$BLDTOP/apps
18O_BINC=`pwd`/$BLDTOP/include
19O_SINC=`pwd`/$SRCTOP/include
20O_LIB=`pwd`/$BLDTOP
21
22export PATH=$O_EXE:$PATH
23export LD_LIBRARY_PATH=$O_LIB:$LD_LIBRARY_PATH
24
25# Check/Set openssl version
26OPENSSL_VERSION=`openssl version | cut -f 2 -d ' '`
27
28echo "------------------------------------------------------------------"
29echo "Testing OpenSSL using Python Cryptography:"
30echo "   CWD:                $PWD"
31echo "   SRCTOP:             $SRCTOP"
32echo "   BLDTOP:             $BLDTOP"
33echo "   OpenSSL version:    $OPENSSL_VERSION"
34echo "------------------------------------------------------------------"
35
36cd $SRCTOP
37
38# Create a python virtual env and activate
39rm -rf venv-cryptography
40python -m venv venv-cryptography
41. ./venv-cryptography/bin/activate
42# Upgrade pip to always have latest
43pip install -U pip
44
45cd pyca-cryptography
46
47echo "------------------------------------------------------------------"
48echo "Building cryptography and installing test requirements"
49echo "------------------------------------------------------------------"
50LDFLAGS="-L$O_LIB" CFLAGS="-I$O_BINC -I$O_SINC " pip install .[test]
51pip install -e vectors
52
53echo "------------------------------------------------------------------"
54echo "Print linked libraries"
55echo "------------------------------------------------------------------"
56ldd $(find ../venv-cryptography/lib/ -iname '*.so')
57
58
59echo "------------------------------------------------------------------"
60echo "Running tests"
61echo "------------------------------------------------------------------"
62pytest -n auto tests --wycheproof-root=../wycheproof
63
64cd ../
65deactivate
66rm -rf venv-cryptography
67
68exit 0
69
70