1#!/bin/sh
2# This shell script runs the ncdump tests.
3# Dennis Heimbigner
4
5if test "x$srcdir" = x ; then srcdir="."; fi
6. ../test_common.sh
7
8##
9# Function to test a netCDF CDL file.
10# First generate binary nc. Then use ncdump to compare against
11# original CDL file.
12# Input: CDL file name, minus the suffix, output filename
13# Other input: arguments.
14#
15# Example:
16#     $ validateNC compound_datasize_test -k nc4
17##
18validateNC() {
19    ORIGNAME=$1
20    BASENAME=tst_$1_run_ncgen_nc4_tests
21    INFILE=$top_srcdir/ncgen/$1.cdl
22    TMPFILE=tst_$2.cdl
23    shift
24    shift
25    ARGS=$@
26
27    echo "*** generating $BASENAME.nc ***"
28    ${NCGEN} $ARGS -o $BASENAME.nc $INFILE
29    ${NCDUMP} -n $ORIGNAME $BASENAME.nc | sed 's/e+0/e+/g' > $TMPFILE
30    echo "*** comparing binary against source CDL file *** "
31    diff -b -w $INFILE $TMPFILE
32}
33
34echo "*** Testing ncgen for netCDF-4."
35set -e
36
37echo "*** creating netCDF-4 file c0_4.nc from c0_4.cdl..."
38validateNC "c0_4" "c0_4" -k nc4 -b -o c0_4.nc
39
40echo "*** creating netCDF-4 classic model file c0_4c.nc from c0.cdl..."
41validateNC "c0" "c0_4c" -k nc7 -b
42
43echo "*** creating C code for CAM file ref_camrun.cdl..."
44${NCGEN} -lc $top_srcdir/ncgen/ref_camrun.cdl > camrun.c
45
46echo "*** test for jira NCF-199 bug"
47validateNC "ncf199" "ncf199" -k nc4
48
49if test "x$NC_VLEN_NOTEST" = x ; then
50echo "*** creating binary files for github issue 323..."
51echo "*** github issue 323 test 1"
52validateNC "compound_datasize_test" "compound_datasize_test" -k nc4
53fi
54
55echo "*** github issue 323 test 2"
56validateNC "compound_datasize_test2" "compound_datasize_test2"  -k nc4
57
58echo "*** Global Attribute with Enum type"
59validateNC "tst_gattenum" "tst_gattenum"  -k nc4
60
61echo "*** Integer constant with just 'u' suffix"
62validateNC "tst_usuffix" "tst_usuffix"  -k nc4
63
64echo "*** Test successful!"
65exit 0
66