From 571cf6b933388677e4135fa599585d0a243276c1 Mon Sep 17 00:00:00 2001 From: Dennis Heimbigner Date: Sat, 3 Nov 2018 11:51:10 -0600 Subject: [PATCH] Fix test run_diskless2.sh with LARGE_FILE_TESTS ret: https://github.com/Unidata/netcdf-c/issues/1162 The test nc_test/run_diskless2.sh fails when LARGE_FILE_TESTS is enabled. Since the goal of the test was to test out diskless+persist on a reasonably large file, I fixed by just limiting the file size to 1000000000L bytes. --- nc_test/CMakeLists.txt | 9 +++----- nc_test/Makefile.am | 6 ++--- nc_test/run_diskless2.sh | 48 +++++++++++++++++++--------------------- nc_test/tst_diskless4.c | 16 ++++---------- 4 files changed, 32 insertions(+), 47 deletions(-) diff --git a/nc_test/CMakeLists.txt b/nc_test/CMakeLists.txt index b26319666..0e5c94d1c 100644 --- a/nc_test/CMakeLists.txt +++ b/nc_test/CMakeLists.txt @@ -78,14 +78,11 @@ IF(BUILD_UTILITIES) add_sh_test(nc_test run_mmap) SET_TESTS_PROPERTIES(nc_test_run_mmap PROPERTIES RUN_SERIAL TRUE) ENDIF(BUILD_MMAP) - if(USE_NETCDF4) - IF(LARGE_FILE_TESTS) - add_sh_test(nc_test run_diskless2) - ENDIF(LARGE_FILE_TESTS) - ENDIF(USE_NETCDF4) add_sh_test(nc_test run_diskless5) add_sh_test(nc_test run_inmemory) - + IF(LARGE_FILE_TESTS) + add_sh_test(nc_test run_diskless2) + ENDIF() ENDIF(BUILD_UTILITIES) # Copy some test files from current source dir to out-of-tree build dir. diff --git a/nc_test/Makefile.am b/nc_test/Makefile.am index 2f19a1d29..23e16db04 100644 --- a/nc_test/Makefile.am +++ b/nc_test/Makefile.am @@ -60,7 +60,7 @@ endif check_PROGRAMS = $(TESTPROGRAMS) # Build Diskless test helpers -check_PROGRAMS += tst_diskless tst_diskless3 tst_diskless4 \ +check_PROGRAMS += tst_diskless tst_diskless3 tst_diskless4 \ tst_diskless5 tst_inmemory tst_open_mem if USE_NETCDF4 check_PROGRAMS += tst_diskless2 @@ -70,12 +70,10 @@ TESTS = $(TESTPROGRAMS) if BUILD_UTILITIES TESTS += run_diskless.sh run_diskless5.sh run_inmemory.sh -if USE_NETCDF4 if LARGE_FILE_TESTS TESTS += run_diskless2.sh endif endif -endif if USE_PNETCDF TESTS += run_pnetcdf_test.sh @@ -92,7 +90,7 @@ CMakeLists.txt # These files are created by the tests. CLEANFILES = nc_test_*.nc tst_*.nc t_nc.nc large_files.nc \ quick_large_files.nc tst_diskless3_file.cdl tst_diskless3_memory.cdl \ -tst_diskless4.cdl benchmark.nc +tst_diskless4.cdl ref_tst_diskless4.cdl benchmark.nc EXTRA_DIST += bad_cdf5_begin.nc run_cdf5.sh if ENABLE_CDF5 diff --git a/nc_test/run_diskless2.sh b/nc_test/run_diskless2.sh index 3c1a67f01..a6da0a5e7 100755 --- a/nc_test/run_diskless2.sh +++ b/nc_test/run_diskless2.sh @@ -12,48 +12,46 @@ if test "x$srcdir" = x ; then srcdir=`pwd`; fi CPU=`uname -p` OS=`uname` -#Constants +# Test diskless on a reasonably large file size + +# Try a large in-memory file +SIZE=1000000000 + FILE4=tst_diskless4.nc -# Compute the file size for tst_diskless4 -SIZE=0 -case $CPU in -*_64*) SIZE=3000000000;; -*) SIZE=1000000000;; -esac +# Uncomment to get timing +#TIME=time # Create the reference ncdump output for tst_diskless4 -rm -fr tst_diskless4.cdl -echo "netcdf tst_diskless4 {" >>tst_diskless4.cdl -echo "dimensions:" >>tst_diskless4.cdl -echo " dim = 1000000000 ;" >>tst_diskless4.cdl -echo "variables:" >>tst_diskless4.cdl -echo " byte var0(dim) ;" >>tst_diskless4.cdl -if test $SIZE = 3000000000 ; then -echo " byte var1(dim) ;" >>tst_diskless4.cdl -echo " byte var2(dim) ;" >>tst_diskless4.cdl -fi -echo "}" >>tst_diskless4.cdl +rm -fr ref_tst_diskless4.cdl +cat >ref_tst_diskless4.cdl < 1) { filesize = atol(argv[1]); - } else { - if(sizeof(size_t) == 4) - filesize = 1000000000L; - else if(sizeof(size_t) == 8) - filesize = 3000000000L; - else { - fprintf(stderr,"Cannot compute filesize\n"); - exit(1); - } - } + } else + filesize = 1000000000L; /* Test that we can malloc that much space */ memory = malloc(filesize); @@ -99,7 +91,7 @@ main(int argc, char **argv) switch (tag) { case Create: cmode = NC_CLOBBER; break; - case CreateDiskless: cmode = NC_CLOBBER|NC_DISKLESS|NC_WRITE; break; + case CreateDiskless: cmode = NC_CLOBBER|NC_DISKLESS|NC_PERSIST|NC_WRITE; break; case Open: cmode = 0; break; case OpenDiskless: cmode = NC_DISKLESS; break; }