Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve handling of copying of dynamic libraries and clean them up after test finishes #1681

Merged
merged 1 commit into from
Apr 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions java/examples/datasets/JavaDatasetExample.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ CMP='cmp'
DIFF='diff -c'
CP='cp'
DIRNAME='dirname'
BASENAME='basename'
LS='ls'
AWK='awk'

Expand Down Expand Up @@ -103,17 +104,21 @@ COPY_LIBFILES_TO_BLDLIBDIR()
INODE_SDIR=`$LS -i -d $SDIR | $AWK -F' ' '{print $1}'`
INODE_DDIR=`$LS -i -d $BLDLIBDIR | $AWK -F' ' '{print $1}'`
if [ "$INODE_SDIR" != "$INODE_DDIR" ]; then
$CP -f $tstfile $BLDLIBDIR
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The 'R' option preserves soft links correctly, instead of letting them be duplicated into new copies of the linked file.

$CP -fR $tstfile $BLDLIBDIR
if [ $? -ne 0 ]; then
echo "Error: FAILED to copy $tstfile ."

# Comment out this to CREATE expected file
exit $EXIT_FAILURE
fi
BNAME=`$BASENAME $tstfile`
if [ "$BNAME" = "libhdf5_java.dylib" ]; then
COPIED_LIBHDF5_JAVA=1
fi
fi
fi
done
if [ "$IS_DARWIN" = "yes" ]; then
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Protect against mangling the dynlib when it wasn't copied

if [[ "$IS_DARWIN" = "yes" ]] && [[ $COPIED_LIBHDF5_JAVA -eq 1 ]]; then
(cd $BLDLIBDIR; \
install_name_tool -add_rpath @loader_path libhdf5_java.dylib; \
exist_path=` otool -l libhdf5_java.dylib | grep libhdf5 | grep -v java | awk '{print $2}'`; \
Expand All @@ -134,7 +139,7 @@ COPY_LIBFILES_TO_BLDLIBDIR()
INODE_SDIR=`$LS -i -d $SDIR | $AWK -F' ' '{print $1}'`
INODE_DDIR=`$LS -i -d $BLDLIBDIR | $AWK -F' ' '{print $1}'`
if [ "$INODE_SDIR" != "$INODE_DDIR" ]; then
$CP -f $tstfile $BLDLIBDIR
$CP -fR $tstfile $BLDLIBDIR
if [ $? -ne 0 ]; then
echo "Error: FAILED to copy $tstfile ."

Expand All @@ -155,10 +160,7 @@ CLEAN_LIBFILES_AND_BLDLIBDIR()
INODE_SDIR=`$LS -i -d $SDIR | $AWK -F' ' '{print $1}'`
INODE_DDIR=`$LS -i -d $BLDLIBDIR | $AWK -F' ' '{print $1}'`
if [ "$INODE_SDIR" != "$INODE_DDIR" ]; then
for tstfile in $COPY_JARTESTFILES
do
$RM $BLDLIBDIR/tstfile
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All the files need to be deleted, not just the JAR files. Plus this should have been $tstfile

done
$RM -rf $BLDLIBDIR
fi
}

Expand Down
16 changes: 9 additions & 7 deletions java/examples/datatypes/JavaDatatypeExample.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ CMP='cmp'
DIFF='diff -c'
CP='cp'
DIRNAME='dirname'
BASENAME='basename'
LS='ls'
AWK='awk'

Expand Down Expand Up @@ -100,17 +101,21 @@ COPY_LIBFILES_TO_BLDLIBDIR()
INODE_SDIR=`$LS -i -d $SDIR | $AWK -F' ' '{print $1}'`
INODE_DDIR=`$LS -i -d $BLDLIBDIR | $AWK -F' ' '{print $1}'`
if [ "$INODE_SDIR" != "$INODE_DDIR" ]; then
$CP -f $tstfile $BLDLIBDIR
$CP -fR $tstfile $BLDLIBDIR
if [ $? -ne 0 ]; then
echo "Error: FAILED to copy $tstfile ."

