Added a new test for h4 endianness. [NCF332]

This commit is contained in:
Ward Fisher 2015-05-28 17:13:15 -06:00
parent afa157f918
commit 64e0d2a44e
10 changed files with 28550 additions and 28467 deletions

View File

@ -391,7 +391,7 @@ IF(ENABLE_HDF4)
MESSAGE(FATAL_ERROR "Can't find or link to the hdf4 mfhdf library.")
ENDIF()
SET(HDF4_LIBRARIES ${HDF4_MFHDF_LIB} ${HDF4_DF_LIB})
SET(HDF4_LIBRARIES ${HDF4_DF_LIB} ${HDF4_MFHDF_LIB})
# End include files, libraries.
MESSAGE(STATUS "HDF4 libraries: ${HDF4_DF_LIB}, ${HDF4_MFHDF_LIB}")
@ -1115,7 +1115,7 @@ ENDMACRO()
# Build a binary used by a script, but don't make a test out of it.
MACRO(build_bin_test F)
ADD_EXECUTABLE(${F} ${F}.c)
TARGET_LINK_LIBRARIES(${F} netcdf)
TARGET_LINK_LIBRARIES(${F} netcdf ${ALL_TLL_LIBS})
IF(MSVC)
SET_TARGET_PROPERTIES(${F}
PROPERTIES LINK_FLAGS_DEBUG " /NODEFAULTLIB:MSVCRT"
@ -1161,14 +1161,10 @@ ENDMACRO()
MACRO(add_bin_test prefix F)
ADD_EXECUTABLE(${prefix}_${F} ${F}.c)
# Some tests explicitly depend on HDF5, e.g., ncdump_tst_h_scalar.
# Some others depend on HDF5_HL, e.g., nc_test4_tst_interops.
# Hence, we have to link the tests against those libraries.
# TODO see if we can implement a more fine-grained approach
TARGET_LINK_LIBRARIES(${prefix}_${F}
${ALL_TLL_LIBS}
netcdf
${HDF5_C_LIBRARIES}
${HDF5_HL_LIBRARIES}
)
IF(MSVC)
SET_TARGET_PROPERTIES(${prefix}_${F}

View File

@ -72,7 +72,7 @@ IF(USE_DAP)
ENDIF()
IF(USE_HDF4)
SET(TLL_LIBS ${TLL_LIBS} ${HDF4_LIBRARIES})
SET(TLL_LIBS ${HDF4_MFHDF_LIB} ${HDF4_DF_LIB} ${TLL_LIBS})
ENDIF()
IF(ENABLE_PNETCDF AND PNETCDF)

File diff suppressed because it is too large Load Diff

16646
libsrc/ncx.c

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -67,6 +67,8 @@ IF(USE_HDF4_FILE_TESTS AND NOT MSVC)
add_sh_test(nc_test4 tst_formatx_hdf4)
build_bin_test(tst_chunk_hdf4)
add_sh_test(nc_test4 run_chunk_hdf4)
add_bin_test(nc_test4 tst_h4_lendian)
ENDIF()

View File

@ -85,8 +85,8 @@ endif # BUILD_BENCHMARKS
# These are the tests for HDF4.
if USE_HDF4
check_PROGRAMS += tst_interops2 tst_chunk_hdf4
TESTS += tst_interops2 tst_formatx_hdf4.sh run_chunk_hdf4.sh
check_PROGRAMS += tst_interops2 tst_chunk_hdf4 tst_h4_lendian
TESTS += tst_interops2 tst_formatx_hdf4.sh run_chunk_hdf4.sh tst_h4_lendian
if USE_HDF4_FILE_TESTS
check_PROGRAMS += tst_interops3
TESTS += run_get_hdf4_files.sh tst_interops3
@ -122,7 +122,7 @@ ref_tst_xplatform2_1.nc ref_tst_xplatform2_2.nc ref_tst_dims.nc \
ref_tst_interops4.nc run_get_knmi_files.sh CMakeLists.txt \
run_grp_rename.sh tst_formatx_hdf4.sh \
run_chunk_hdf4.sh contiguous.hdf4 chunked.hdf4 \
tst_h5_endians.c
tst_h5_endians.c tst_h4_lendian.c
CLEANFILES = tst_mpi_parallel.bin cdm_sea_soundings.nc bm_chunking.nc \
bm_radar.nc bm_radar1.nc radar_3d_compression_test.txt \
@ -132,7 +132,7 @@ tst_*.nc tst_floats2_*.cdl tst_ints2_*.cdl tst_shorts2_*.cdl \
tst_elena_*.cdl tst_simple*.cdl tst_chunks.cdl pr_A1.* tauu_A1.* \
usi_01.* thetau_01.* tst_*.nc tst_*.h5 \
tst_grp_rename.cdl tst_grp_rename.nc tst_grp_rename.dmp ref_grp_rename.cdl \
foo1.nc tst_interops2.h4 tst_h5_endians.nc
foo1.nc tst_interops2.h4 tst_h5_endians.nc tst_h4_lendian.h4
if USE_HDF4_FILE_TESTS
DISTCLEANFILES = AMSR_E_L2_Rain_V10_200905312326_A.hdf \

85
nc_test4/tst_h4_lendian.c Normal file
View File

@ -0,0 +1,85 @@
/*! Testing for proper read of little-endian variables in an hdf4 file.
*
* Added to debug issue NCF-332. Based on code submitted by
* https://github.com/Unidata/netcdf-c/issues/113.
*/
#include <stdio.h>
#include <config.h>
#include <nc_tests.h>
#include <hdf5.h>
#include <H5DSpublic.h>
#include "mfhdf.h"
#define DIM1 5
#define DIM0 5
#define RANK 2
#define FILENAME "tst_h4_lendian.h4"
#define SDSNAME "data"
int create_hdf_file() {
int32 sd_id, sds_id, istat, sd_index;
int32 dims[2], start[2], edges[2], rank;
int16 array_data[DIM0][DIM1];
intn i, j, count;
start[0] = 0;
start[1] = 0;
edges[0] = DIM1;
edges[1] = DIM0;
// populate data array
count = 0;
for (j = 0; j < DIM0; j++)
{
for (i = 0; i < DIM1; i++)
array_data[j][i] = count++;
}
sd_id = SDstart(FILENAME, DFACC_CREATE);
sds_id = SDcreate(sd_id, SDSNAME, DFNT_LITEND|DFNT_INT16, RANK, edges);
istat = SDendaccess(sds_id);
istat = SDend(sd_id);
sd_id = SDstart(FILENAME, DFACC_WRITE);
sd_index = 0;
sds_id = SDselect(sd_id, sd_index);
istat = SDwritedata(sds_id, start, NULL, edges, (VOIDP)array_data);
istat = SDendaccess(sds_id);
istat = SDend(sd_id);
return 0;
}
/*! Standard main function.
*
*/
int main() {
int res = 0;
printf("Testing a read from an hdf4 file with a little-endian datatype.\n");
printf("\to Creating hdf file with little-endian datatypes....\t");
res = create_hdf_file();
if(res) {
printf("Failure: %d\n",res);
return res;
} else {
printf("Success.\n");
}
printf("\to Reading hdf4 file.\n");
printf("Finished.\n");
return 0;
}