Minos Galanakis | 2c824b4 | 2025-03-20 09:28:45 +0000 | [diff] [blame] | 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%/*}/../../scripts/demo_common.sh" |
| 10 | |
| 11 | msg "Test the dynamic loading of libmbed*" |
| 12 | |
| 13 | program="$programs_dir/test/dlopen" |
| 14 | library_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. |
| 18 | if [ ! -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 |
| 22 | fi |
| 23 | |
| 24 | # ELF-based Unix-like (Linux, *BSD, Solaris, ...) |
| 25 | if [ -n "${LD_LIBRARY_PATH-}" ]; then |
| 26 | LD_LIBRARY_PATH="$library_dir:$LD_LIBRARY_PATH" |
| 27 | else |
| 28 | LD_LIBRARY_PATH="$library_dir" |
| 29 | fi |
| 30 | export LD_LIBRARY_PATH |
| 31 | |
| 32 | # OSX/macOS |
| 33 | if [ -n "${DYLD_LIBRARY_PATH-}" ]; then |
| 34 | DYLD_LIBRARY_PATH="$library_dir:$DYLD_LIBRARY_PATH" |
| 35 | else |
| 36 | DYLD_LIBRARY_PATH="$library_dir" |
| 37 | fi |
| 38 | export DYLD_LIBRARY_PATH |
| 39 | |
| 40 | msg "Running dynamic loading test program: $program" |
| 41 | msg "Loading libraries from: $library_dir" |
| 42 | "$program" |