# Comment out this to CREATE expected file
exit $EXIT_FAILURE
fi
BNAME=`$BASENAME $tstfile`
if [ "$BNAME" = "libhdf5_java.dylib" ]; then
COPIED_LIBHDF5_JAVA=1
fi
fi
fi
done
if [ "$IS_DARWIN" = "yes" ]; then
if [[ "$IS_DARWIN" = "yes" ]] && [[ $COPIED_LIBHDF5_JAVA -eq 1 ]]; then
(cd $BLDLIBDIR; \
install_name_tool -add_rpath @loader_path libhdf5_java.dylib; \
exist_path=` otool -l libhdf5_java.dylib | grep libhdf5 | grep -v java | awk '{print $2}'`; \
Expand All @@ -131,7 +136,7 @@ COPY_LIBFILES_TO_BLDLIBDIR()
INODE_SDIR=`$LS -i -d $SDIR | $AWK -F' ' '{print $1}'`
INODE_DDIR=`$LS -i -d $BLDLIBDIR | $AWK -F' ' '{print $1}'`
if [ "$INODE_SDIR" != "$INODE_DDIR" ]; then
$CP -f $tstfile $BLDLIBDIR
$CP -fR $tstfile $BLDLIBDIR
if [ $? -ne 0 ]; then
echo "Error: FAILED to copy $tstfile ."

Expand All @@ -152,10 +157,7 @@ CLEAN_LIBFILES_AND_BLDLIBDIR()
INODE_SDIR=`$LS -i -d $SDIR | $AWK -F' ' '{print $1}'`
INODE_DDIR=`$LS -i -d $BLDLIBDIR | $AWK -F' ' '{print $1}'`
if [ "$INODE_SDIR" != "$INODE_DDIR" ]; then
for tstfile in $COPY_JARTESTFILES
do
$RM $BLDLIBDIR/tstfile
done
$RM -rf $BLDLIBDIR
fi
}

Expand Down
16 changes: 9 additions & 7 deletions java/examples/groups/JavaGroupExample.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ CMP='cmp'
DIFF='diff -c'
CP='cp'
DIRNAME='dirname'
BASENAME='basename'
LS='ls'
AWK='awk'

Expand Down Expand Up @@ -95,17 +96,21 @@ COPY_LIBFILES_TO_BLDLIBDIR()
INODE_SDIR=`$LS -i -d $SDIR | $AWK -F' ' '{print $1}'`
INODE_DDIR=`$LS -i -d $BLDLIBDIR | $AWK -F' ' '{print $1}'`
if [ "$INODE_SDIR" != "$INODE_DDIR" ]; then
$CP -f $tstfile $BLDLIBDIR
$CP -fR $tstfile $BLDLIBDIR
if [ $? -ne 0 ]; then
echo "Error: FAILED to copy $tstfile ."

# Comment out this to CREATE expected file
exit $EXIT_FAILURE
fi
BNAME=`$BASENAME $tstfile`
if [ "$BNAME" = "libhdf5_java.dylib" ]; then
COPIED_LIBHDF5_JAVA=1
fi
fi
fi
done
if [ "$IS_DARWIN" = "yes" ]; then
if [[ "$IS_DARWIN" = "yes" ]] && [[ $COPIED_LIBHDF5_JAVA -eq 1 ]]; then
(cd $BLDLIBDIR; \
install_name_tool -add_rpath @loader_path libhdf5_java.dylib; \
exist_path=` otool -l libhdf5_java.dylib | grep libhdf5 | grep -v java | awk '{print $2}'`; \
Expand All @@ -126,7 +131,7 @@ COPY_LIBFILES_TO_BLDLIBDIR()
INODE_SDIR=`$LS -i -d $SDIR | $AWK -F' ' '{print $1}'`
INODE_DDIR=`$LS -i -d $BLDLIBDIR | $AWK -F' ' '{print $1}'`
if [ "$INODE_SDIR" != "$INODE_DDIR" ]; then
$CP -f $tstfile $BLDLIBDIR
$CP -fR $tstfile $BLDLIBDIR
if [ $? -ne 0 ]; then
echo "Error: FAILED to copy $tstfile ."

Expand All @@ -147,10 +152,7 @@ CLEAN_LIBFILES_AND_BLDLIBDIR()
INODE_SDIR=`$LS -i -d $SDIR | $AWK -F' ' '{print $1}'`
INODE_DDIR=`$LS -i -d $BLDLIBDIR | $AWK -F' ' '{print $1}'`
if [ "$INODE_SDIR" != "$INODE_DDIR" ]; then
for tstfile in $COPY_JARTESTFILES
do
$RM $BLDLIBDIR/tstfile
done
$RM -rf $BLDLIBDIR
fi
}

Expand Down
16 changes: 9 additions & 7 deletions java/examples/intro/JavaIntroExample.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ CMP='cmp'
DIFF='diff -c'
CP='cp'
DIRNAME='dirname'
BASENAME='basename'
LS='ls'
AWK='awk'

Expand Down Expand Up @@ -89,17 +90,21 @@ COPY_LIBFILES_TO_BLDLIBDIR()
INODE_SDIR=`$LS -i -d $SDIR | $AWK -F' ' '{print $1}'`
INODE_DDIR=`$LS -i -d $BLDLIBDIR | $AWK -F' ' '{print $1}'`
if [ "$INODE_SDIR" != "$INODE_DDIR" ]; then
$CP -f $tstfile $BLDLIBDIR
$CP -fR $tstfile $BLDLIBDIR
if [ $? -ne 0 ]; then
echo "Error: FAILED to copy $tstfile ."

