Skip to content

Commit b98d576

Browse files
authored
Merge pull request #327 from padelsbach/wp-enforce-local-ossl
Ensure use of local wolfSSL and OpenSSL when running unit tests
2 parents 855820b + 32a55f8 commit b98d576

File tree

5 files changed

+31
-50
lines changed

5 files changed

+31
-50
lines changed

.github/workflows/asan.yml

Lines changed: 0 additions & 35 deletions
This file was deleted.

.github/workflows/openssl-version.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,9 @@ jobs:
7777

7878
- name: Build and test wolfProvider
7979
run: |
80-
WOLFPROV_CONFIG_CFLAGS="-static-libasan -fsanitize=address,undefined -g" \
80+
OPENSSL_CFLAGS="-static-libasan -fsanitize=address,undefined -g" \
81+
OPENSSL_CXXFLAGS="-static-libasan -fsanitize=address,undefined -g" \
82+
OPENSSL_LDFLAGS="-fsanitize=address,undefined -static-libasan" \
8183
OPENSSL_TAG=${{ matrix.openssl_ref }} \
8284
WOLFSSL_TAG=${{ matrix.wolfssl_ref }} \
8385
./scripts/build-wolfprovider.sh

scripts/env-setup

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ fi
6767
export OPENSSL_CONF="${OPENSSL_CONF:=$DEFAULT_PROVIDER_CONF}"
6868

6969
export OPENSSL_MODULES="${OPENSSL_MODULES:=$WOLFPROV_LIB_PATH}"
70-
export PKG_CONFIG_PATH="${PKG_CONFIG_PATH:=$OPENSSL_LIB_PATH/pkgconfig:$REPO_ROOT/libdefault-stub-install/lib}"
70+
export PKG_CONFIG_PATH="${PKG_CONFIG_PATH:=$OPENSSL_LIB_PATH/pkgconfig}"
7171

7272
# Other variables used by test scripts
7373
export WOLFPROV_PATH="${WOLFPROV_LIB_PATH}"

scripts/utils-openssl.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ OPENSSL_INSTALL_DIR=${SCRIPT_DIR}/../openssl-install
3232
OPENSSL_BIN=${OPENSSL_INSTALL_DIR}/bin/openssl
3333
OPENSSL_TEST=${OPENSSL_SOURCE_DIR}/test
3434
OPENSSL_LIB_DIRS="${OPENSSL_INSTALL_DIR}/lib:${OPENSSL_INSTALL_DIR}/lib64"
35+
OPENSSL_CFLAGS=${OPENSSL_CFLAGS:-""}
36+
OPENSSL_CXXFLAGS=${OPENSSL_CXXFLAGS:-""}
37+
OPENSSL_LDFLAGS=${OPENSSL_LDFLAGS:-""}
3538

3639
NUMCPU=${NUMCPU:-8}
3740
WOLFPROV_DEBUG=${WOLFPROV_DEBUG:-0}
@@ -227,6 +230,10 @@ install_openssl() {
227230
fi
228231
printf "Done.\n"
229232

233+
export CFLAGS="${OPENSSL_CFLAGS}"
234+
export CXXFLAGS="${OPENSSL_CXXFLAGS}"
235+
export LDFLAGS="${OPENSSL_LDFLAGS}"
236+
230237
printf "\tBuild OpenSSL ${OPENSSL_TAG} ... "
231238
make -j$NUMCPU >>$LOG_FILE 2>&1
232239
if [ $? != 0 ]; then

scripts/utils-wolfprovider.sh

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -130,32 +130,42 @@ install_wolfprov() {
130130
fi
131131
printf "Done.\n"
132132

133+
# Install prior to test so that the library is present in the known location.
134+
printf "\tInstall wolfProvider ... "
135+
make install >>$LOG_FILE 2>&1
136+
if [ $? != 0 ]; then
137+
printf "\n\n...\n"
138+
tail -n 40 $LOG_FILE
139+
do_cleanup
140+
exit 1
141+
fi
142+
printf "Done.\n"
143+
133144
# Build the replacement default library after wolfprov to avoid linker errors
134145
# but before testing so that the library is present if needed
135146
if [ "$WOLFPROV_REPLACE_DEFAULT" = "1" ]; then
136147
printf "\tWARNING: Skipping tests in replace mode...\n"
137148
else
149+
# Setup the environment to ensure we use the local builds of wolfprov, wolfssl, and openssl.
150+
if ! source ${SCRIPT_DIR}/env-setup >/dev/null 2>&1; then
151+
printf "\n\nError: Failed to source env-setup\n"
152+
do_cleanup
153+
exit 1
154+
fi
155+
138156
printf "\tTest wolfProvider ... "
139157
make test >>$LOG_FILE 2>&1
140158
if [ $? != 0 ]; then
141159
printf "\n\n...\n"
142160
tail -n 40 $LOG_FILE
161+
# Clean up the install directory
162+
make uninstall >>$LOG_FILE 2>&1 || true
143163
do_cleanup
144164
exit 1
145165
fi
146166
printf "Done.\n"
147167
fi
148168

149-
printf "\tInstall wolfProvider ... "
150-
make install >>$LOG_FILE 2>&1
151-
if [ $? != 0 ]; then
152-
printf "\n\n...\n"
153-
tail -n 40 $LOG_FILE
154-
do_cleanup
155-
exit 1
156-
fi
157-
printf "Done.\n"
158-
159169
popd &> /dev/null
160170
}
161171

@@ -174,9 +184,6 @@ init_wolfprov() {
174184
install_wolfprov
175185
fi
176186
printf "\twolfProvider installed in: ${WOLFPROV_INSTALL_DIR}\n"
177-
178-
export OPENSSL_MODULES=$WOLFPROV_PATH
179-
export OPENSSL_CONF=${WOLFPROV_CONFIG}
180187
fi
181188
}
182189

0 commit comments

Comments
 (0)