From 9726d77e95a770111c06e0ec160793185b01dd55 Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Thu, 24 Sep 2009 18:26:23 -0500 Subject: [svn-r17526] Description: Add backward compatibility test to make certain that the 1.8 library handles encountering a file with a fixed array chunk index gracefully. Tested on: FreeBSD/32 6.3 (duty) w/production (too minor to require h5committest) --- MANIFEST | 2 + test/Makefile.am | 6 +-- test/Makefile.in | 20 ++++++--- test/dsets.c | 62 +++++++++++++++++++++++++++ test/fixed_idx.h5 | Bin 0 -> 2158 bytes test/gen_idx.c | 126 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 207 insertions(+), 9 deletions(-) create mode 100644 test/fixed_idx.h5 create mode 100644 test/gen_idx.c diff --git a/MANIFEST b/MANIFEST index 9d736c5..0ff4cec 100644 --- a/MANIFEST +++ b/MANIFEST @@ -804,12 +804,14 @@ ./test/freespace.c ./test/fill_old.h5 ./test/fillval.c +./test/fixed_idx.h5 ./test/flush1.c ./test/flush2.c ./test/gen_bad_ohdr.c _DO_NOT_DISTRIBUTE_ ./test/gen_bogus.c _DO_NOT_DISTRIBUTE_ ./test/gen_cross.c _DO_NOT_DISTRIBUTE_ ./test/gen_deflate.c _DO_NOT_DISTRIBUTE_ +./test/gen_idx.c _DO_NOT_DISTRIBUTE_ ./test/gen_mergemsg.c _DO_NOT_DISTRIBUTE_ ./test/gen_new_array.c _DO_NOT_DISTRIBUTE_ ./test/gen_new_fill.c _DO_NOT_DISTRIBUTE_ diff --git a/test/Makefile.am b/test/Makefile.am index 84d1510..31eb462 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -59,9 +59,9 @@ check_PROGRAMS=$(TEST_PROG) error_test err_compat testmeta # --enable-build-all at configure time. # The gen_old_* files can only be compiled with older versions of the library # so do not appear in this list. -BUILD_ALL_PROGS=gen_bad_ohdr gen_bogus gen_cross gen_deflate gen_filters gen_new_array \ - gen_new_fill gen_new_group gen_new_mtime gen_new_super gen_noencoder \ - gen_nullspace gen_udlinks space_overflow +BUILD_ALL_PROGS=gen_bad_ohdr gen_bogus gen_cross gen_deflate gen_filters gen_idx \ + gen_new_array gen_new_fill gen_new_group gen_new_mtime gen_new_super \ + gen_noencoder gen_nullspace gen_udlinks space_overflow if BUILD_ALL_CONDITIONAL noinst_PROGRAMS=$(BUILD_ALL_PROGS) diff --git a/test/Makefile.in b/test/Makefile.in index fb769f3..67eb0f3 100644 --- a/test/Makefile.in +++ b/test/Makefile.in @@ -92,7 +92,7 @@ am__EXEEXT_2 = gen_bad_ohdr$(EXEEXT) gen_bogus$(EXEEXT) \ gen_new_group$(EXEEXT) gen_new_mtime$(EXEEXT) \ gen_new_super$(EXEEXT) gen_noencoder$(EXEEXT) \ gen_nullspace$(EXEEXT) gen_udlinks$(EXEEXT) \ - space_overflow$(EXEEXT) + space_overflow$(EXEEXT) gen_idx$(EXEEXT) PROGRAMS = $(noinst_PROGRAMS) app_ref_SOURCES = app_ref.c app_ref_OBJECTS = app_ref.$(OBJEXT) @@ -206,6 +206,10 @@ gen_filters_SOURCES = gen_filters.c gen_filters_OBJECTS = gen_filters.$(OBJEXT) gen_filters_LDADD = $(LDADD) gen_filters_DEPENDENCIES = libh5test.la $(LIBHDF5) +gen_idx_SOURCES = gen_idx.c +gen_idx_OBJECTS = gen_idx.$(OBJEXT) +gen_idx_LDADD = $(LDADD) +gen_idx_DEPENDENCIES = libh5test.la $(LIBHDF5) gen_new_array_SOURCES = gen_new_array.c gen_new_array_OBJECTS = gen_new_array.$(OBJEXT) gen_new_array_LDADD = $(LDADD) @@ -354,8 +358,8 @@ SOURCES = $(libh5test_la_SOURCES) app_ref.c big.c bittests.c btree2.c \ dt_arith.c dtransform.c dtypes.c enum.c err_compat.c \ error_test.c extend.c external.c fheap.c fillval.c flush1.c \ flush2.c freespace.c gen_bad_ohdr.c gen_bogus.c gen_cross.c \ - gen_deflate.c gen_filters.c gen_new_array.c gen_new_fill.c \ - gen_new_group.c gen_new_mtime.c gen_new_super.c \ + gen_deflate.c gen_filters.c gen_idx.c gen_new_array.c \ + gen_new_fill.c gen_new_group.c gen_new_mtime.c gen_new_super.c \ gen_noencoder.c gen_nullspace.c gen_udlinks.c getname.c \ gheap.c hyperslab.c istore.c lheap.c links.c mf.c mount.c \ mtime.c ntypes.c objcopy.c ohdr.c pool.c reserved.c \ @@ -366,8 +370,8 @@ DIST_SOURCES = $(libh5test_la_SOURCES) app_ref.c big.c bittests.c \ dsets.c dt_arith.c dtransform.c dtypes.c enum.c err_compat.c \ error_test.c extend.c external.c fheap.c fillval.c flush1.c \ flush2.c freespace.c gen_bad_ohdr.c gen_bogus.c gen_cross.c \ - gen_deflate.c gen_filters.c gen_new_array.c gen_new_fill.c \ - gen_new_group.c gen_new_mtime.c gen_new_super.c \ + gen_deflate.c gen_filters.c gen_idx.c gen_new_array.c \ + gen_new_fill.c gen_new_group.c gen_new_mtime.c gen_new_super.c \ gen_noencoder.c gen_nullspace.c gen_udlinks.c getname.c \ gheap.c hyperslab.c istore.c lheap.c links.c mf.c mount.c \ mtime.c ntypes.c objcopy.c ohdr.c pool.c reserved.c \ @@ -687,7 +691,7 @@ TEST_PROG = testhdf5 lheap ohdr stab gheap cache cache_api \ # so do not appear in this list. BUILD_ALL_PROGS = gen_bad_ohdr gen_bogus gen_cross gen_deflate gen_filters gen_new_array \ gen_new_fill gen_new_group gen_new_mtime gen_new_super gen_noencoder \ - gen_nullspace gen_udlinks space_overflow + gen_nullspace gen_udlinks space_overflow gen_idx # The libh5test library provides common support code for the tests. @@ -880,6 +884,9 @@ gen_deflate$(EXEEXT): $(gen_deflate_OBJECTS) $(gen_deflate_DEPENDENCIES) gen_filters$(EXEEXT): $(gen_filters_OBJECTS) $(gen_filters_DEPENDENCIES) @rm -f gen_filters$(EXEEXT) $(LINK) $(gen_filters_OBJECTS) $(gen_filters_LDADD) $(LIBS) +gen_idx$(EXEEXT): $(gen_idx_OBJECTS) $(gen_idx_DEPENDENCIES) + @rm -f gen_idx$(EXEEXT) + $(LINK) $(gen_idx_OBJECTS) $(gen_idx_LDADD) $(LIBS) gen_new_array$(EXEEXT): $(gen_new_array_OBJECTS) $(gen_new_array_DEPENDENCIES) @rm -f gen_new_array$(EXEEXT) $(LINK) $(gen_new_array_OBJECTS) $(gen_new_array_LDADD) $(LIBS) @@ -1006,6 +1013,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gen_cross.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gen_deflate.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gen_filters.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gen_idx.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gen_new_array.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gen_new_fill.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gen_new_group.Po@am__quote@ diff --git a/test/dsets.c b/test/dsets.c index 2876dad..cf6322c 100644 --- a/test/dsets.c +++ b/test/dsets.c @@ -178,6 +178,11 @@ const char *FILENAME[] = { #define BYPASS_CHUNK_DIM 500 #define BYPASS_FILL_VALUE 7 +/* Declarations for test_idx_compatible() */ +#define FIXED_IDX_FILE "fixed_idx.h5" +#define DSET "dset" +#define DSET_FILTER "dset_filter" + /* Shared global arrays */ #define DSET_DIM1 100 #define DSET_DIM2 200 @@ -7242,6 +7247,62 @@ error: return -1; } /* end test_chunk_expand() */ +/*------------------------------------------------------------------------- + * + * test_idx_compatible(): + * Verify that the 1.8 branch cannot read datasets that use + * Fixed Array indexing method. + * + *------------------------------------------------------------------------- + */ +static herr_t +test_idx_compatible(void) +{ + hid_t fid; /* File id */ + hid_t did; /* Dataset id */ + char *srcdir = HDgetenv("srcdir"); /* where the src code is located */ + char filename[FILENAME_BUF_SIZE] = ""; /* old test file name */ + + /* Output message about test being performed */ + TESTING("Compatibility for datasets that use Fixed Array indexing\n"); + + /* Generate correct name for test file by prepending the source path */ + if(srcdir && ((HDstrlen(srcdir) + HDstrlen(FIXED_IDX_FILE) + 1) < sizeof(filename))) { + HDstrcpy(filename, srcdir); + HDstrcat(filename, "/"); + } + HDstrcat(filename, FIXED_IDX_FILE); + + /* Open the file */ + if((fid = H5Fopen(filename, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + + /* Should not able to read the dataset w/o filter that use Fixed Array indexing */ + H5E_BEGIN_TRY { + if((did = H5Dopen2(fid, DSET, H5P_DEFAULT)) != FAIL) + TEST_ERROR + } H5E_END_TRY; + + /* Should not able to read the dataset w/ filter that use Fixed Array indexing */ + H5E_BEGIN_TRY { + if((did = H5Dopen2(fid, DSET_FILTER, H5P_DEFAULT)) != FAIL) + TEST_ERROR + } H5E_END_TRY; + + if(H5Fclose(fid) < 0) + FAIL_STACK_ERROR + + PASSED(); + return 0; + +error: + H5E_BEGIN_TRY { + H5Dclose(did); + H5Fclose(fid); + } H5E_END_TRY; + return -1; +} /* test_idx_compatible */ + /*------------------------------------------------------------------------- * Function: main @@ -7366,6 +7427,7 @@ main(void) nerrors += (test_chunk_cache(my_fapl) < 0 ? 1 : 0); nerrors += (test_big_chunks_bypass_cache(my_fapl) < 0 ? 1 : 0); nerrors += (test_chunk_expand(my_fapl) < 0 ? 1 : 0); + nerrors += (test_idx_compatible() < 0 ? 1 : 0); if(H5Fclose(file) < 0) goto error; diff --git a/test/fixed_idx.h5 b/test/fixed_idx.h5 new file mode 100644 index 0000000..b9971b2 Binary files /dev/null and b/test/fixed_idx.h5 differ diff --git a/test/gen_idx.c b/test/gen_idx.c new file mode 100644 index 0000000..6282574 --- /dev/null +++ b/test/gen_idx.c @@ -0,0 +1,126 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Purpose: This program is run to generate an HDF5 data file with datasets + * that use the B-tree indexing method. + * + * To test compatibility, compile and run this program + * which will generate a file called "btree_idx_1_8.h5". + * Move it to the test directory in the current branch. + * The test: test_idx_compatible() in dsets.c will read it. + */ +#include +#include "hdf5.h" + +const char *FILENAME[1] = { + "btree_idx_1_8.h5" /* file with datasets that use B-tree indexing method */ +}; + +#define DSET "dset" +#define DSET_FILTER "dset_filter" + +/* + * Function: gen_idx_file + * + * Purpose: Create a file with datasets that use B-tree indexing: + * one dataset: fixed dimension, chunked layout, w/o filters + * one dataset: fixed dimension, chunked layout, w/ filters + * + */ +static void gen_idx_file(void) +{ + hid_t fapl; /* file access property id */ + hid_t fid; /* file id */ + hid_t sid; /* space id */ + hid_t dcpl; /* dataset creation property id */ + hid_t did, did2; /* dataset id */ + hsize_t dims[1] = {10}; /* dataset dimension */ + hsize_t c_dims[1] = {2}; /* chunk dimension */ + herr_t status; /* return status */ + int i; /* local index variable */ + int buf[10]; /* data buffer */ + + + /* Get a copy of the file aaccess property */ + fapl = H5Pcreate(H5P_FILE_ACCESS); + assert(fapl >= 0); + + /* Set the "use the latest format" bounds for creating objects in the file */ + status = H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST); + assert(status >= 0); + + /* Create dataset */ + fid = H5Fcreate(FILENAME[0], H5F_ACC_TRUNC, H5P_DEFAULT, fapl); + assert(fid >= 0); + + /* Create data */ + for(i = 0; i < 10; i++) + buf[i] = i; + + /* Set chunk */ + dcpl = H5Pcreate(H5P_DATASET_CREATE); + assert(dcpl >= 0); + status = H5Pset_chunk(dcpl, 1, c_dims); + assert(status >= 0); + + sid = H5Screate_simple(1, dims, NULL); + assert(sid >= 0); + + /* Create a 1D dataset */ + did = H5Dcreate2(fid, DSET, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT); + assert(did >= 0); + + /* Write to the dataset */ + status = H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf); + assert(status >= 0); + +#if defined (H5_HAVE_FILTER_DEFLATE) + /* set deflate data */ + status = H5Pset_deflate(dcpl, 9); + assert(status >= 0); + + /* Create and write the dataset */ + did2 = H5Dcreate2(fid, DSET_FILTER, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT); + assert(did2 >= 0); + status = H5Dwrite(did2, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf); + assert(status >= 0); + + /* Close the dataset */ + status = H5Dclose(did2); + assert(status >= 0); + +#endif + + /* Closing */ + status = H5Dclose(did); + assert(status >= 0); + status = H5Sclose(sid); + assert(status >= 0); + status = H5Pclose(dcpl); + assert(status >= 0); + status = H5Pclose(fapl); + assert(status >= 0); + status = H5Fclose(fid); + assert(status >= 0); + +} /* gen_idx_file() */ + +int main(void) +{ + gen_idx_file(); + + return 0; +} -- cgit v0.12