# Comment out this to CREATE expected file
exit $EXIT_FAILURE
fi
BNAME=`$BASENAME $tstfile`
if [ "$BNAME" = "libhdf5_java.dylib" ]; then
COPIED_LIBHDF5_JAVA=1
fi
fi
fi
done
if [ "$IS_DARWIN" = "yes" ]; then
if [[ "$IS_DARWIN" = "yes" ]] && [[ $COPIED_LIBHDF5_JAVA -eq 1 ]]; then
(cd $BLDLIBDIR; \
install_name_tool -add_rpath @loader_path libhdf5_java.dylib; \
exist_path=` otool -l libhdf5_java.dylib | grep libhdf5 | grep -v java | awk '{print $2}'`; \
Expand All @@ -120,7 +125,7 @@ COPY_LIBFILES_TO_BLDLIBDIR()
INODE_SDIR=`$LS -i -d $SDIR | $AWK -F' ' '{print $1}'`
INODE_DDIR=`$LS -i -d $BLDLIBDIR | $AWK -F' ' '{print $1}'`
if [ "$INODE_SDIR" != "$INODE_DDIR" ]; then
$CP -f $tstfile $BLDLIBDIR
$CP -fR $tstfile $BLDLIBDIR
if [ $? -ne 0 ]; then
echo "Error: FAILED to copy $tstfile ."

Expand All @@ -141,10 +146,7 @@ CLEAN_LIBFILES_AND_BLDLIBDIR()
INODE_SDIR=`$LS -i -d $SDIR | $AWK -F' ' '{print $1}'`
INODE_DDIR=`$LS -i -d $BLDLIBDIR | $AWK -F' ' '{print $1}'`
if [ "$INODE_SDIR" != "$INODE_DDIR" ]; then
for tstfile in $COPY_JARTESTFILES
do
$RM $BLDLIBDIR/tstfile
done
$RM -rf $BLDLIBDIR
fi
}

Expand Down
13 changes: 9 additions & 4 deletions java/test/junit.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ CMP='cmp'
DIFF='diff -c'
CP='cp'
DIRNAME='dirname'
BASENAME='basename'
LS='ls'
AWK='awk'

Expand Down Expand Up @@ -141,17 +142,21 @@ COPY_LIBFILES_TO_BLDLIBDIR()
INODE_SDIR=`$LS -i -d $SDIR | $AWK -F' ' '{print $1}'`
INODE_DDIR=`$LS -i -d $BLDLIBDIR | $AWK -F' ' '{print $1}'`
if [ "$INODE_SDIR" != "$INODE_DDIR" ]; then
$CP -f $tstfile $BLDLIBDIR
$CP -fR $tstfile $BLDLIBDIR
if [ $? -ne 0 ]; then
echo "Error: FAILED to copy $tstfile ."

# Comment out this to CREATE expected file
exit $EXIT_FAILURE
fi
BNAME=`$BASENAME $tstfile`
if [ "$BNAME" = "libhdf5_java.dylib" ]; then
COPIED_LIBHDF5_JAVA=1
fi
fi
fi
done
if [ "$IS_DARWIN" = "yes" ]; then
if [[ "$IS_DARWIN" = "yes" ]] && [[ $COPIED_LIBHDF5_JAVA -eq 1 ]]; then
(cd testlibs; \
install_name_tool -add_rpath @loader_path libhdf5_java.dylib; \
exist_path=` otool -l libhdf5_java.dylib | grep libhdf5 | grep -v java | awk '{print $2}'`; \
Expand All @@ -172,7 +177,7 @@ COPY_LIBFILES_TO_BLDLIBDIR()
INODE_SDIR=`$LS -i -d $SDIR | $AWK -F' ' '{print $1}'`
INODE_DDIR=`$LS -i -d $BLDLIBDIR | $AWK -F' ' '{print $1}'`
if [ "$INODE_SDIR" != "$INODE_DDIR" ]; then
$CP -f $tstfile $BLDLIBDIR
$CP -fR $tstfile $BLDLIBDIR
if [ $? -ne 0 ]; then
echo "Error: FAILED to copy $tstfile ."

Expand All @@ -195,7 +200,7 @@ COPY_LIBFILES_TO_BLDLIBDIR()
INODE_SDIR=`$LS -i -d $SDIR | $AWK -F' ' '{print $1}'`
INODE_DDIR=`$LS -i -d $BLDLIBDIR | $AWK -F' ' '{print $1}'`
if [ "$INODE_SDIR" != "$INODE_DDIR" ]; then
$CP -f $tstfile $BLDLIBDIR
$CP -fR $tstfile $BLDLIBDIR
if [ $? -ne 0 ]; then
echo "Error: FAILED to copy $tstfile ."

Expand Down