summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorZack Weinberg <zackw@panix.com>2020-12-30 14:24:41 -0500
committerZack Weinberg <zackw@panix.com>2020-12-30 14:24:41 -0500
commita5b0a665368cc80931a037eecf1f79ede98f397e (patch)
tree6c2c5b069ed60e790d5525fd71c812737cde2b19 /test
parent0ad75cb4a9b6c26252db9c11155afd1388bf42ae (diff)
downloadlibxcrypt-a5b0a665368cc80931a037eecf1f79ede98f397e.tar.gz
libxcrypt-a5b0a665368cc80931a037eecf1f79ede98f397e.tar.bz2
libxcrypt-a5b0a665368cc80931a037eecf1f79ede98f397e.zip
test/symbols-compat.sh: Don’t rely on -lcrypt to find libcrypt.so.1.
Some Linux distributions are now shipping libcrypt.so as a symlink to libcrypt.so.2, but still providing libcrypt.so.1 as a compatibility library. The symbols-compat.sh test is still relevant on these systems, but linking a test program against -lcrypt will not find libcrypt.so.1. Instead use gcc -print-file-name=libcrypt.so.1, which will find that library regardless of what other libcrypt* files are present. This also has the nice fringe benefit that we don’t have to parse ldd output anymore. This does *not* fix the symbols-compat failures in CI, but it should not make them worse.
Diffstat (limited to 'test')
-rwxr-xr-xtest/symbols-compat.sh36
1 files changed, 12 insertions, 24 deletions
diff --git a/test/symbols-compat.sh b/test/symbols-compat.sh
index f00334a..661d2ef 100755
--- a/test/symbols-compat.sh
+++ b/test/symbols-compat.sh
@@ -44,31 +44,19 @@ get_our_symbols_with_versions ()
get_their_symbols_with_versions ()
{
- (
- set -e
- cd "$1"
- cat >test.c <<\EOF
-extern char *crypt(const char *, const char *);
-int main(int argc, char **argv)
-{
- return !!crypt(argv[0], argv[1]);
-}
-EOF
- ${CC-cc} test.c -lcrypt >&2 || exit 77
+ # Ask the compiler whether a libcrypt.so.1 exists in its search
+ # path. The compiler option -print-file-name should be supported
+ # on all operating systems where there's an older libcrypt that we
+ # can be backward compatible with.
+ their_library=$(${CC-cc} $CFLAGS $LDFLAGS -print-file-name=libcrypt.so.1)
- their_library=$(ldd ./a.out |
- grep -F libcrypt.so.1 |
- cut -d' ' -f3)
+ if [ -z "$their_library" ] || [ "$their_library" = "libcrypt.so.1" ]; then
+ printf '%s\n' '- No libcrypt.so.1 to be compatible with' >&2
+ exit 77
+ fi
- if [ -n "$their_library" ]; then
- printf '%s%s\n' '- Their library: ' "$their_library" >&2
- get_symbols_with_versions "$their_library"
- else
- printf '%s\n' '- No libcrypt.so.1 to be compatible with'
- exit 77
- fi
- )
- if [ $? -ne 0 ]; then exit $?; fi
+ printf '%s%s\n' '- Their library: ' "$their_library" >&2
+ get_symbols_with_versions "$their_library"
}
if [ ! -f "$lib_la" ] || [ -z "$host_os" ]; then
@@ -104,7 +92,7 @@ trap '[ -z "$workdir" ] || rm -rf "$workdir" || :' 0
workdir="$(mktemp -d)"
get_our_symbols_with_versions "$lib_la" > "$workdir/our_symbols"
-get_their_symbols_with_versions "$workdir" > "$workdir/their_symbols"
+get_their_symbols_with_versions > "$workdir/their_symbols"
# It's okay if we define more symbol (versions) than they do, but every
# symbol they define should have a matching definition in our library.