| Gilles Peskine | ca14459 | 2021-11-04 12:52:14 +0100 | [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 | 
|  | 8 | # | 
|  | 9 | # Licensed under the Apache License, Version 2.0 (the "License"); you may | 
|  | 10 | # not use this file except in compliance with the License. | 
|  | 11 | # You may obtain a copy of the License at | 
|  | 12 | # | 
|  | 13 | # http://www.apache.org/licenses/LICENSE-2.0 | 
|  | 14 | # | 
|  | 15 | # Unless required by applicable law or agreed to in writing, software | 
|  | 16 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | 
|  | 17 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 
|  | 18 | # See the License for the specific language governing permissions and | 
|  | 19 | # limitations under the License. | 
|  | 20 |  | 
|  | 21 | set -e -u | 
|  | 22 |  | 
|  | 23 | program_dir="${0%/*}" | 
|  | 24 | program="$program_dir/dlopen" | 
|  | 25 | top_dir="$program_dir/../.." | 
|  | 26 | library_dir="$top_dir/library" | 
|  | 27 |  | 
|  | 28 | # ELF-based Unix-like (Linux, *BSD, Solaris, ...) | 
|  | 29 | if [ -n "${LD_LIBRARY_PATH-}" ]; then | 
|  | 30 | LD_LIBRARY_PATH="$library_dir:$LD_LIBRARY_PATH" | 
|  | 31 | else | 
|  | 32 | LD_LIBRARY_PATH="$library_dir" | 
|  | 33 | fi | 
|  | 34 | export LD_LIBRARY_PATH | 
|  | 35 |  | 
|  | 36 | # OSX/macOS | 
|  | 37 | if [ -n "${DYLD_LIBRARY_PATH-}" ]; then | 
|  | 38 | DYLD_LIBRARY_PATH="$library_dir:$DYLD_LIBRARY_PATH" | 
|  | 39 | else | 
|  | 40 | DYLD_LIBRARY_PATH="$library_dir" | 
|  | 41 | fi | 
|  | 42 | export DYLD_LIBRARY_PATH | 
|  | 43 |  | 
| Gilles Peskine | 7fb54c5 | 2021-11-10 21:04:24 +0100 | [diff] [blame] | 44 | echo "Running dynamic loading test program: $program" | 
|  | 45 | echo "Loading libraries from: $library_dir" | 
| Gilles Peskine | ca14459 | 2021-11-04 12:52:14 +0100 | [diff] [blame] | 46 | "$program" |