From a4a2761bbc644e400d1154544e0918f0f9a1caff Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 15 May 2013 11:22:34 +0200 Subject: Add dlopen script to check for unresolved symbols. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Vendors can call "make test_proxymech" from their specfile to make sure proxymech.so can be properly loaded by the GSSAPI. Signed-off-by: Günther Deschner Reviewed-by: Simo Sorce --- proxy/Makefile.am | 6 ++++ proxy/tests/scripts/dlopen.sh | 76 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 82 insertions(+) create mode 100755 proxy/tests/scripts/dlopen.sh (limited to 'proxy') diff --git a/proxy/Makefile.am b/proxy/Makefile.am index 857be35..e786d42 100644 --- a/proxy/Makefile.am +++ b/proxy/Makefile.am @@ -312,3 +312,9 @@ prerelease-srpm: mv $(srcdir)/version.m4.orig $(srcdir)/version.m4 endif +#################### +# Testing # +#################### + +test_proxymech: + TMPDIR=tests/scripts/ ./tests/scripts/dlopen.sh ./.libs/proxymech.so || exit 1 diff --git a/proxy/tests/scripts/dlopen.sh b/proxy/tests/scripts/dlopen.sh new file mode 100755 index 0000000..890cc39 --- /dev/null +++ b/proxy/tests/scripts/dlopen.sh @@ -0,0 +1,76 @@ +#!/bin/sh + +test -n "$TMPDIR" || exit 1 +tempdir="$TMPDIR/dlopentest" +mkdir -p $tempdir +cat >> $tempdir/dlopen.c << _EOF +#include +#include +#include +#include +/* Simple program to see if dlopen() would succeed. */ +int main(int argc, char **argv) +{ + int i; + struct stat st; + char buf[PATH_MAX]; + for (i = 1; i < argc; i++) { + if (dlopen(argv[i], RTLD_NOW)) { + fprintf(stdout, "dlopen() of \"%s\" succeeded.\n", + argv[i]); + } else { + snprintf(buf, sizeof(buf), "./%s", argv[i]); + if ((stat(buf, &st) == 0) && dlopen(buf, RTLD_NOW)) { + fprintf(stdout, "dlopen() of \"./%s\" " + "succeeded.\n", argv[i]); + } else { + fprintf(stdout, "dlopen() of \"%s\" failed: " + "%s\n", argv[i], dlerror()); + return 1; + } + } + } + return 0; +} +_EOF + +for arg in $@ ; do + case "$arg" in + "") + ;; + -I*|-D*|-f*|-m*|-g*|-O*|-W*) + cflags="$cflags $arg" + ;; + -l*|-L*) + ldflags="$ldflags $arg" + ;; + /*) + modules="$modules $arg" + ;; + *) + modules="$modules $arg" + ;; + esac +done + +${CC:-gcc} $RPM_OPT_FLAGS $CFLAGS -o $tempdir/dlopen $cflags $tempdir/dlopen.c $ldflags -ldl + +retval=0 +for module in $modules ; do + case "$module" in + "") + ;; + /*) + $tempdir/dlopen "$module" + retval=$? + ;; + *) + $tempdir/dlopen ./"$module" + retval=$? + ;; + esac +done + +rm -f $tempdir/dlopen $tempdir/dlopen.c +rmdir $tempdir +exit $retval -- cgit