Use demo_common.sh in dlopen test script

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
This commit is contained in:
Gilles Peskine 2023-07-25 19:53:04 +02:00
parent 63c3534981
commit c25ae6f48c

View file

@ -18,33 +18,12 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
set -e -u . "${0%/*}/../demo_common.sh"
program_name="dlopen" msg "Test the dynamic loading of libmbed*"
program_dir="${0%/*}"
program="$program_dir/$program_name"
if [ ! -e "$program" ]; then program="$programs_dir/test/dlopen"
# Look for programs in the current directory and the directories above it library_dir="$root_dir/library"
for dir in "." ".." "../.."; do
program_dir="$dir/programs/test"
program="$program_dir/$program_name"
if [ -e "$program" ]; then
break
fi
done
if [ ! -e "$program" ]; then
echo "Could not find $program_name program"
echo "Make sure that Mbed TLS is built as a shared library." \
"If building out-of-tree, this script must be run" \
"from the project build directory."
exit 1
fi
fi
top_dir="$program_dir/../.."
library_dir="$top_dir/library"
# ELF-based Unix-like (Linux, *BSD, Solaris, ...) # ELF-based Unix-like (Linux, *BSD, Solaris, ...)
if [ -n "${LD_LIBRARY_PATH-}" ]; then if [ -n "${LD_LIBRARY_PATH-}" ]; then
@ -62,6 +41,6 @@ else
fi fi
export DYLD_LIBRARY_PATH export DYLD_LIBRARY_PATH
echo "Running dynamic loading test program: $program" msg "Running dynamic loading test program: $program"
echo "Loading libraries from: $library_dir" msg "Loading libraries from: $library_dir"
"$program" "$program"