mirror of
https://github.com/Unidata/netcdf-c.git
synced 2024-11-27 07:30:33 +08:00
Incorporated endian test for [NCF-331] into autotools.
This commit is contained in:
parent
c43f9dee63
commit
6eff077ed5
@ -1,7 +1,7 @@
|
||||
# This is part of the netCDF package.
|
||||
# Copyright 2005 University Corporation for Atmospheric Research/Unidata
|
||||
# See COPYRIGHT file for conditions of use.
|
||||
#
|
||||
#
|
||||
# This entire directory will be skipped if netCDF-4 is not enabled.
|
||||
#
|
||||
|
||||
@ -21,7 +21,7 @@ tst_chunks tst_chunks2 tst_utf8 tst_fills tst_fills2 tst_fillbug \
|
||||
tst_xplatform tst_xplatform2 tst_h_atts2 tst_endian_fill tst_atts \
|
||||
t_type cdm_sea_soundings tst_camrun tst_vl tst_atts1 tst_atts2 \
|
||||
tst_vars2 tst_files5 tst_files6 tst_sync tst_h_strbug tst_h_refs \
|
||||
tst_h_scalar tst_rename
|
||||
tst_h_scalar tst_rename tst_endian_float
|
||||
|
||||
check_PROGRAMS = $(NC4_TESTS) renamegroup
|
||||
|
||||
@ -36,7 +36,7 @@ TESTS += run_grp_rename.sh
|
||||
|
||||
# If the v2 API was built, add its test program.
|
||||
if BUILD_V2
|
||||
check_PROGRAMS += tst_v2
|
||||
check_PROGRAMS += tst_v2
|
||||
TESTS += tst_v2
|
||||
endif # BUILD_V2
|
||||
|
||||
@ -76,8 +76,8 @@ TESTS += run_par_bm_test.sh
|
||||
endif # TEST_PARALLEL
|
||||
|
||||
benchmarks: check
|
||||
./run_bm_radar_2D.sh
|
||||
./run_bm_radar_2D_compression1.sh
|
||||
./run_bm_radar_2D.sh
|
||||
./run_bm_radar_2D_compression1.sh
|
||||
./run_bm.sh
|
||||
./run_tst_chunks.sh
|
||||
./run_bm_ar4.sh
|
||||
@ -140,9 +140,3 @@ MYD29.A2009152.0000.005.2009153124331.hdf \
|
||||
MYD29.A2002185.0000.005.2007160150627.hdf \
|
||||
MOD29.A2000055.0005.005.2006267200024.hdf
|
||||
endif # HDF4_FILE_TESTS
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -15,25 +15,35 @@
|
||||
#define NDIM 10
|
||||
#define NLON 20
|
||||
#define DIM_NAME "x"
|
||||
#define VAR_NAME "fv"
|
||||
#define VAR_NAME2 "iv"
|
||||
#define VAR_NAME2 "fv"
|
||||
#define VAR_NAME3 "iv"
|
||||
#define VAR_NAME "jv"
|
||||
int main() {
|
||||
|
||||
/*
|
||||
* 1. Create a file with endianness as desired.
|
||||
*/
|
||||
|
||||
int ncid, dimid, varid, varid2, retval;
|
||||
int ed, ed2;
|
||||
int ncid, dimid, varid, varid2, varid3, retval;
|
||||
int ed, ed2, ed3;
|
||||
int failures = 0;
|
||||
|
||||
|
||||
retval = nc_create(FILE_NAME, NC_NETCDF4 | NC_CLOBBER, &ncid);
|
||||
retval = nc_def_dim(ncid, DIM_NAME, NDIM, &dimid);
|
||||
|
||||
/* First, Float */
|
||||
retval = nc_def_var(ncid, VAR_NAME, NC_FLOAT, 1, &dimid, &varid);
|
||||
retval = nc_def_var_endian(ncid, varid, NC_ENDIAN_BIG);
|
||||
retval = nc_def_var(ncid, VAR_NAME2, NC_INT, 1, &dimid, &varid2);
|
||||
|
||||
/* Second, Float */
|
||||
retval = nc_def_var(ncid, VAR_NAME2, NC_FLOAT, 1, &dimid, &varid2);
|
||||
retval = nc_def_var_endian(ncid, varid2, NC_ENDIAN_BIG);
|
||||
|
||||
/* Third, Int */
|
||||
retval = nc_def_var(ncid, VAR_NAME3, NC_INT, 1, &dimid, &varid3);
|
||||
retval = nc_def_var_endian(ncid, varid3, NC_ENDIAN_BIG);
|
||||
|
||||
retval = nc_close(ncid);
|
||||
|
||||
/*
|
||||
@ -44,6 +54,7 @@ int main() {
|
||||
retval = nc_open(FILE_NAME, NC_NETCDF4 | NC_NOWRITE, &ncid);
|
||||
retval = nc_inq_varid(ncid,VAR_NAME,&varid);
|
||||
retval = nc_inq_varid(ncid,VAR_NAME2,&varid2);
|
||||
retval = nc_inq_varid(ncid,VAR_NAME3,&varid3);
|
||||
|
||||
retval = nc_inq_var_endian(ncid,varid,&ed);
|
||||
if(ed != NC_ENDIAN_BIG) {
|
||||
@ -55,12 +66,20 @@ int main() {
|
||||
|
||||
retval = nc_inq_var_endian(ncid,varid2,&ed2);
|
||||
if(ed2 != NC_ENDIAN_BIG) {
|
||||
printf("Test 2: Error for integer variable endianness: [%d] not NC_ENDIAN_BIG\n",ed2);
|
||||
printf("Test 2: Error for float variable endianness: [%d] not NC_ENDIAN_BIG\n",ed);
|
||||
failures++;
|
||||
} else {
|
||||
printf("Test 2: [%d] is NC_ENDIAN_BIG, Success.\n",ed2);
|
||||
}
|
||||
|
||||
retval = nc_inq_var_endian(ncid,varid3,&ed3);
|
||||
if(ed3 != NC_ENDIAN_BIG) {
|
||||
printf("Test 3: Error for integer variable endianness: [%d] not NC_ENDIAN_BIG\n",ed2);
|
||||
failures++;
|
||||
} else {
|
||||
printf("Test 3: [%d] is NC_ENDIAN_BIG, Success.\n",ed3);
|
||||
}
|
||||
|
||||
retval = nc_close(ncid);
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user