summaryrefslogtreecommitdiffstats
path: root/hl
diff options
context:
space:
mode:
authorAllen Byrne <byrn@hdfgroup.org>2009-10-01 13:55:43 (GMT)
committerAllen Byrne <byrn@hdfgroup.org>2009-10-01 13:55:43 (GMT)
commitfbf7f470e2f8c29994829ada8b4c01590d4cacc7 (patch)
treef0339640b34f150a16ecc23b6b3f6c350b6272f7 /hl
parentd495a52fdd306391bd01f2a22abda26666c6c705 (diff)
downloadhdf5-fbf7f470e2f8c29994829ada8b4c01590d4cacc7.zip
hdf5-fbf7f470e2f8c29994829ada8b4c01590d4cacc7.tar.gz
hdf5-fbf7f470e2f8c29994829ada8b4c01590d4cacc7.tar.bz2
[svn-r17565] Fix for Bug 1562. H5DS.c checked for other locations which need to account for platform dependent types in dealing with ds_list_t. Added generator program for test files of LE and BE dimension scales.
Tested: local linux, h5committest
Diffstat (limited to 'hl')
-rw-r--r--hl/src/H5DS.c18
-rw-r--r--hl/test/Makefile.am11
-rw-r--r--hl/test/Makefile.in39
-rw-r--r--hl/test/gen_test_ds.c585
4 files changed, 645 insertions, 8 deletions
diff --git a/hl/src/H5DS.c b/hl/src/H5DS.c
index f75e926..e15c132 100644
--- a/hl/src/H5DS.c
+++ b/hl/src/H5DS.c
@@ -129,6 +129,7 @@ herr_t H5DSattach_scale(hid_t did,
hssize_t nelmts;
hid_t sid; /* space ID */
hid_t tid = -1; /* attribute type ID */
+ hid_t ntid = -1; /* attribute native type ID */
hid_t aid = -1; /* attribute ID */
int rank; /* rank of dataset */
hsize_t *dims=NULL; /* dimension of the "REFERENCE_LIST" array */
@@ -472,6 +473,9 @@ herr_t H5DSattach_scale(hid_t did,
if((tid = H5Aget_type(aid)) < 0)
goto out;
+
+ if((ntid = H5Tget_native_type(tid, H5T_DIR_DEFAULT)) < 0)
+ goto out;
/* get and save the old reference(s) */
if((sid = H5Aget_space(aid)) < 0)
@@ -487,7 +491,7 @@ herr_t H5DSattach_scale(hid_t did,
if (dsbuf == NULL)
goto out;
- if (H5Aread(aid,tid,dsbuf) < 0)
+ if (H5Aread(aid,ntid,dsbuf) < 0)
goto out;
/* close */
@@ -495,6 +499,8 @@ herr_t H5DSattach_scale(hid_t did,
goto out;
if (H5Aclose(aid) < 0)
goto out;
+ if (H5Tclose(ntid) < 0)
+ goto out;
/*-------------------------------------------------------------------------
* create a new attribute
@@ -586,6 +592,7 @@ out:
H5E_BEGIN_TRY {
H5Sclose(sid);
H5Aclose(aid);
+ H5Tclose(ntid);
H5Tclose(tid);
} H5E_END_TRY;
return FAIL;
@@ -631,6 +638,7 @@ herr_t H5DSdetach_scale(hid_t did,
hid_t did_i; /* dataset ID in REFERENCE_LIST */
hid_t sid; /* space ID */
hid_t tid = -1; /* attribute type ID */
+ hid_t ntid = -1; /* attribute native type ID */
hid_t aid = -1; /* attribute ID */
int rank; /* rank of dataset */
ds_list_t *dsbuf = NULL; /* array of attribute data in the DS pointing to the dataset */
@@ -823,6 +831,9 @@ herr_t H5DSdetach_scale(hid_t did,
if((tid = H5Aget_type(aid)) < 0)
goto out;
+
+ if((ntid = H5Tget_native_type(tid, H5T_DIR_DEFAULT)) < 0)
+ goto out;
/* get and save the old reference(s) */
if((sid = H5Aget_space(aid)) < 0)
@@ -835,7 +846,7 @@ herr_t H5DSdetach_scale(hid_t did,
if(dsbuf == NULL)
goto out;
- if (H5Aread(aid,tid,dsbuf) < 0)
+ if (H5Aread(aid,ntid,dsbuf) < 0)
goto out;
for(i=0; i<nelmts; i++)
@@ -879,6 +890,8 @@ herr_t H5DSdetach_scale(hid_t did,
goto out;
if (H5Aclose(aid) < 0)
goto out;
+ if (H5Tclose(ntid) < 0)
+ goto out;
/*-------------------------------------------------------------------------
* check if we found the pointed dataset
@@ -961,6 +974,7 @@ out:
H5E_BEGIN_TRY {
H5Sclose(sid);
H5Aclose(aid);
+ H5Tclose(ntid);
H5Tclose(tid);
if (dsbuf)
diff --git a/hl/test/Makefile.am b/hl/test/Makefile.am
index bdc969d..d20b7d3 100644
--- a/hl/test/Makefile.am
+++ b/hl/test/Makefile.am
@@ -32,6 +32,17 @@ LDADD=$(LIBH5_HL) $(LIBH5TEST) $(LIBHDF5)
TEST_PROG=test_lite test_image test_table test_ds test_packet
check_PROGRAMS=$(TEST_PROG)
+# These programs generate test files for the tests. They don't need to be
+# compiled every time we want to test the library. However, putting
+# them in a conditional causes automake to generate rules so that they
+# can be built by hand. They can also be built by specifying
+# --enable-build-all at configure time.
+BUILD_ALL_PROGS=gen_test_ds
+
+if BUILD_ALL_CONDITIONAL
+ noinst_PROGRAMS=$(BUILD_ALL_PROGS)
+endif
+
# Temporary files. These files are the ones created by running `make test'.
CHECK_CLEANFILES+=combine_tables[1-2].h5 test_ds[1-9].h5 test_image[1-3].h5 \
test_lite[1-2].h5 test_table.h5 test_packet_table.h5 \
diff --git a/hl/test/Makefile.in b/hl/test/Makefile.in
index 5d4a2be..3121138 100644
--- a/hl/test/Makefile.in
+++ b/hl/test/Makefile.in
@@ -56,6 +56,7 @@ DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \
$(top_srcdir)/config/commence.am \
$(top_srcdir)/config/conclude.am COPYING
check_PROGRAMS = $(am__EXEEXT_1)
+@BUILD_ALL_CONDITIONAL_TRUE@noinst_PROGRAMS = $(am__EXEEXT_2)
TESTS = $(check_PROGRAMS)
subdir = hl/test
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
@@ -68,6 +69,8 @@ CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
am__EXEEXT_1 = test_lite$(EXEEXT) test_image$(EXEEXT) \
test_table$(EXEEXT) test_ds$(EXEEXT) test_packet$(EXEEXT)
+am__EXEEXT_2 = gen_test_ds$(EXEEXT)
+PROGRAMS = $(noinst_PROGRAMS)
test_ds_SOURCES = test_ds.c
test_ds_OBJECTS = test_ds.$(OBJEXT)
test_ds_LDADD = $(LDADD)
@@ -88,6 +91,10 @@ test_table_SOURCES = test_table.c
test_table_OBJECTS = test_table.$(OBJEXT)
test_table_LDADD = $(LDADD)
test_table_DEPENDENCIES = $(LIBH5_HL) $(LIBH5TEST) $(LIBHDF5)
+gen_test_ds_SOURCES = gen_test_ds.c
+gen_test_ds_OBJECTS = gen_test_ds.$(OBJEXT)
+gen_test_ds_LDADD = $(LDADD)
+gen_test_ds_DEPENDENCIES = $(LIBH5_HL) $(LIBH5TEST) $(LIBHDF5)
DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/src
depcomp = $(SHELL) $(top_srcdir)/bin/depcomp
am__depfiles_maybe = depfiles
@@ -102,9 +109,9 @@ LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
$(LDFLAGS) -o $@
SOURCES = test_ds.c test_image.c test_lite.c test_packet.c \
- test_table.c
+ test_table.c gen_test_ds.c
DIST_SOURCES = test_ds.c test_image.c test_lite.c test_packet.c \
- test_table.c
+ test_table.c gen_test_ds.c
ETAGS = etags
CTAGS = ctags
am__tty_colors = \
@@ -375,6 +382,13 @@ LDADD = $(LIBH5_HL) $(LIBH5TEST) $(LIBHDF5)
# order to be executed, generally most specific tests to least specific tests.
TEST_PROG = test_lite test_image test_table test_ds test_packet
+# These programs generate test files for the tests. They don't need to be
+# compiled every time we want to test the library. However, putting
+# them in a conditional causes automake to generate rules so that they
+# can be built by hand. They can also be built by specifying
+# --enable-build-all at configure time.
+BUILD_ALL_PROGS = gen_test_ds
+
# Automake needs to be taught how to build lib, progs, and tests targets.
# These will be filled in automatically for the most part (e.g.,
# lib_LIBRARIES are built for lib target), but EXTRA_LIB, EXTRA_PROG, and
@@ -433,6 +447,15 @@ clean-checkPROGRAMS:
list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \
echo " rm -f" $$list; \
rm -f $$list
+
+clean-noinstPROGRAMS:
+ @list='$(noinst_PROGRAMS)'; test -n "$$list" || exit 0; \
+ echo " rm -f" $$list; \
+ rm -f $$list || exit $$?; \
+ test -n "$(EXEEXT)" || exit 0; \
+ list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \
+ echo " rm -f" $$list; \
+ rm -f $$list
test_ds$(EXEEXT): $(test_ds_OBJECTS) $(test_ds_DEPENDENCIES)
@rm -f test_ds$(EXEEXT)
$(LINK) $(test_ds_OBJECTS) $(test_ds_LDADD) $(LIBS)
@@ -448,6 +471,9 @@ test_packet$(EXEEXT): $(test_packet_OBJECTS) $(test_packet_DEPENDENCIES)
test_table$(EXEEXT): $(test_table_OBJECTS) $(test_table_DEPENDENCIES)
@rm -f test_table$(EXEEXT)
$(LINK) $(test_table_OBJECTS) $(test_table_LDADD) $(LIBS)
+gen_test_ds$(EXEEXT): $(gen_test_ds_OBJECTS) $(gen_test_ds_DEPENDENCIES)
+ @rm -f gen_test_ds$(EXEEXT)
+ $(LINK) $(gen_test_ds_OBJECTS) $(gen_test_ds_LDADD) $(LIBS)
mostlyclean-compile:
-rm -f *.$(OBJEXT)
@@ -460,6 +486,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_lite.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_packet.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_table.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gen_test_ds.Po@am__quote@
.c.o:
@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@@ -574,7 +601,7 @@ check-am: all-am
$(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS)
$(MAKE) $(AM_MAKEFLAGS) check-TESTS
check: check-am
-all-am: Makefile all-local
+all-am: Makefile $(PROGRAMS) all-local
installdirs:
install: install-am
install-exec: install-exec-am
@@ -604,7 +631,7 @@ maintainer-clean-generic:
clean: clean-am
clean-am: clean-checkPROGRAMS clean-generic clean-libtool \
- mostlyclean-am
+ clean-noinstPROGRAMS mostlyclean-am
distclean: distclean-am
-rm -rf ./$(DEPDIR)
@@ -675,8 +702,8 @@ uninstall-am:
.MAKE: check-am install-am install-strip
.PHONY: CTAGS GTAGS all all-am all-local check check-TESTS check-am \
- clean clean-checkPROGRAMS clean-generic clean-libtool ctags \
- distclean distclean-compile distclean-generic \
+ clean clean-checkPROGRAMS clean-generic clean-libtool clean-noinstPROGRAMS \
+ ctags distclean distclean-compile distclean-generic \
distclean-libtool distclean-tags distdir dvi dvi-am html \
html-am info info-am install install-am install-data \
install-data-am install-dvi install-dvi-am install-exec \
diff --git a/hl/test/gen_test_ds.c b/hl/test/gen_test_ds.c
new file mode 100644
index 0000000..217412d
--- /dev/null
+++ b/hl/test/gen_test_ds.c
@@ -0,0 +1,585 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * 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 dimension scales.
+ *
+ * Compile and run this program to generate the "test_ds_xx.h5"
+ * file, where xx is "le" on a little-endian machine and "be"
+ * on a big-endian machine.
+ * Move it to the test directory in the current branch.
+ * The test: test_foreign_scaleattached(const char *fileforeign)
+ * in test_ds.c will read them.
+ */
+
+#include <stdlib.h>
+#include <string.h>
+#include "h5hltest.h"
+#include "H5DSpublic.h"
+#include "H5LTpublic.h"
+
+/* prototypes */
+herr_t create_long_dataset(hid_t fid, const char *dsname, const char *dsidx);
+herr_t test_attach_scale(hid_t fid, hid_t did, const char *name, unsigned int idx);
+herr_t test_set_scalename(hid_t fid, hid_t did, const char *name, const char *scalename, unsigned int idx);
+herr_t test_cmp_scalename(hid_t fid, hid_t did, const char *name, const char *scalename, unsigned int idx);
+
+static int test_long_attachscales(const char *filename);
+static int test_duplicatelong_attachscales(const char *filename);
+static int test_long_scalenames(const char *filename);
+static int test_samelong_scalenames(const char *filename);
+static int test_foreign_scaleattached(const char *filename);
+
+
+#define RANK 2
+#define DIM_DATA 12
+#define DIM1_SIZE 3
+#define DIM2_SIZE 4
+#define DIM3_SIZE 12
+#define DIM4_SIZE 2
+#define DIM0 0
+#define DIM1 1
+#define DIM2 2
+#define DIM3 3
+
+#define DATASET_NAME "dset_"
+#define DS_1_NAME "ds_1_"
+#define DS_2_NAME "ds_2_"
+#define DS_3_NAME "ds_3_"
+#define DS_4_NAME "ds_4_"
+
+#define SCALE_1_NAME "scalename_1_"
+#define SCALE_2_NAME "scalename_2_"
+#define SCALE_3_NAME "scalename_3_"
+#define SCALE_4_NAME "scalename_4_"
+
+#define FILENAME "test_ds_"
+#define FILEEXT ".h5"
+
+/*-------------------------------------------------------------------------
+ * the main program
+ *-------------------------------------------------------------------------
+ */
+int main(int argc , char **argv)
+{
+ int nerrors=0;
+ char filename[65];
+
+
+ if (argc < 2) {
+ printf("Usage: gen_test [le | be]\n");
+ return 1;
+ }
+
+ if ( argv[1] && (strcmp("le",argv[1])!=0) && (strcmp("be",argv[1])!=0) ) {
+ printf("Usage: gen_test [le | be]\n");
+ return 1;
+ }
+
+ /* create file to be used in following tests */
+ strcpy(filename, FILENAME);
+ strcat(filename, argv[1]);
+ strcat(filename, FILEEXT);
+ if(H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT) < 0) {
+ nerrors = 1;
+ goto error;
+ }
+ nerrors += test_long_attachscales(filename) < 0 ? 1 : 0;
+ nerrors += test_duplicatelong_attachscales(filename) < 0 ? 1 : 0;
+ nerrors += test_samelong_scalenames(filename) < 0 ? 1 : 0;
+ nerrors += test_foreign_scaleattached(filename) < 0 ? 1 : 0;
+
+
+ if(nerrors) goto error;
+ printf("Dimension scales file generation passed.\n");
+ return 0;
+
+error:
+ printf("***** %d DIMENSION SCALES FILE GENERATION FAILED! *****\n",nerrors);
+ return 1;
+}
+
+/*-------------------------------------------------------------------------
+ * create "data" dataset
+ *-------------------------------------------------------------------------
+ */
+
+herr_t create_long_dataset(hid_t fid, const char *dsname, const char *dsidx)
+{
+ int rank = 4;
+ int rankds = 1;
+ hsize_t dims[4] = {DIM1_SIZE,DIM2_SIZE,DIM3_SIZE,DIM4_SIZE};
+ long buf[DIM_DATA*3*2] = {1,2,3,4,5,6,7,8,9,10,11,12,
+ 1,2,3,4,5,6,7,8,9,10,11,12,1,2,3,4,5,6,7,8,9,10,11,12,
+ 1,2,3,4,5,6,7,8,9,10,11,12,1,2,3,4,5,6,7,8,9,10,11,12,
+ 1,2,3,4,5,6,7,8,9,10,11,12};
+ hsize_t s1_dim[1] = {DIM1_SIZE};
+ hsize_t s2_dim[1] = {DIM2_SIZE};
+ hsize_t s3_dim[1] = {DIM3_SIZE};
+ hsize_t s4_dim[1] = {DIM4_SIZE};
+ long s1_wbuf[DIM1_SIZE] = {10,20,30};
+ long s2_wbuf[DIM2_SIZE] = {100,200,300,400};
+ long s3_wbuf[DIM3_SIZE] = {10,10,10,20,20,20,30,30,30,40,40,40};
+ long s4_wbuf[DIM4_SIZE] = {18,18};
+ char name[32];
+
+ strcpy(name, dsname);
+
+ /* make a dataset */
+ if(H5LTmake_dataset_long(fid, name, rank, dims, buf) >= 0) {
+ /* make a DS dataset for the first dimension */
+ char dsname[32];
+
+ strcpy(dsname, DS_1_NAME);
+ strcat(dsname, dsidx);
+ /* make a DS dataset for the first dimension */
+ if(H5LTmake_dataset_long(fid, dsname, rankds, s1_dim, s1_wbuf) < 0)
+ return FAIL;
+
+ strcpy(dsname, DS_2_NAME);
+ strcat(dsname, dsidx);
+ /* make a DS dataset for the first dimension */
+ if(H5LTmake_dataset_long(fid, dsname, rankds, s2_dim, s2_wbuf) < 0)
+ return FAIL;
+
+ strcpy(dsname, DS_3_NAME);
+ strcat(dsname, dsidx);
+ /* make a DS dataset for the first dimension */
+ if(H5LTmake_dataset_long(fid, dsname, rankds, s3_dim, s3_wbuf) < 0)
+ return FAIL;
+
+ strcpy(dsname, DS_4_NAME);
+ strcat(dsname, dsidx);
+ /* make a DS dataset for the first dimension */
+ if(H5LTmake_dataset_long(fid, dsname, rankds, s4_dim, s4_wbuf) < 0)
+ return FAIL;
+ }
+ else
+ return FAIL;
+ return SUCCEED;
+}
+
+herr_t test_attach_scale(hid_t fid, hid_t did, const char *name, unsigned int idx)
+{
+ herr_t ret_value = FAIL;
+ hid_t dsid = -1;
+
+ if((dsid = H5Dopen2(fid, name, H5P_DEFAULT)) >= 0) {
+ if(H5DSis_attached(did, dsid, idx) == 0) {
+ if(H5DSattach_scale(did, dsid, idx) >= 0) {
+ if(H5DSis_attached(did, dsid, idx) > 0) {
+ /* printf(" scale attached "); */
+ ret_value = SUCCEED;
+ }
+ else if(H5DSis_attached(did, dsid, idx) == 0) {
+ printf(" scale not attached ");
+ }
+ }
+ }
+ if(H5Dclose(dsid) < 0)
+ ret_value = FAIL;
+ }
+
+ return ret_value;
+}
+
+herr_t test_detach_scale(hid_t fid, hid_t did, const char *name, unsigned int idx)
+{
+ herr_t ret_value = FAIL;
+ hid_t dsid = -1;
+
+ if((dsid = H5Dopen2(fid, name, H5P_DEFAULT)) >= 0) {
+ if(H5DSis_attached(did, dsid, idx) == 1) {
+ if(H5DSdetach_scale(did, dsid, idx) >= 0) {
+ if(H5DSis_attached(did, dsid, idx) == 0) {
+ ret_value = SUCCEED;
+ }
+ }
+ }
+ if(H5Dclose(dsid) < 0)
+ ret_value = FAIL;
+ }
+
+ return ret_value;
+}
+
+herr_t test_set_scalename(hid_t fid, hid_t did, const char *name, const char *scalename, unsigned int idx)
+{
+ herr_t ret_value = FAIL;
+ hid_t dsid = -1;
+
+ if((dsid = H5Dopen2(fid, name, H5P_DEFAULT)) >= 0) {
+ if(H5DSis_attached(did, dsid, idx) == 1) {
+ if(H5DSset_scale(dsid, scalename) >= 0) {
+ if(H5DSis_attached(did, dsid, idx) == 1) {
+ ret_value = SUCCEED;
+ }
+ }
+ }
+ if(H5Dclose(dsid) < 0)
+ ret_value = FAIL;
+ }
+
+ return ret_value;
+}
+
+herr_t test_cmp_scalename(hid_t fid, hid_t did, const char *name, const char *scalename, unsigned int idx)
+{
+ herr_t ret_value = FAIL;
+ hid_t dsid = -1;
+ ssize_t name_len;
+ char *name_out=NULL;
+
+ if((dsid = H5Dopen2(fid, name, H5P_DEFAULT)) >= 0) {
+ if(H5DSis_attached(did, dsid, idx) == 1) {
+ if((name_len=H5DSget_scale_name(dsid,NULL,(size_t)0)) > 0) {
+ name_out = (char*)malloc(name_len * sizeof (char));
+ if(name_out != NULL) {
+ if(H5DSget_scale_name(dsid, name_out, (size_t)name_len) >= 0) {
+ if(strcmp(scalename,name_out)==0) {
+ ret_value = SUCCEED;
+ }
+ free(name_out);
+ name_out=NULL;
+ }
+ }
+ }
+ }
+ if(H5Dclose(dsid) < 0)
+ ret_value = FAIL;
+ }
+
+ return ret_value;
+}
+
+static int test_long_attachscales(const char *filename)
+{
+ hid_t fid = -1;
+ hid_t did = -1;
+ char dsname[32];
+ char scalename[32];
+ strcpy(dsname, DATASET_NAME);
+ strcat(dsname, "al");
+
+ TESTING2("test_long_attachscales");
+
+ if((fid = H5Fopen(filename, H5F_ACC_RDWR, H5P_DEFAULT)) < 0)
+ goto out;
+
+ /* make a dataset */
+ if(create_long_dataset(fid, dsname, "al", 0) < 0)
+ goto out;
+
+ if((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) {
+ strcpy(scalename, DS_1_NAME);
+ strcat(scalename, "al");
+ if(test_attach_scale(fid, did, scalename, DIM0) < 0)
+ goto out;
+
+ strcpy(scalename, DS_2_NAME);
+ strcat(scalename, "al");
+ if(test_attach_scale(fid, did, scalename, DIM1) < 0)
+ goto out;
+
+ strcpy(scalename, DS_3_NAME);
+ strcat(scalename, "al");
+ if(test_attach_scale(fid, did, scalename, DIM2) < 0)
+ goto out;
+
+ strcpy(scalename, DS_4_NAME);
+ strcat(scalename, "al");
+ if(test_attach_scale(fid, did, scalename, DIM3) < 0)
+ goto out;
+
+ if(H5Dclose(did) < 0)
+ goto out;
+ }
+ else
+ goto out;
+
+ PASSED();
+
+ H5Fclose(fid);
+ return SUCCEED;
+
+out:
+ H5E_BEGIN_TRY {
+ H5Dclose(did);
+ H5Fclose(fid);
+ } H5E_END_TRY;
+
+ H5_FAILED();
+
+ return FAIL;
+}
+
+static int test_duplicatelong_attachscales(const char *filename)
+{
+ hid_t fid = -1;
+ hid_t did = -1;
+ char dsname[32];
+ char scalename[32];
+ strcpy(dsname, DATASET_NAME);
+ strcat(dsname, "al2");
+
+ TESTING2("test_duplicatelong_attachscales");
+
+ if((fid = H5Fopen(filename, H5F_ACC_RDWR, H5P_DEFAULT)) < 0)
+ goto out;
+
+ /* make a dataset 2 */
+ if(create_long_dataset(fid, dsname, "al2", 0) < 0)
+ goto out;
+
+ if((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) {
+ strcpy(scalename, DS_1_NAME);
+ strcat(scalename, "al");
+ if(test_attach_scale(fid, did, scalename, DIM0) < 0)
+ goto out;
+
+ strcpy(scalename, DS_2_NAME);
+ strcat(scalename, "al");
+ if(test_attach_scale(fid, did, scalename, DIM1) < 0)
+ goto out;
+
+ strcpy(scalename, DS_3_NAME);
+ strcat(scalename, "al");
+ if(test_attach_scale(fid, did, scalename, DIM2) < 0)
+ goto out;
+
+ strcpy(scalename, DS_4_NAME);
+ strcat(scalename, "al");
+ if(test_attach_scale(fid, did, scalename, DIM3) < 0)
+ goto out;
+
+ if(H5Dclose(did) < 0)
+ goto out;
+ }
+ else
+ goto out;
+
+ PASSED();
+
+ H5Fclose(fid);
+ return SUCCEED;
+
+out:
+ H5E_BEGIN_TRY {
+ H5Dclose(did);
+ H5Fclose(fid);
+ } H5E_END_TRY;
+
+ H5_FAILED();
+
+ return FAIL;
+}
+
+static int test_long_scalenames(const char *filename) {
+ hid_t fid = -1;
+ hid_t did = -1;
+ char dsname[32];
+ char scalename[32];
+ char name[32];
+ strcpy(dsname, DATASET_NAME);
+ strcat(dsname, "al");
+
+ if((fid = H5Fopen(filename, H5F_ACC_RDWR, H5P_DEFAULT)) < 0)
+ goto out;
+
+ TESTING2("set long scale/cmp scale name");
+ if((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) {
+ strcpy(scalename, DS_1_NAME);
+ strcat(scalename, "al");
+ strcpy(name, SCALE_1_NAME);
+ strcat(name, "al");
+ if(test_set_scalename(fid, did, scalename, name, DIM0) < 0)
+ goto out;
+
+ if(test_cmp_scalename(fid, did, scalename, name, DIM0) < 0)
+ goto out;
+
+ strcpy(scalename, DS_2_NAME);
+ strcat(scalename, "al");
+ strcpy(name, SCALE_2_NAME);
+ strcat(name, "al");
+ if(test_set_scalename(fid, did, scalename, name, DIM1) < 0)
+ goto out;
+
+ if(test_cmp_scalename(fid, did, scalename, name, DIM1) < 0)
+ goto out;
+
+ strcpy(scalename, DS_3_NAME);
+ strcat(scalename, "al");
+ strcpy(name, SCALE_3_NAME);
+ strcat(name, "al");
+ if(test_set_scalename(fid, did, scalename, name, DIM2) < 0)
+ goto out;
+
+ if(test_cmp_scalename(fid, did, scalename, name, DIM2) < 0)
+ goto out;
+
+ strcpy(scalename, DS_4_NAME);
+ strcat(scalename, "al");
+ strcpy(name, SCALE_4_NAME);
+ strcat(name, "al");
+ if(test_set_scalename(fid, did, scalename, name, DIM3) < 0)
+ goto out;
+
+ if(test_cmp_scalename(fid, did, scalename, name, DIM3) < 0)
+ goto out;
+
+ if(H5Dclose(did) < 0)
+ goto out;
+ }
+ else
+ goto out;
+
+ PASSED();
+
+ H5Fclose(fid);
+ return SUCCEED;
+
+out:
+ H5E_BEGIN_TRY {
+ H5Dclose(did);
+ H5Fclose(fid);
+ } H5E_END_TRY;
+
+ H5_FAILED();
+
+ return FAIL;
+}
+
+static int test_samelong_scalenames(const char *filename) {
+ hid_t fid = -1;
+ hid_t did = -1;
+ char dsname[32];
+ char scalename[32];
+ char name[32];
+ strcpy(dsname, DATASET_NAME);
+ strcat(dsname, "al2");
+
+ if((fid = open_test_file(fileext)) < 0)
+ goto out;
+
+ TESTING2("set same long scale/cmp scale name");
+ if((did = H5Fopen(filename, H5F_ACC_RDWR, H5P_DEFAULT)) >= 0) {
+ strcpy(scalename, DS_1_NAME);
+ strcat(scalename, "al");
+ strcpy(name, DS_1_NAME);
+ strcat(name, "al");
+ if(test_set_scalename(fid, did, scalename, name, DIM0) < 0)
+ goto out;
+
+ if(test_cmp_scalename(fid, did, scalename, name, DIM0) < 0)
+ goto out;
+
+ strcpy(scalename, DS_2_NAME);
+ strcat(scalename, "al");
+ strcpy(name, DS_2_NAME);
+ strcat(name, "al");
+ if(test_set_scalename(fid, did, scalename, name, DIM1) < 0)
+ goto out;
+
+ if(test_cmp_scalename(fid, did, scalename, name, DIM1) < 0)
+ goto out;
+
+ strcpy(scalename, DS_3_NAME);
+ strcat(scalename, "al");
+ strcpy(name, DS_3_NAME);
+ strcat(name, "al");
+ if(test_set_scalename(fid, did, scalename, name, DIM2) < 0)
+ goto out;
+
+ if(test_cmp_scalename(fid, did, scalename, name, DIM2) < 0)
+ goto out;
+
+ strcpy(scalename, DS_4_NAME);
+ strcat(scalename, "al");
+ strcpy(name, DS_4_NAME);
+ strcat(name, "al");
+ if(test_set_scalename(fid, did, scalename, name, DIM3) < 0)
+ goto out;
+
+ if(test_cmp_scalename(fid, did, scalename, name, DIM3) < 0)
+ goto out;
+
+ if(H5Dclose(did) < 0)
+ goto out;
+ }
+ else
+ goto out;
+
+ PASSED();
+
+ H5Fclose(fid);
+ return SUCCEED;
+
+out:
+ H5E_BEGIN_TRY {
+ H5Dclose(did);
+ H5Fclose(fid);
+ } H5E_END_TRY;
+
+ H5_FAILED();
+
+ return FAIL;
+}
+
+static int test_foreign_scaleattached(const char *filename)
+{
+ herr_t ret_value = FAIL;
+ hid_t fid = -1;
+ hid_t did = -1;
+ hid_t dsid = -1;
+
+ TESTING2("test_foreign_scaleattached");
+
+ if((fid = H5Fopen(filename, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0)
+ goto out;
+
+ if((did = H5Dopen2(fid, "/dset_al", H5P_DEFAULT)) >= 0) {
+ if((dsid = H5Dopen2(fid, "/ds_4_al", H5P_DEFAULT)) >= 0) {
+ if(H5DSis_attached(did, dsid, 3) == 1) {
+ ret_value = SUCCEED;
+ }
+ if(H5Dclose(dsid) < 0)
+ goto out;
+ }
+ if(H5Dclose(did) < 0)
+ goto out;
+ }
+ else
+ goto out;
+
+ if(ret_value == FAIL)
+ goto out;
+
+ PASSED();
+
+ H5Fclose(fid);
+ return 0;
+
+out:
+ H5E_BEGIN_TRY {
+ H5Dclose(did);
+ H5Fclose(fid);
+ } H5E_END_TRY;
+
+ H5_FAILED();
+
+ return FAIL;
+}