netcdf-c/nczarr_test/run_interop.sh
Dennis Heimbigner 36102e3c32 Improve UTF8 Support On Windows
re: Issue https://github.com/Unidata/netcdf-c/issues/2190

The primary purpose of this PR is to improve the utf8 support
for windows. This is persuant to a change in Windows that
supports utf8 natively (almost). The almost means that it is
still utf16 internally and the set of characters representable
by utf8 is larger than those representable by utf16.

This leaves open the question in the Issue about handling
the Windows 1252 character set.

This required the following changes:

1. Test the Windows build and major version in order to see if
   native utf8 is supported.
2. If native utf8 is supported, Modify dpathmgr.c to call the 8-bit
   version of the windows fopen() and open() functions.
3. In support of this, programs that use XGetOpt (Windows versions)
   need to get the command line as utf8 and then parse to
   arc+argv as utf8. This requires using a homegrown command line parser
   named XCommandLineToArgvA.
4. Add a utility program called "acpget" that prints out the
   current Windows code page and locale.

Additionally, some technical debt was cleaned up as follows:

1. Unify all the places which attempt to read all or a part
   of a file into the dutil.c#NC_readfile code.
2. Similary unify all the code that creates temp files into
   dutil.c#NC_mktmp code.
3. Convert almost all remaining calls to fopen() and open()
   to NCfopen() and NCopen3(). This is to ensure that path management
   is used consistently. This touches a number of files.
4. extern->EXTERNL as needed to get it to work under Windows.
2022-02-08 20:53:30 -07:00

94 lines
2.4 KiB
Bash
Executable File

#!/bin/sh
if test "x$srcdir" = x ; then srcdir=`pwd`; fi
. ../test_common.sh
. "$srcdir/test_nczarr.sh"
# This shell script tests compatibility between
# this implementation and other implementations
# by means of files constructed by that other implementation
set -e
UH="${NCZARR_S3_TEST_HOST}"
UB="${NCZARR_S3_TEST_BUCKET}"
testcasefile() {
zext=file
ref=$1
mode=$2
metaonly=$3
if test "x$metaonly" = xmetaonly ; then flags="-h"; fi
fileargs ${execdir}/$ref "mode=$mode,$zext"
rm -f tmp_${ref}_${zext}.cdl
${NCDUMP} $flags $fileurl > tmp_${ref}_${zext}.cdl
diff -b ${srcdir}/${ref}.cdl tmp_${ref}_${zext}.cdl
}
testcasezip() {
zext=zip
ref=$1
mode=$2
fileargs $ref "mode=$mode,$zext"
rm -f tmp_${ref}_${zext}.cdl
${NCDUMP} -h $flags $fileurl > tmp_${ref}_${zext}.cdl
diff -b ${srcdir}/${ref}.cdl tmp_${ref}_${zext}.cdl
}
testcases3() {
zext=s3
zarr=$1
ref=$2
mode=$3
rm -f tmp_${zarr}_${zext}.cdl
url="https://${UH}/${UB}/${zarr}#mode=${mode},s3"
${NCDUMP} $url > tmp_${zarr}_${zext}.cdl
diff -b ${srcdir}/${ref}.cdl tmp_${zarr}_${zext}.cdl
}
testallcases() {
zext=$1
case "$zext" in
file)
# need to unpack
rm -fr ref_power_901_constants ref_power_901_constants.file
unzip ${srcdir}/ref_power_901_constants.zip > /dev/null
mv ref_power_901_constants ref_power_901_constants.file
testcasefile ref_power_901_constants zarr metaonly; # test xarray as default
;;
zip)
# Move into position
if test "x$srcdir" != "x$execdir" ; then
cp ${srcdir}/ref_power_901_constants.zip ${execdir}
cp ${srcdir}/ref_quotes.zip ${execdir}
fi
testcasezip ref_power_901_constants xarray metaonly
# Test large constant interoperability
testcasezip ref_quotes zarr metaonly
;;
s3)
# Read a test case created by netcdf-java zarr.
# Move into position
rm -f ${execdir}/ref_zarr_test_data.cdl
# Use gunzip because it always appears to be available
if ! test -f ${srcdir}/ref_zarr_test_data.cdl ; then
gunzip -c ${srcdir}/ref_zarr_test_data.cdl.gz > ${srcdir}/ref_zarr_test_data.cdl
fi
testcases3 zarr_test_data.zarr ref_zarr_test_data xarray
;;
*) echo "unimplemented kind: $1" ; exit 1;;
esac
}
testallcases file
if test "x$FEATURE_NCZARR_ZIP" = xyes ; then testallcases zip; fi
if test "x$FEATURE_S3TESTS" = xyes ; then testallcases s3; fi
exit
# Cleanup
rm -fr ${execdir}/ref_power_901_constants.file
rm -f ${execdir}/ref_zarr_test_data.cdl
exit 0