netcdf-c/ncdump/test_rcmerge.sh
Dennis Heimbigner 55a2643cac Fix a number of OS specific bugs
1. Issue https://github.com/Unidata/netcdf-c/issues/2043
   * FreeBSD build fails because of conflicts in defining the fileno() function. So removed all extern declarations of fileno.

2. Issue https://github.com/Unidata/netcdf-c/issues/2124
   * There were a couple of problems here.
     * I was conflating msys with mingw and they need separate handling of paths. So treat mingw like windows.
     * memio.c was not always writing the full content of the memory to file. Untested fix by properly accounting for zero size writes.
     * Fix bug when skipping white space in tst_xcache.c

3. Issue https://github.com/Unidata/netcdf-c/pull/2105
   * On MINGW, bash and other POSIX utilities use a mounted root directory,
     but executables compiled for Windows do not recognise the mount point.
     Ensure that Windows paths are used in tests of Windows executables.

4. Issue https://github.com/Unidata/netcdf-c/issues/2132
   * Apparently the Intel C compiler on OSX defines isnan etc.
     So disable declaration in dutil.c under that condition.

5. Fix and re-enable test_rcmerge.sh by allowing override of where to
   look for .rc files

6. CMakeLists.txt suppresses certain ncdump directory tests because of differences in printing floats/doubles.
   * Extend the list to include those that also fail under mingw.
   * Suppress the mingw tests in ncdump/Makefile.am
2021-11-03 12:49:54 -06:00

125 lines
3.1 KiB
Bash
Executable File

#!/bin/sh
if test "x$srcdir" = x ; then srcdir=`pwd`; fi
. ../test_common.sh
# Test that all available .rc files are merged and overrides are handled.
# The internal .rc is constructed as follows:
#
# 1. Use NCRCENV_RC environment variable exclusively if defined
# 2. If NCRCENV_RC is not defined then merge the set of rc files in this order:
# 1. $RCHOME/.ncrc
# 2. $RCHOME/.daprc
# 3. $RCHOME/.docsrc
# 4. $CWD/.ncrc
# 5. $CWD/.daprc
# 6. $CWD/.docsrc
# Entries in later files override any of the >earlier >files
# RCHOME overrides HOME when searching for .rc files.
# Since this involves a shared resource: the .rc files in current working directory,
# we need to isolate from any other test.
# Make sure execdir and srcdir absolute paths are available
WD=`pwd`
cd $srcdir ; abs_srcdir=`pwd` ; cd $WD
cd $execdir ; abs_execdir=`pwd` ; cd $WD
#DEBUG=1
#TRUEHOME=1
# Create RCHOME
if test "x$TRUEHOME" = x1 ; then
RCHOME="$HOME"
else
rm -fr rchome
mkdir rchome
cd rchome
RCHOME=`pwd`
cd ..
export NCRCENV_HOME="$RCHOME"
fi
# Now create a special directory
# And enter it to execute tests
rm -fr rcmergedir
mkdir rcmergedir
cd rcmergedir
WD=`pwd`
HOMERCFILES="$RCHOME/.ncrc $RCHOME/.daprc $RCHOME/.dodsrc"
LOCALRCFILES="$WD/.ncrc $WD/.daprc $WD/.dodsrc"
resetrc() {
rm -fr $HOMERCFILES
rm -f $LOCALRCFILES
unset NCRCENV_RC
rm -f tmpoutput.txt
rm -f allfiles1 allfiles2 allfiles3
}
union() {
if test "x$DEBUG" = x1 ; then
rm -f ../allfiles$1
for f in $HOMERCFILES $LOCALRCFILES; do
if test -f $f ; then cat $f >> ../allfiles$1 ; fi
done
fi
}
mergecase1() {
# create everything with different keys to test merge
resetrc
rm -f tmp_rcmerge.txt tmpoutput.txt
echo "for r=ncrc daprc dodsrc"
for r in "ncrc" "daprc" "dodsrc"; do
echo "${r}_home=${r}" >> $RCHOME/".${r}";
echo "${r}_local=${r}" >> $WD/".${r}"
done;
union 1
${abs_execdir}/tst_rcmerge |sort > tmpoutput.txt
# echo ">>merge1"; cat ${abs_srcdir}/ref_rcmerge1.txt;
# echo "====="; cat tmpoutput.txt
diff -b ${abs_srcdir}/ref_rcmerge1.txt tmpoutput.txt
}
mergecase2() {
# create with some same keys to test override
resetrc
rm -f tmp_rcmerge.txt tmpoutput.txt
for r in "ncrc" "daprc" "dodsrc" ; do
echo "${r}=${r}" >> $RCHOME/".${r}";
echo "${r}=${r}" >> $WD/".${r}"
done;
union 2
${abs_execdir}/tst_rcmerge |sort > tmpoutput.txt
diff -b ${abs_srcdir}/ref_rcmerge2.txt tmpoutput.txt
}
mergecase3() {
# Test cross file overrides
resetrc
rm -f tmp_rcmerge.txt tmpoutput.txt
echo "ncrc=ncrc1" >> $HOME/.ncrc
echo "ncrcx=ncrcx" >> $RCHOME/.ncrc
echo "ncrc=ncrc2" >> $RCHOME/.dodsrc
echo "daprc=daprc" >> $RCHOME/.daprc
echo "ncrc=ncrc1" >> $WD/.ncrc
echo "ncrcx=ncrcx" >> $WD/.ncrc
echo "ncrc=ncrc2" >> $WD/.dodsrc
echo "daprc=daprc" >> $WD/.daprc
echo "daprc=daprc" >> $WD/.dodsrc
echo "ncrcx=ncrcy" >> $WD/.dodsrc
union 3
${abs_execdir}/tst_rcmerge |sort -d > tmpoutput.txt
diff -b ${abs_srcdir}/ref_rcmerge3.txt tmpoutput.txt
}
resetrc
mergecase1
mergecase2
mergecase3
resetrc