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