2014-03-08 13:52:40 +08:00
|
|
|
#!/bin/sh
|
2017-03-09 08:01:10 +08:00
|
|
|
|
|
|
|
if test "x$srcdir" = x ; then srcdir=`pwd`; fi
|
|
|
|
. ../test_common.sh
|
|
|
|
|
2014-03-08 13:52:40 +08:00
|
|
|
# This shell script tests BOM support in ncgen
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
# add hack for sunos
|
|
|
|
export srcdir;
|
|
|
|
|
|
|
|
echo ""
|
|
|
|
|
2022-11-09 11:12:38 +08:00
|
|
|
rm -f tst_bom.cdl tmp_bom.cdl tst_bom8.* tst_bom16.*
|
2014-03-08 13:52:40 +08:00
|
|
|
|
|
|
|
cat <<EOF >>tst_bom.cdl
|
|
|
|
netcdf tst_bom {
|
|
|
|
variables:
|
|
|
|
float f;
|
|
|
|
data:
|
|
|
|
|
|
|
|
f = 1;
|
|
|
|
}
|
|
|
|
EOF
|
|
|
|
|
|
|
|
echo "*** Generate a cdl file with leading UTF-8 BOM."
|
2017-03-09 08:01:10 +08:00
|
|
|
${execdir}/bom 8 >tst_bom8.cdl
|
2014-03-08 13:52:40 +08:00
|
|
|
cat tst_bom.cdl >> tst_bom8.cdl
|
|
|
|
|
|
|
|
echo "*** Verify .nc file"
|
2017-03-09 08:01:10 +08:00
|
|
|
${NCGEN} -k nc3 -o tst_bom8.nc tst_bom8.cdl
|
2022-11-09 11:12:38 +08:00
|
|
|
${NCDUMP} -n tst_bom tst_bom8.nc > tmp_bom.cdl
|
|
|
|
diff -w tst_bom.cdl tmp_bom.cdl
|
2014-03-08 13:52:40 +08:00
|
|
|
|
|
|
|
# Do it again but with Big-Endian 16; should fail
|
|
|
|
|
2022-11-09 11:12:38 +08:00
|
|
|
rm -f tmp_bom.cdl tst_bom8.* tst_bom16.*
|
2014-03-08 13:52:40 +08:00
|
|
|
|
|
|
|
echo "*** Generate a cdl file with leading UTF-16 BOM."
|
2017-03-09 08:01:10 +08:00
|
|
|
${execdir}/bom 16 >tst_bom16.cdl
|
2014-03-08 13:52:40 +08:00
|
|
|
cat tst_bom.cdl >> tst_bom16.cdl
|
|
|
|
|
|
|
|
echo "*** Verify UTF-16 file fails"
|
2017-03-09 08:01:10 +08:00
|
|
|
if ${NCGEN} -k nc3 -o tst_bom16.nc tst_bom16.cdl ; then
|
2014-03-08 13:52:40 +08:00
|
|
|
echo 'BOM Big Endian 16 succeeded, but should not'
|
|
|
|
exit 1
|
|
|
|
else
|
2014-03-09 11:41:30 +08:00
|
|
|
echo '***XFAIL : BOM Big Endian 16'
|
2014-03-08 13:52:40 +08:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Cleanup
|
2022-11-09 11:12:38 +08:00
|
|
|
rm -f tst_bom.cdl tmp_bom.cdl tst_bom8.* tst_bom16.*
|
2014-03-08 13:52:40 +08:00
|
|
|
|
|
|
|
exit 0
|