Skip to content

Commit 567bf77

Browse files
committed
CDRIVER-2673 test to verify installed lib name
1 parent 81347a8 commit 567bf77

File tree

3 files changed

+90
-43
lines changed

3 files changed

+90
-43
lines changed

.evergreen/check-symlink.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
check_symlink()
2+
{
3+
SYMLINK="$INSTALL_DIR/lib/$1"
4+
EXPECTED_TARGET="$2"
5+
6+
if test ! -L "$SYMLINK"; then
7+
echo "$SYMLINK should be a symlink"
8+
exit 1
9+
fi
10+
11+
TARGET=$(readlink "$SYMLINK")
12+
if test ! -f $INSTALL_DIR/lib/$TARGET; then
13+
echo "$SYMLINK target $INSTALL_DIR/lib/$TARGET is missing!"
14+
exit 1
15+
else
16+
echo "$SYMLINK target $INSTALL_DIR/lib/$TARGET check ok"
17+
fi
18+
19+
if [ "$TARGET" != "$EXPECTED_TARGET" ]; then
20+
echo "$SYMLINK should symlink to $EXPECTED_TARGET, not to $TARGET"
21+
exit 1
22+
else
23+
echo "$SYMLINK links to correct filename"
24+
fi
25+
}

.evergreen/link-sample-program-bson.sh

Lines changed: 33 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,25 @@ echo "LINK_STATIC=$LINK_STATIC BUILD_SAMPLE_WITH_CMAKE=$BUILD_SAMPLE_WITH_CMAKE"
1111

1212
DIR=$(dirname $0)
1313
. $DIR/find-cmake.sh
14+
. $DIR/check-symlink.sh
1415

1516
if command -v gtar 2>/dev/null; then
1617
TAR=gtar
1718
else
1819
TAR=tar
1920
fi
2021

21-
if [ $(uname) = "Darwin" ]; then
22+
# Get the kernel name, lowercased
23+
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
24+
echo "OS: $OS"
25+
26+
if [ "$OS" = "darwin" ]; then
2227
SO=dylib
2328
LIB_SO=libbson-1.0.0.dylib
2429
LDD="otool -L"
2530
else
2631
SO=so
27-
LIB_SO=libbson-1.0.so.0
32+
LIB_SO=libbson-1.0.so.0.0.0
2833
LDD=ldd
2934
fi
3035

@@ -76,28 +81,34 @@ else
7681

7782
fi
7883

79-
set +o xtrace
80-
81-
LIB=$INSTALL_DIR/lib/libbson-1.0.$SO
82-
if test ! -L $LIB; then
83-
echo "$LIB should be a symlink"
84-
exit 1
85-
fi
86-
87-
TARGET=$(readlink $LIB)
88-
if test ! -f $INSTALL_DIR/lib/$TARGET; then
89-
echo "$LIB target $INSTALL_DIR/lib/$TARGET is missing!"
90-
exit 1
91-
else
92-
echo "$LIB target $INSTALL_DIR/lib/$TARGET check ok"
93-
fi
84+
ls -l $INSTALL_DIR/lib
9485

86+
set +o xtrace
9587

96-
if test ! -f $INSTALL_DIR/lib/$LIB_SO; then
97-
echo "$LIB_SO missing!"
98-
exit 1
88+
# Check on Linux that libbson is installed into lib/ like:
89+
# libbson-1.0.so -> libbson-1.0.so.0
90+
# libbson-1.0.so.0 -> libbson-1.0.so.0.0.0
91+
# libbson-1.0.so.0.0.0
92+
if [ "$OS" != "darwin" ]; then
93+
# From check-symlink.sh
94+
check_symlink libbson-1.0.so libbson-1.0.so.0
95+
check_symlink libbson-1.0.so.0 libbson-1.0.so.0.0.0
96+
SONAME=$(objdump -p $INSTALL_DIR/lib/$LIB_SO|grep SONAME|awk '{print $2}')
97+
EXPECTED_SONAME="libbson-1.0.so.0"
98+
if [ "$SONAME" != "$EXPECTED_SONAME" ]; then
99+
echo "SONAME should be $EXPECTED_SONAME, not $SONAME"
100+
exit 1
101+
else
102+
echo "library name check ok, SONAME=$SONAME"
103+
fi
99104
else
100-
echo "$LIB_SO check ok"
105+
# Just test that the shared lib was installed.
106+
if test ! -f $INSTALL_DIR/lib/$LIB_SO; then
107+
echo "$LIB_SO missing!"
108+
exit 1
109+
else
110+
echo "$LIB_SO check ok"
111+
fi
101112
fi
102113

103114
if test ! -f $INSTALL_DIR/lib/pkgconfig/libbson-1.0.pc; then
@@ -177,7 +188,7 @@ else
177188
fi
178189

