diff --git a/CMakeLists.txt b/CMakeLists.txt index a149e0fe4..8f80859b9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1623,6 +1623,7 @@ ENDIF(USE_HDF5) IF(USE_HDF4) add_subdirectory(libhdf4) + add_subdirectory(test_hdf4) ENDIF(USE_HDF4) IF(ENABLE_DAP2) diff --git a/configure.ac b/configure.ac index 726c0bda4..a981fb029 100644 --- a/configure.ac +++ b/configure.ac @@ -72,8 +72,8 @@ AC_CONFIG_LINKS([nc_test4/ref_hdf5_compat1.nc:nc_test4/ref_hdf5_compat1.nc]) AC_CONFIG_LINKS([nc_test4/ref_hdf5_compat2.nc:nc_test4/ref_hdf5_compat2.nc]) AC_CONFIG_LINKS([nc_test4/ref_hdf5_compat3.nc:nc_test4/ref_hdf5_compat3.nc]) -AC_CONFIG_LINKS([nc_test4/ref_chunked.hdf4:nc_test4/ref_chunked.hdf4]) -AC_CONFIG_LINKS([nc_test4/ref_contiguous.hdf4:nc_test4/ref_contiguous.hdf4]) +AC_CONFIG_LINKS([hdf4_test/ref_chunked.hdf4:hdf4_test/ref_chunked.hdf4]) +AC_CONFIG_LINKS([hdf4_test/ref_contiguous.hdf4:hdf4_test/ref_contiguous.hdf4]) AM_INIT_AUTOMAKE([foreign dist-zip subdir-objects]) @@ -1430,6 +1430,7 @@ AC_CONFIG_FILES([Makefile include/netcdf_meta.h include/Makefile h5_test/Makefile + hdf4_test/Makefile libsrc/Makefile libsrc4/Makefile libsrcp/Makefile diff --git a/hdf4_test/CMakeLists.txt b/hdf4_test/CMakeLists.txt new file mode 100644 index 000000000..190827ef1 --- /dev/null +++ b/hdf4_test/CMakeLists.txt @@ -0,0 +1,16 @@ +# Copy some test files from current source dir to out-of-tree build dir. +FILE(GLOB COPY_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.sh ${CMAKE_CURRENT_SOURCE_DIR}/*.hdf4) +FILE(COPY ${COPY_FILES} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/) +IF(MSVC) + FILE(COPY ${COPY_FILES} DESTINATION ${RUNTIME_OUTPUT_DIRECTORY}/) +ENDIF() + +IF(USE_HDF4_FILE_TESTS AND NOT MSVC) + build_bin_test_no_prefix(tst_interops2) + build_bin_test_no_prefix(tst_interops3) + add_bin_test(tst_chunk_hdf4) + add_bin_test(hdf4_test tst_h4_lendian) + add_sh_test(hdf4_test run_get_hdf4_files) + add_sh_test(hdf4_test run_formatx_hdf4) +ENDIF() + diff --git a/hdf4_test/Makefile.am b/hdf4_test/Makefile.am new file mode 100644 index 000000000..5bb7e8289 --- /dev/null +++ b/hdf4_test/Makefile.am @@ -0,0 +1,37 @@ +# This is part of the netCDF package. +# Copyright 2018 University Corporation for Atmospheric Research/Unidata +# See COPYRIGHT file for conditions of use. +# +# This directory has tests for the HDF4 code. This directory will be +# skipped if HDF4 is not enabled. +# +# Ed Hartnett + +# Put together AM_CPPFLAGS and AM_LDFLAGS. +include $(top_srcdir)/lib_flags.am + +# Link to our assembled library. +AM_LDFLAGS += ${top_builddir}/liblib/libnetcdf.la + +# These are the C tests for HDF4. +check_PROGRAMS = tst_chunk_hdf4 tst_h4_lendian +TESTS = tst_chunk_hdf4 tst_h4_lendian + +# This test script depends on ncdump and tst_interops2.c. +if BUILD_UTILITIES +check_PROGRAMS += tst_interops2 +TESTS += run_formatx_hdf4.sh +endif # BUILD_UTILITIES + +# This test script fetches HDF4 files from an FTP server and uses +# program tst_interops3.c to read them. +if USE_HDF4_FILE_TESTS +check_PROGRAMS += tst_interops3 +TESTS += run_get_hdf4_files.sh +endif # USE_HDF4_FILE_TESTS + +EXTRA_DIST = CMakeLists.txt ref_contiguous.hdf4 ref_chunked.hdf4 \ +run_get_hdf4_files.sh run_formatx_hdf4.sh + +CLEANFILES = *.h4 *.hdf + diff --git a/nc_test4/ref_chunked.hdf4 b/hdf4_test/ref_chunked.hdf4 similarity index 100% rename from nc_test4/ref_chunked.hdf4 rename to hdf4_test/ref_chunked.hdf4 diff --git a/nc_test4/ref_contiguous.hdf4 b/hdf4_test/ref_contiguous.hdf4 similarity index 100% rename from nc_test4/ref_contiguous.hdf4 rename to hdf4_test/ref_contiguous.hdf4 diff --git a/nc_test4/run_chunk_hdf4.sh b/hdf4_test/run_chunk_hdf4.sh similarity index 100% rename from nc_test4/run_chunk_hdf4.sh rename to hdf4_test/run_chunk_hdf4.sh diff --git a/nc_test4/run_get_hdf4_files.sh b/hdf4_test/run_get_hdf4_files.sh similarity index 100% rename from nc_test4/run_get_hdf4_files.sh rename to hdf4_test/run_get_hdf4_files.sh diff --git a/nc_test4/tst_chunk_hdf4.c b/hdf4_test/tst_chunk_hdf4.c similarity index 100% rename from nc_test4/tst_chunk_hdf4.c rename to hdf4_test/tst_chunk_hdf4.c diff --git a/nc_test4/tst_formatx_hdf4.sh b/hdf4_test/tst_formatx_hdf4.sh similarity index 55% rename from nc_test4/tst_formatx_hdf4.sh rename to hdf4_test/tst_formatx_hdf4.sh index f008fe3e1..67002a439 100755 --- a/nc_test4/tst_formatx_hdf4.sh +++ b/hdf4_test/tst_formatx_hdf4.sh @@ -25,8 +25,25 @@ echo "*** Fail: extended format for an HDF4 file: result=" $TMP ECODE=1 fi +# Clean up. rm -f tmp_tst_formatx_hdf4 -exit $ECODE +# Exit if there was a failure. +if test $ECODE = 1 ; then + exit $ECODE +fi +echo "" +echo "*** Testing reading an individual variable from an HDF4 file." + +${NCDUMP} -v hdf4_dataset_type_0 $FILE +${NCDUMP} -v hdf4_dataset_type_1 $FILE +${NCDUMP} -v hdf4_dataset_type_2 $FILE +${NCDUMP} -v hdf4_dataset_type_3 $FILE +${NCDUMP} -v hdf4_dataset_type_4 $FILE +${NCDUMP} -v hdf4_dataset_type_5 $FILE +${NCDUMP} -v hdf4_dataset_type_6 $FILE +${NCDUMP} -v hdf4_dataset_type_7 $FILE + +echo "*** Success." diff --git a/nc_test4/tst_h4_lendian.c b/hdf4_test/tst_h4_lendian.c similarity index 100% rename from nc_test4/tst_h4_lendian.c rename to hdf4_test/tst_h4_lendian.c diff --git a/nc_test4/tst_hdf4_read_var.sh b/hdf4_test/tst_hdf4_read_var.sh similarity index 100% rename from nc_test4/tst_hdf4_read_var.sh rename to hdf4_test/tst_hdf4_read_var.sh diff --git a/nc_test4/tst_interops2.c b/hdf4_test/tst_interops2.c similarity index 99% rename from nc_test4/tst_interops2.c rename to hdf4_test/tst_interops2.c index ee8c2ab44..2b7ff2681 100644 --- a/nc_test4/tst_interops2.c +++ b/hdf4_test/tst_interops2.c @@ -65,7 +65,7 @@ main(int argc, char **argv) /* Expected this to return NC_EPERM, but instead it returns * success. See github issue #744. */ - /* if (nc_def_var_chunking_ints(ncid, 0, NC_CONTIGUOUS, NULL) != NC_EPERM) ERR; */ + /* if (nc_def_var_chunking_ints(ncid, 0, NC_CONTIGUOUS, NULL)) ERR; */ /* Read the data through a vara function from the netCDF API. */ if (nc_get_vara(ncid, 0, nstart, ncount, data_in)) ERR; diff --git a/nc_test4/tst_interops3.c b/hdf4_test/tst_interops3.c similarity index 99% rename from nc_test4/tst_interops3.c rename to hdf4_test/tst_interops3.c index 4603e8866..166c50c66 100644 --- a/nc_test4/tst_interops3.c +++ b/hdf4_test/tst_interops3.c @@ -77,7 +77,6 @@ main(int argc, char **argv) "MOD29.A2000055.0005.005.2006267200024.hdf", "MYD29.A2002185.0000.005.2007160150627.hdf", "MYD29.A2009152.0000.005.2009153124331.hdf"}; - size_t len_in; int expected_mode = NC_NETCDF4; int expected_extended_format = NC_FORMATX_NC_HDF4; int f; diff --git a/nc_test4/Makefile.am b/nc_test4/Makefile.am index 6423d780e..417a0c630 100644 --- a/nc_test4/Makefile.am +++ b/nc_test4/Makefile.am @@ -95,26 +95,6 @@ benchmarks: check ./run_bm_ar4.sh endif # BUILD_BENCHMARKS -# These are the tests for HDF4. -if USE_HDF4 -check_PROGRAMS += tst_interops2 tst_chunk_hdf4 tst_h4_lendian - -if BUILD_UTILITIES -# This test script depends on ncdump. -TESTS += tst_interops2 tst_formatx_hdf4.sh -tst_formatx_hdf4.log: tst_interops2.log -endif # BUILD_UTILITIES - -TESTS += run_chunk_hdf4.sh tst_h4_lendian -if USE_HDF4_FILE_TESTS -check_PROGRAMS += tst_interops3 -TESTS += run_get_hdf4_files.sh tst_hdf4_read_var.sh - -tst_hdf4_read_var.log: tst_interops2.log - -endif # USE_HDF4_FILE_TESTS -endif # USE_HDF4 - # Szip Tests (requires ncdump) if USE_SZIP if BUILD_UTILITIES @@ -143,17 +123,15 @@ EXTRA_DIST = run_par_test.sh run_bm.sh run_bm_test1.sh \ run_bm_test2.sh run_bm_radar_2D.sh run_bm_radar_2D_compression1.sh \ run_par_bm_test.sh run_bm_elena.sh run_par_bm_radar_2D.sh \ run_bm_radar_2D_endianness1.sh run_tst_chunks.sh ref_chunks1.cdl \ -ref_chunks2.cdl run_get_hdf4_files.sh run_bm_ar4.sh \ -ref_tst_compounds.nc 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 tst_h5_endians.c tst_h4_lendian.c \ -tst_atts_string_rewrite.c tst_put_vars_two_unlim_dim.c \ -tst_empty_vlen_unlim.c run_empty_vlen_test.sh ref_hdf5_compat1.nc \ -ref_hdf5_compat2.nc ref_hdf5_compat3.nc tst_misc.sh tdset.h5 \ -tst_hdf4_read_var.sh ref_contiguous.hdf4 ref_chunked.hdf4 tst_szip.sh \ -ref_szip.h5 ref_szip.cdl tst_filter.sh bzip2.cdl filtered.cdl \ -unfiltered.cdl ref_bzip2.c findplugin.in +ref_chunks2.cdl run_bm_ar4.sh ref_tst_compounds.nc \ +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_h5_endians.c tst_atts_string_rewrite.c \ +tst_put_vars_two_unlim_dim.c tst_empty_vlen_unlim.c \ +run_empty_vlen_test.sh ref_hdf5_compat1.nc ref_hdf5_compat2.nc \ +ref_hdf5_compat3.nc tst_misc.sh tdset.h5 tst_szip.sh ref_szip.h5 \ +ref_szip.cdl tst_filter.sh bzip2.cdl filtered.cdl unfiltered.cdl \ +ref_bzip2.c findplugin.in CLEANFILES = tst_mpi_parallel.bin cdm_sea_soundings.nc bm_chunking.nc \ bm_radar.nc bm_radar1.nc radar_3d_compression_test.txt \ @@ -171,12 +149,4 @@ szip_dump.cdl DISTCLEANFILES = findplugin.sh -if USE_HDF4_FILE_TESTS -DISTCLEANFILES += AMSR_E_L2_Rain_V10_200905312326_A.hdf \ -AMSR_E_L3_DailyLand_V06_20020619.hdf \ -MYD29.A2009152.0000.005.2009153124331.hdf \ -MYD29.A2002185.0000.005.2007160150627.hdf \ -MOD29.A2000055.0005.005.2006267200024.hdf -endif # HDF4_FILE_TESTS - SUBDIRS=hdf5plugins