1#!/bin/sh 2 3# Run the shared library dynamic loading demo program. 4# This is only expected to work when Mbed TLS is built as a shared library. 5 6# Copyright The Mbed TLS Contributors 7# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later 8 9. "${0%/*}/../demo_common.sh" 10 11msg "Test the dynamic loading of libmbed*" 12 13program="$programs_dir/test/dlopen" 14library_dir="$root_dir/library" 15 16# Skip this test if we don't have a shared library build. Detect this 17# through the absence of the demo program. 18if [ ! -e "$program" ]; then 19 msg "$0: this demo requires a shared library build." 20 # Exit with a success status so that this counts as a pass for run_demos.py. 21 exit 22fi 23 24# ELF-based Unix-like (Linux, *BSD, Solaris, ...) 25if [ -n "${LD_LIBRARY_PATH-}" ]; then 26 LD_LIBRARY_PATH="$library_dir:$LD_LIBRARY_PATH" 27else 28 LD_LIBRARY_PATH="$library_dir" 29fi 30export LD_LIBRARY_PATH 31 32# OSX/macOS 33if [ -n "${DYLD_LIBRARY_PATH-}" ]; then 34 DYLD_LIBRARY_PATH="$library_dir:$DYLD_LIBRARY_PATH" 35else 36 DYLD_LIBRARY_PATH="$library_dir" 37fi 38export DYLD_LIBRARY_PATH 39 40msg "Running dynamic loading test program: $program" 41msg "Loading libraries from: $library_dir" 42"$program" 43