mirror of
https://github.com/Unidata/netcdf-c.git
synced 2025-01-24 16:04:40 +08:00
5c07ebfd11
re: Issue https://github.com/Unidata/netcdf-c/issues/2656 Charlie Zender notes that *nc_open()* does not immediately detect that the given path refers to a file not in zarr format. Rather it fails later when trying to read the (meta-)data. The reason is that the Zarr format is highly decentralized. There is no easily testable magic number or superblock to look for. In effect the only way to see if a directory is Zarr is to successfully read it. It is possible to heuristically detect that a path refers to an NCZarr/Zarr file by doing a breadth-first search of the file tree starting at the given path. If the search encounters a file whose name starts with ".z", then assume it is a legitimate NCZarr/Zarr file. Of course, this test could be costly. One hopes that in practice that it is not. In addition to this fix, a corresponding test case was added. ## Other Changes re: PR https://github.com/Unidata/netcdf-c/pull/2529 There was an error under Cygwin for this PR that is fixed in this PR. The fix was to convert all *noinst_* references to *check_*.
83 lines
2.0 KiB
Bash
Executable File
83 lines
2.0 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
if test "x$srcdir" = x ; then srcdir=`pwd`; fi
|
|
. ../test_common.sh
|
|
|
|
. "$srcdir/test_nczarr.sh"
|
|
|
|
# Test ability to detect NCZarr/Zarr files
|
|
|
|
URL="${NCZARR_S3_TEST_HOST}/${NCZARR_S3_TEST_BUCKET}"
|
|
KEY="/netcdf-c"
|
|
|
|
THISDIR=`pwd`
|
|
RESULTSDIR=tmp_notzarr
|
|
sometestfailed=
|
|
|
|
testfailed() {
|
|
if test "x$1" != "x-51" ; then
|
|
echo "*** Failed"
|
|
sometestfailed=1
|
|
fi
|
|
}
|
|
|
|
rm -fr ${RESULTSDIR}
|
|
mkdir -p ${RESULTSDIR}
|
|
cd ${RESULTSDIR}
|
|
|
|
# Make test sets
|
|
mkdir empty.file # empty
|
|
mkdir notzarr.file # non-empty, non-zarr
|
|
echo "random data" >notzarr.file/notzarr.txt
|
|
if test "x$FEATURE_NCZARR_ZIP" = xyes ; then
|
|
mkdir empty
|
|
zip -r empty.zip empty
|
|
cp -r notzarr.file ./notzarr
|
|
zip -r notzarr.zip notzarr
|
|
rm -fr empty notzarr
|
|
fi
|
|
if test "x$FEATURE_S3TESTS" = xyes ; then
|
|
cat /dev/null > empty.txt
|
|
# not possible: ${execdir}/s3util -f notzarr.txt -u "https://${URL}" -k "/netcdf-c/empty.s3" upload
|
|
${execdir}/s3util -f notzarr.file/notzarr.txt -u "https://${URL}" -k "/netcdf-c/notzarr.s3/notzarr.txt" upload
|
|
fi
|
|
|
|
echo "Test empty file"
|
|
RET=`${execdir}/tst_notzarr "file://empty.file#mode=zarr,file"`
|
|
testfailed "$RET"
|
|
echo "Test non-zarr file"
|
|
RET=`${execdir}/tst_notzarr "file://notzarr.file#mode=zarr,file"`
|
|
testfailed "$RET"
|
|
|
|
if test "x$FEATURE_NCZARR_ZIP" = xyes ; then
|
|
echo "Test empty zip file"
|
|
RET=`${execdir}/tst_notzarr "file://empty.zip#mode=zarr,zip"`
|
|
testfailed "$RET"
|
|
echo "Test non-zarr zip file"
|
|
RET=`${execdir}/tst_notzarr "file://notzarr.zip#mode=zarr,zip"`
|
|
testfailed "$RET"
|
|
fi
|
|
|
|
if test "x$FEATURE_S3TESTS" = xyes ; then
|
|
if test 1 = 0 ; then
|
|
# This test is NA for S3
|
|
echo "Test empty S3 file"
|
|
KEY="/netcdf-c/empty.s3"
|
|
RET=`${execdir}/tst_notzarr "https://$URL${KEY}#mode=zarr,s3"`
|
|
testfailed "$RET"
|
|
fi
|
|
echo "Test non-zarr S3 file"
|
|
RET=`${execdir}/tst_notzarr "https://$URL/netcdf-c/notzarr.s3#mode=zarr,s3"`
|
|
testfailed "$RET"
|
|
fi
|
|
|
|
cd ${THISDIR}
|
|
|
|
# Cleanup
|
|
rm -fr ${RESULTSDIR}
|
|
if test "x$FEATURE_S3TESTS" = xyes ; then
|
|
awsdelete "/netcdf-c"
|
|
fi
|
|
|
|
exit 0
|