179190
if [ ! "$LINK_STATIC" ]; then
180-
if [ $(uname) = "Darwin" ]; then
191+
if [ "$OS" = "darwin" ]; then
181192
export DYLD_LIBRARY_PATH=$INSTALL_DIR/lib
182193
else
183194
export LD_LIBRARY_PATH=$INSTALL_DIR/lib

.evergreen/link-sample-program.sh

Lines changed: 32 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ echo "LINK_STATIC=$LINK_STATIC BUILD_SAMPLE_WITH_CMAKE=$BUILD_SAMPLE_WITH_CMAKE"
1414

1515
DIR=$(dirname $0)
1616
. $DIR/find-cmake.sh
17+
. $DIR/check-symlink.sh
1718

1819
if command -v gtar 2>/dev/null; then
1920
TAR=gtar
@@ -76,29 +77,37 @@ $CMAKE -DCMAKE_INSTALL_PREFIX=$INSTALL_DIR -DCMAKE_PREFIX_PATH=$INSTALL_DIR/lib/
7677
make
7778
make install
7879

79-
80-
LIB=$INSTALL_DIR/lib/libmongoc-1.0.$SO
81-
if test ! -L $LIB; then
82-
echo "$LIB should be a symlink"
83-
exit 1
84-
fi
85-
86-
TARGET=$(readlink $LIB)
87-
if test ! -f $INSTALL_DIR/lib/$TARGET; then
88-
echo "$LIB target $INSTALL_DIR/lib/$TARGET is missing!"
89-
exit 1
80+
ls -l $INSTALL_DIR/lib
81+
82+
set +o xtrace
83+
84+
# Check on Linux that libmongoc is installed into lib/ like:
85+
# libmongoc-1.0.so -> libmongoc-1.0.so.0
86+
# libmongoc-1.0.so.0 -> libmongoc-1.0.so.0.0.0
87+
# libmongoc-1.0.so.0.0.0
88+
if [ "$OS" != "darwin" ]; then
89+
# From check-symlink.sh
90+
check_symlink libmongoc-1.0.so libmongoc-1.0.so.0
91+
check_symlink libmongoc-1.0.so.0 libmongoc-1.0.so.0.0.0
92+
SONAME=$(objdump -p $INSTALL_DIR/lib/$LIB_SO|grep SONAME|awk '{print $2}')
93+
EXPECTED_SONAME="libmongoc-1.0.so.0"
94+
if [ "$SONAME" != "$EXPECTED_SONAME" ]; then
95+
echo "SONAME should be $EXPECTED_SONAME, not $SONAME"
96+
exit 1
97+
else
98+
echo "library name check ok, SONAME=$SONAME"
99+
fi
90100
else
91-
echo "$LIB target $INSTALL_DIR/lib/$TARGET check ok"
101+
# Just test that the shared lib was installed.
102+
if test ! -f $INSTALL_DIR/lib/$LIB_SO; then
103+
echo "$LIB_SO missing!"
104+
exit 1
105+
else
106+
echo "$LIB_SO check ok"
107+
fi
92108
fi
93109

94110

95-
if test ! -f $INSTALL_DIR/lib/$LIB_SO; then
96-
echo "$LIB_SO missing!"
97-
exit 1
98-
else
99-
echo "$LIB_SO check ok"
100-
fi
101-
102111
if test ! -f $INSTALL_DIR/lib/pkgconfig/libmongoc-1.0.pc; then
103112
echo "libmongoc-1.0.pc missing!"
104113
exit 1
@@ -167,7 +176,7 @@ else
167176
fi
168177
fi
169178

170-
if [ $(uname) = "Darwin" ]; then
179+
if [ "$OS" = "darwin" ]; then
171180
if test -f $INSTALL_DIR/bin/mongoc-stat; then
172181
echo "mongoc-stat shouldn't have been installed"
173182
exit 1
@@ -181,6 +190,8 @@ else
181190
fi
182191
fi
183192

193+
set -o xtrace
194+
184195
if [ "$BUILD_SAMPLE_WITH_CMAKE" ]; then
185196
# Test our CMake package config file with CMake's find_package command.
186197
EXAMPLE_DIR=$SRCROOT/src/libmongoc/examples/cmake/find_package
@@ -209,7 +220,7 @@ else
209220
fi
210221

211222
if [ ! "$LINK_STATIC" ]; then
212-
if [ $(uname) = "Darwin" ]; then
223+
if [ "$OS" = "darwin" ]; then
213224
export DYLD_LIBRARY_PATH=$INSTALL_DIR/lib
214225
else
215226
export LD_LIBRARY_PATH=$INSTALL_DIR/lib

0 commit comments

Comments
 (0)