|
| 1 | +#!/bin/bash |
| 2 | +# FIPS provider status test runner |
| 3 | + |
| 4 | +set -e |
| 5 | + |
| 6 | +# Get the directory of this script and find the root |
| 7 | +TEST_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" |
| 8 | +ROOT_DIR="$(cd "$TEST_DIR/../../../.." && pwd)" |
| 9 | + |
| 10 | +# Binary should be in the test/.libs/ directory |
| 11 | +BINARY="fips_status.test" |
| 12 | +BINARY_PATH="$ROOT_DIR/test/.libs/$BINARY" |
| 13 | + |
| 14 | +# Make sure we can find the binary |
| 15 | +if [ ! -f "$BINARY_PATH" ]; then |
| 16 | + echo "Error: Cannot find binary $BINARY_PATH" |
| 17 | + echo "Make sure you've built the test with: make test/fips_status.test" |
| 18 | + exit 1 |
| 19 | +fi |
| 20 | + |
| 21 | +# Source env-setup |
| 22 | +if ! source "$ROOT_DIR/scripts/env-setup" >/dev/null; then |
| 23 | + echo "Error: env-setup failed" |
| 24 | + exit 1 |
| 25 | +fi |
| 26 | + |
| 27 | +# Source common test utilities |
| 28 | +source "$ROOT_DIR/test/standalone/test_common.sh" |
| 29 | + |
| 30 | +# Check if this is a replace-default build |
| 31 | +WP_USING_REPLACE_DEFAULT="0" |
| 32 | +if detect_replace_default_build; then |
| 33 | + WP_USING_REPLACE_DEFAULT="1" |
| 34 | + unset OPENSSL_CONF |
| 35 | +fi |
| 36 | + |
| 37 | +echo "Using environment:" |
| 38 | +echo "LD_LIBRARY_PATH: $LD_LIBRARY_PATH" |
| 39 | +echo "OPENSSL_CONF: $OPENSSL_CONF" |
| 40 | +echo "OPENSSL_BIN: $OPENSSL_BIN" |
| 41 | + |
| 42 | +echo "Running FIPS status test: $BINARY_PATH" |
| 43 | +echo "" |
| 44 | + |
| 45 | +# The healthy-path assertion runs on every build. The forced-failure path runs |
| 46 | +# in FIPS builds via wolfCrypt_SetStatus_fips (HAVE_FORCE_FIPS_FAILURE) or, on |
| 47 | +# Linux, symbol interposition; the binary self-reports which path it took. |
| 48 | +if "$BINARY_PATH"; then |
| 49 | + echo "FIPS status test: PASSED" |
| 50 | + exit 0 |
| 51 | +else |
| 52 | + echo "FIPS status test: FAILED" |
| 53 | + exit 1 |
| 54 | +fi |
0 commit comments