-
Notifications
You must be signed in to change notification settings - Fork 26
/
test-openssl-version.sh
executable file
·218 lines (193 loc) · 4.53 KB
/
test-openssl-version.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
#!/bin/sh
# test-openssl-version.sh
#
# Copyright (C) 2019-2023 wolfSSL Inc.
#
TMP_FILE=/tmp/test_config.$$
CONFIG_STATUS=config.status
CONFIG_STATUS_TMP=/tmp/config.status.$$
WE_TEST="./test/unit.test"
# See README.md for change to make to OpenSSL to enable this to work.
EXTRA_OPTS=""
VERBOSE="no"
# User can set the directory to find different versions of OpenSSL
if [ "$OPENSSL_VER_DIR" = "" ]
then
OPENSSL_VER_DIR=~/wolfssl/external
fi
# User can set directory of specific versions
if [ "$OPENSSL300_DIR" = "" ]
then
OPENSSL300_DIR=$OPENSSL_VER_DIR/openssl-3.0.0
fi
if [ "$OPENSSL111_DIR" = "" ]
then
OPENSSL111_DIR=$OPENSSL_VER_DIR/openssl-1.1.1
fi
if [ "$OPENSSL110_DIR" = "" ]
then
OPENSSL110_DIR=$OPENSSL_VER_DIR/openssl-1.1.0
fi
if [ "$OPENSSL102_DIR" = "" ]
then
OPENSSL102_DIR=$OPENSSL_VER_DIR/openssl-1.0.2
fi
# Check if a directory for an OpenSSL version exists to know to test
if [ -d "$OPENSSL300_DIR" ]
then
CONFIG_300="yes"
else
CONFIG_300="no"
fi
if [ -d "$OPENSSL111_DIR" ]
then
CONFIG_111="yes"
else
CONFIG_111="no"
fi
if [ -d "$OPENSSL110_DIR" ]
then
CONFIG_110="yes"
else
CONFIG_110="no"
fi
if [ -d "$OPENSSL102_DIR" ]
then
CONFIG_102="yes"
else
CONFIG_102="no"
fi
do_cleanup() {
if [ -f $CONFIG_STATUS_TMP ]; then
mv $CONFIG_STATUS_TMP $CONFIG_STATUS
fi
./config.status >/dev/null 2>&1
make clean >/dev/null 2>&1
make -j 8 >/dev/null 2>&1
rm -f $CONFIG_STATUS_TMP
rm -f $TMP_FILE
}
do_trap() {
echo "got trap"
do_cleanup
exit 2
}
trap do_trap INT TERM
cp $CONFIG_STATUS $CONFIG_STATUS_TMP
do_config() {
export OPENSSL=$OPENSSL_DIR/apps/openssl
echo -n " Configure ... "
# Using development version of OpenSSL not install - set LDFLAGS
./configure LDFLAGS="-L$OPENSSL_DIR $WOLFENGINE_EXTRA_LDFLAGS" $EXTRA_OPTS \
CPPFLAGS="$WOLFENGINE_EXTRA_CPPFLAGS" \
--with-openssl=$OPENSSL_DIR >$TMP_FILE 2>&1
if [ $? != 0 ]; then
cat $TMP_FILE
echo "Failed to configure wolfSSL engine"
do_cleanup
exit 1
fi
echo "DONE"
if [ "$VERBOSE" = "yes" ]; then
cat $TMP_FILE
fi
echo -n " Make ... "
make >$TMP_FILE 2>&1
if [ $? != 0 ]; then
cat $TMP_FILE
echo "Failed to make wolfSSL engine"
do_cleanup
exit 1
fi
echo "DONE"
if [ "$VERBOSE" = "yes" ]; then
cat $TMP_FILE
fi
echo -n " unit.test ... "
LD_LIBRARY_PATH=$OPENSSL_DIR $WE_TEST >$TMP_FILE 2>&1
if [ $? != 0 ]; then
cat $TMP_FILE
echo "Unit test failed for wolfSSL engine"
do_cleanup
exit 1
fi
echo -n "PASS "
LD_LIBRARY_PATH=$OPENSSL_DIR $WE_TEST --list | wc -l
if [ "$VERBOSE" = "yes" ]; then
cat $TMP_FILE
fi
}
while [ $# -gt 0 ]
do
case $1 in
300)
echo "Only testing OpenSSL v3.0.0"
CONFIG_111="no"
CONFIG_110="no"
CONFIG_102="no"
;;
111)
echo "Only testing OpenSSL v1.1.1"
CONFIG_300="no"
CONFIG_110="no"
CONFIG_102="no"
;;
110)
echo "Only testing OpenSSL v1.1.0"
CONFIG_300="no"
CONFIG_111="no"
CONFIG_102="no"
;;
102)
echo "Only testing OpenSSL v1.0.2"
CONFIG_300="no"
CONFIG_111="no"
CONFIG_110="no"
;;
--debug)
echo "Enabling debug in wolfengine"
EXTRA_OPTS="$EXTRA_OPTS --enable-debug"
;;
--no-hash)
echo "Disabling hash in wolfengine"
EXTRA_OPTS="$EXTRA_OPTS --disable-hash"
;;
--pbe)
EXTRA_OPTS="$EXTRA_OPTS --enable-pbe"
;;
--clang)
EXTRA_OPTS="$EXTRA_OPTS CC=clang"
;;
-v)
VERBOSE="yes"
;;
--verbose)
VERBOSE="yes"
;;
esac
shift 1
done
echo
# Only tests the OpenSSL versions request and available
if [ "$CONFIG_300" = "yes" ]; then
echo "OpenSSL v3.0.0"
OPENSSL_DIR=$OPENSSL300_DIR
do_config
fi
if [ "$CONFIG_111" = "yes" ]; then
echo "OpenSSL v1.1.1"
OPENSSL_DIR=$OPENSSL111_DIR
do_config
fi
if [ "$CONFIG_110" = "yes" ]; then
echo "OpenSSL v1.1.0"
OPENSSL_DIR=$OPENSSL110_DIR
do_config
fi
if [ "$CONFIG_102" = "yes" ]; then
echo "OpenSSL v1.0.2"
OPENSSL_DIR=$OPENSSL102_DIR
do_config
fi
# Cleanup temporary files and restore configuration
do_cleanup