summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobb Matzke <matzke@llnl.gov>1998-06-04 22:28:11 (GMT)
committerRobb Matzke <matzke@llnl.gov>1998-06-04 22:28:11 (GMT)
commit15f2fb818498d5c1c377041493382a29e0d71a45 (patch)
tree3060276f664cb5febe611faa1f6101acd9a3e80b
parentb4c5e3e00965f4ba6bd6b865cbde3bd33fcdbe47 (diff)
downloadhdf5-15f2fb818498d5c1c377041493382a29e0d71a45.zip
hdf5-15f2fb818498d5c1c377041493382a29e0d71a45.tar.gz
hdf5-15f2fb818498d5c1c377041493382a29e0d71a45.tar.bz2
[svn-r408] ./test/dtypes.c
Added tests for transient and named types and their use in datasets. ./test/shtype.c Commented out all the tests since they no longer apply. ./test/chunk.c Removed a couple int->double coercion warnings.
-rw-r--r--test/.distdep144
-rw-r--r--test/chunk.c4
-rw-r--r--test/dtypes.c288
-rw-r--r--test/shtype.c12
4 files changed, 373 insertions, 75 deletions
diff --git a/test/.distdep b/test/.distdep
index f2e23cd..0e71c56 100644
--- a/test/.distdep
+++ b/test/.distdep
@@ -157,6 +157,78 @@ th5s.o: \
../src/H5Zpublic.h \
../src/H5Pprivate.h \
../src/H5Ppublic.h
+hyperslab.o: \
+ hyperslab.c \
+ ../src/H5private.h \
+ ../src/H5public.h \
+ ../src/H5config.h
+iopipe.o: \
+ iopipe.c \
+ ../src/hdf5.h \
+ ../src/H5public.h \
+ ../src/H5config.h \
+ ../src/H5Ipublic.h \
+ ../src/H5Apublic.h \
+ ../src/H5ACpublic.h \
+ ../src/H5Bpublic.h \
+ ../src/H5Dpublic.h \
+ ../src/H5Epublic.h \
+ ../src/H5Fpublic.h \
+ ../src/H5Gpublic.h \
+ ../src/H5HGpublic.h \
+ ../src/H5HLpublic.h \
+ ../src/H5MFpublic.h \
+ ../src/H5MMpublic.h \
+ ../src/H5Opublic.h \
+ ../src/H5Ppublic.h \
+ ../src/H5Zpublic.h \
+ ../src/H5Spublic.h \
+ ../src/H5Tpublic.h
+big.o: \
+ big.c \
+ ../src/hdf5.h \
+ ../src/H5public.h \
+ ../src/H5config.h \
+ ../src/H5Ipublic.h \
+ ../src/H5Apublic.h \
+ ../src/H5ACpublic.h \
+ ../src/H5Bpublic.h \
+ ../src/H5Dpublic.h \
+ ../src/H5Epublic.h \
+ ../src/H5Fpublic.h \
+ ../src/H5Gpublic.h \
+ ../src/H5HGpublic.h \
+ ../src/H5HLpublic.h \
+ ../src/H5MFpublic.h \
+ ../src/H5MMpublic.h \
+ ../src/H5Opublic.h \
+ ../src/H5Ppublic.h \
+ ../src/H5Zpublic.h \
+ ../src/H5Spublic.h \
+ ../src/H5Tpublic.h \
+ ../src/H5private.h
+chunk.o: \
+ chunk.c \
+ ../src/hdf5.h \
+ ../src/H5public.h \
+ ../src/H5config.h \
+ ../src/H5Ipublic.h \
+ ../src/H5Apublic.h \
+ ../src/H5ACpublic.h \
+ ../src/H5Bpublic.h \
+ ../src/H5Dpublic.h \
+ ../src/H5Epublic.h \
+ ../src/H5Fpublic.h \
+ ../src/H5Gpublic.h \
+ ../src/H5HGpublic.h \
+ ../src/H5HLpublic.h \
+ ../src/H5MFpublic.h \
+ ../src/H5MMpublic.h \
+ ../src/H5Opublic.h \
+ ../src/H5Ppublic.h \
+ ../src/H5Zpublic.h \
+ ../src/H5Spublic.h \
+ ../src/H5Tpublic.h
dtypes.o: \
dtypes.c \
../src/hdf5.h \
@@ -184,11 +256,6 @@ dtypes.o: \
../src/H5Tprivate.h \
../src/H5Gprivate.h \
../src/H5Bprivate.h
-hyperslab.o: \
- hyperslab.c \
- ../src/H5private.h \
- ../src/H5public.h \
- ../src/H5config.h
istore.o: \
istore.c \
../src/H5private.h \
@@ -301,28 +368,6 @@ external.o: \
../src/H5Zpublic.h \
../src/H5Spublic.h \
../src/H5Tpublic.h
-iopipe.o: \
- iopipe.c \
- ../src/hdf5.h \
- ../src/H5public.h \
- ../src/H5config.h \
- ../src/H5Ipublic.h \
- ../src/H5Apublic.h \
- ../src/H5ACpublic.h \
- ../src/H5Bpublic.h \
- ../src/H5Dpublic.h \
- ../src/H5Epublic.h \
- ../src/H5Fpublic.h \
- ../src/H5Gpublic.h \
- ../src/H5HGpublic.h \
- ../src/H5HLpublic.h \
- ../src/H5MFpublic.h \
- ../src/H5MMpublic.h \
- ../src/H5Opublic.h \
- ../src/H5Ppublic.h \
- ../src/H5Zpublic.h \
- ../src/H5Spublic.h \
- ../src/H5Tpublic.h
gheap.o: \
gheap.c \
../src/H5private.h \
@@ -361,29 +406,6 @@ shtype.o: \
../src/H5Ppublic.h \
../src/H5Zpublic.h \
../src/H5Spublic.h
-big.o: \
- big.c \
- ../src/hdf5.h \
- ../src/H5public.h \
- ../src/H5config.h \
- ../src/H5Ipublic.h \
- ../src/H5Apublic.h \
- ../src/H5ACpublic.h \
- ../src/H5Bpublic.h \
- ../src/H5Dpublic.h \
- ../src/H5Epublic.h \
- ../src/H5Fpublic.h \
- ../src/H5Gpublic.h \
- ../src/H5HGpublic.h \
- ../src/H5HLpublic.h \
- ../src/H5MFpublic.h \
- ../src/H5MMpublic.h \
- ../src/H5Opublic.h \
- ../src/H5Ppublic.h \
- ../src/H5Zpublic.h \
- ../src/H5Spublic.h \
- ../src/H5Tpublic.h \
- ../src/H5private.h
links.o: \
links.c \
../src/hdf5.h \
@@ -403,25 +425,3 @@ links.o: \
../src/H5MMpublic.h \
../src/H5Opublic.h \
../src/H5Ppublic.h
-chunk.o: \
- chunk.c \
- ../src/hdf5.h \
- ../src/H5public.h \
- ../src/H5config.h \
- ../src/H5Ipublic.h \
- ../src/H5Apublic.h \
- ../src/H5ACpublic.h \
- ../src/H5Bpublic.h \
- ../src/H5Dpublic.h \
- ../src/H5Epublic.h \
- ../src/H5Fpublic.h \
- ../src/H5Gpublic.h \
- ../src/H5HGpublic.h \
- ../src/H5HLpublic.h \
- ../src/H5MFpublic.h \
- ../src/H5MMpublic.h \
- ../src/H5Opublic.h \
- ../src/H5Ppublic.h \
- ../src/H5Zpublic.h \
- ../src/H5Spublic.h \
- ../src/H5Tpublic.h
diff --git a/test/chunk.c b/test/chunk.c
index 35b5b85..33b4648 100644
--- a/test/chunk.c
+++ b/test/chunk.c
@@ -231,7 +231,7 @@ test_rowmaj (int op, hsize_t cache_size, hsize_t io_size)
H5Dclose (dset);
H5Fclose (file);
- return (double)SQUARE(CH_SIZE*DS_SIZE)/nio_g;
+ return (double)SQUARE(CH_SIZE*DS_SIZE)/(double)nio_g;
}
@@ -291,7 +291,7 @@ test_diag (int op, hsize_t cache_size, hsize_t io_size, hsize_t offset)
H5Dclose (dset);
H5Fclose (file);
- return (double)nio/nio_g;
+ return (double)nio/(double)nio_g;
}
diff --git a/test/dtypes.c b/test/dtypes.c
index 445e51f..0ae39b3 100644
--- a/test/dtypes.c
+++ b/test/dtypes.c
@@ -192,15 +192,295 @@ test_compound(void)
}
puts(" PASSED");
+#if 0
/* Just for debugging... */
H5T_debug(H5I_object(complex_id), stdout);
printf("\n");
-
+#endif
+
return SUCCEED;
error:
return FAIL;
}
+
+
+/*-------------------------------------------------------------------------
+ * Function: test_transient
+ *
+ * Purpose: Tests transient data types.
+ *
+ * Return: Success: SUCCEED
+ *
+ * Failure: FAIL
+ *
+ * Programmer: Robb Matzke
+ * Thursday, June 4, 1998
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+test_transient (void)
+{
+ static hsize_t ds_size[2] = {100, 200};
+ hid_t file, type, space, dset, t2;
+
+ printf ("%-70s", "Testing transient data types");
+ if ((file=H5Fcreate ("dtypes1.h5", H5F_ACC_TRUNC|H5F_ACC_DEBUG,
+ H5P_DEFAULT, H5P_DEFAULT))<0) goto error;
+ space = H5Screate_simple (2, ds_size, ds_size);
+
+ /* Predefined types cannot be modified or closed */
+ H5E_BEGIN_TRY {
+ if (H5Tset_precision (H5T_NATIVE_INT, 256)>=0) {
+ puts ("*FAILED*");
+ puts (" Predefined types should not be modifiable!");
+ goto error;
+ }
+ if (H5Tclose (H5T_NATIVE_INT)>=0) {
+ puts ("*FAILED*");
+ puts (" Predefined types should not be closable!");
+ goto error;
+ }
+ } H5E_END_TRY;
+
+ /* Copying a predefined type results in a modifiable copy */
+ if ((type=H5Tcopy (H5T_NATIVE_INT))<0) goto error;
+ if (H5Tset_precision (type, 256)<0) goto error;
+ if (H5Tclose (type)<0) goto error;
+
+ /* Create a dataset from a transient data type */
+ if ((type = H5Tcopy (H5T_NATIVE_INT))<0) goto error;
+ if ((dset=H5Dcreate (file, "dset1", type, space, H5P_DEFAULT))<0) {
+ goto error;
+ }
+
+ /* The type returned from a dataset should not be modifiable */
+ if ((t2 = H5Dget_type (dset))<0) goto error;
+ H5E_BEGIN_TRY {
+ if (H5Tset_precision (t2, 256)>=0) {
+ puts ("*FAILED*");
+ puts (" Dataset data types should not be modifiable!");
+ goto error;
+ }
+ } H5E_END_TRY;
+ if (H5Tclose (t2)<0) goto error;
+
+ /*
+ * Close the dataset and reopen it, testing that it's type is still
+ * read-only.
+ */
+ if (H5Dclose (dset)<0) goto error;
+ if ((dset=H5Dopen (file, "dset1"))<0) goto error;
+ if ((t2 = H5Dget_type (dset))<0) goto error;
+ H5E_BEGIN_TRY {
+ if (H5Tset_precision (t2, 256)>=0) {
+ puts ("*FAILED*");
+ puts (" Dataset data types should not be modifiable!");
+ goto error;
+ }
+ } H5E_END_TRY;
+ if (H5Tclose (t2)<0) goto error;
+
+ /*
+ * Get the dataset data type by applying H5Tcopy() to the dataset. The
+ * result should be modifiable.
+ */
+ if ((t2=H5Tcopy (dset))<0) goto error;
+ if (H5Tset_precision (t2, 256)<0) goto error;
+ if (H5Tclose (t2)<0) goto error;
+
+
+ H5Dclose (dset);
+ H5Fclose (file);
+ H5Tclose (type);
+ H5Sclose (space);
+ puts (" PASSED");
+ return SUCCEED;
+
+ error:
+ H5E_BEGIN_TRY {
+ H5Tclose (t2);
+ H5Tclose (type);
+ H5Sclose (space);
+ H5Dclose (dset);
+ H5Fclose (file);
+ } H5E_END_TRY;
+ return FAIL;
+}
+
+
+/*-------------------------------------------------------------------------
+ * Function: test_named
+ *
+ * Purpose: Tests named data types.
+ *
+ * Return: Success: SUCCEED
+ *
+ * Failure: FAIL
+ *
+ * Programmer: Robb Matzke
+ * Monday, June 1, 1998
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+test_named (void)
+{
+ hid_t file, type, space, dset, t2;
+ herr_t status;
+ static hsize_t ds_size[2] = {100, 200};
+
+ printf ("%-70s", "Testing named data types");
+ if ((file=H5Fcreate ("dtypes2.h5", H5F_ACC_TRUNC|H5F_ACC_DEBUG,
+ H5P_DEFAULT, H5P_DEFAULT))<0) goto error;
+ space = H5Screate_simple (2, ds_size, ds_size);
+
+ /* Predefined types cannot be committed */
+ H5E_BEGIN_TRY {
+ if (H5Tcommit (file, "test_named_1 (should not exist)",
+ H5T_NATIVE_INT)>=0) {
+ puts ("*FAILED*");
+ puts (" Predefined types should not be committable!");
+ goto error;
+ }
+ } H5E_END_TRY;
+
+ /* Copy a predefined data type and commit the copy */
+ if ((type = H5Tcopy (H5T_NATIVE_INT))<0) goto error;
+ if (H5Tcommit (file, "native-int", type)<0) goto error;
+ if ((status=H5Tcommitted (type))<0) goto error;
+ if (0==status) {
+ puts ("*FAILED*");
+ puts (" H5Tcommitted() returned false!");
+ goto error;
+ }
+
+ /* We should not be able to modify a type after it has been committed. */
+ H5E_BEGIN_TRY {
+ if (H5Tset_precision (type, 256)>=0) {
+ puts ("*FAILED*");
+ puts (" Committed type is not constant!");
+ goto error;
+ }
+ } H5E_END_TRY;
+
+ /* We should not be able to re-commit a committed type */
+ H5E_BEGIN_TRY {
+ if (H5Tcommit (file, "test_named_2 (should not exist)", type)>=0) {
+ puts ("*FAILED*");
+ puts (" Committed types should not be recommitted!");
+ goto error;
+ }
+ } H5E_END_TRY;
+
+ /*
+ * Copying a committed type should result in a transient type which is
+ * not locked.
+ */
+ if ((t2 = H5Tcopy (type))<0) goto error;
+ if ((status=H5Tcommitted (t2))<0) goto error;
+ if (status) {
+ puts ("*FAILED*");
+ puts (" Copying a named type should result in a transient type!");
+ goto error;
+ }
+ if (H5Tset_precision (t2, 256)<0) goto error;
+ if (H5Tclose (t2)<0) goto error;
+
+ /*
+ * Close the committed type and reopen it. It should return a named type.
+ */
+ if (H5Tclose (type)<0) goto error;
+ if ((type=H5Topen (file, "native-int"))<0) goto error;
+ if ((status=H5Tcommitted (type))<0) goto error;
+ if (!status) {
+ puts ("*FAILED*");
+ puts (" Opened named types should be named types!");
+ goto error;
+ }
+
+ /* Create a dataset that uses the named type */
+ if ((dset = H5Dcreate (file, "dset1", type, space, H5P_DEFAULT))<0) {
+ goto error;
+ }
+
+ /* Get the dataset's data type and make sure it's a named type */
+ if ((t2 = H5Dget_type (dset))<0) goto error;
+ if ((status=H5Tcommitted (t2))<0) goto error;
+ if (!status) {
+ puts ("*FAILED*");
+ puts (" Dataset type should be a named type!");
+ goto error;
+ }
+
+ /* Close the dataset, then close its type, then reopen the dataset */
+ if (H5Dclose (dset)<0) goto error;
+ if (H5Tclose (t2)<0) goto error;
+ if ((dset = H5Dopen (file, "dset1"))<0) goto error;
+
+ /* Get the dataset's type and make sure it's named */
+ if ((t2 = H5Dget_type (dset))<0) goto error;
+ if ((status=H5Tcommitted (t2))<0) goto error;
+ if (!status) {
+ puts ("*FAILED*");
+ puts (" Dataset type should be a named type!");
+ goto error;
+ }
+
+ /*
+ * Close the dataset and create another with the type returned from the
+ * first dataset.
+ */
+ if (H5Dclose (dset)<0) goto error;
+ if ((dset=H5Dcreate (file, "dset2", t2, space, H5P_DEFAULT))<0) {
+ goto error;
+ }
+
+ /* Reopen the second dataset and make sure the type is shared */
+ if (H5Tclose (t2)<0) goto error;
+ if (H5Dclose (dset)<0) goto error;
+ if ((dset = H5Dopen (file, "dset2"))<0) goto error;
+ if ((t2 = H5Dget_type (dset))<0) goto error;
+ if ((status=H5Tcommitted (t2))<0) goto error;
+ if (!status) {
+ puts ("*FAILED*");
+ puts (" Dataset type should be a named type!");
+ goto error;
+ }
+ if (H5Tclose (t2)<0) goto error;
+
+ /*
+ * Get the dataset data type by applying H5Tcopy() to the dataset. The
+ * result should be modifiable.
+ */
+ if ((t2=H5Tcopy (dset))<0) goto error;
+ if (H5Tset_precision (t2, 256)<0) goto error;
+ if (H5Tclose (t2)<0) goto error;
+
+ /* Clean up */
+ if (H5Dclose (dset)<0) goto error;
+ if (H5Tclose (type)<0) goto error;
+ if (H5Sclose (space)<0) goto error;
+ if (H5Fclose (file)<0) goto error;
+ puts (" PASSED");
+ return SUCCEED;
+
+ error:
+ H5E_BEGIN_TRY {
+ H5Tclose (t2);
+ H5Tclose (type);
+ H5Sclose (space);
+ H5Dclose (dset);
+ H5Fclose (file);
+ } H5E_END_TRY;
+ return FAIL;
+}
+
/*-------------------------------------------------------------------------
* Function: main
@@ -233,6 +513,12 @@ main(void)
status = test_compound();
nerrors += status < 0 ? 1 : 0;
+ status = test_transient ();
+ nerrors += status < 0 ? 1 : 0;
+
+ status = test_named ();
+ nerrors += status < 0 ? 1 : 0;
+
if (nerrors) {
printf("***** %d DATA TYPE TEST%s FAILED! *****\n",
nerrors, 1 == nerrors ? "" : "S");
diff --git a/test/shtype.c b/test/shtype.c
index e9fb935..ba6c32d 100644
--- a/test/shtype.c
+++ b/test/shtype.c
@@ -72,6 +72,7 @@ display_error_cb (void __unused__ *client_data)
static int
test_1 (void)
{
+#if 0
hid_t f, d1, d2, s1, t1, t2;
hsize_t size[1] = {1};
@@ -105,6 +106,9 @@ test_1 (void)
error:
return -1;
+#else
+ return 0;
+#endif
}
@@ -129,6 +133,7 @@ test_1 (void)
static int
test_2 (void)
{
+#if 0
hid_t f1, f2, t1, t2, s1, d1, d2;
hsize_t size[1] = {1};
char buf[32];
@@ -178,6 +183,9 @@ test_2 (void)
error:
return -1;
+#else
+ return 0;
+#endif
}
@@ -200,6 +208,7 @@ test_2 (void)
static int
test_3 (void)
{
+#if 0
hid_t f1, s1, t1, d1;
hsize_t size[1] = {1};
herr_t status, (*ef)(void*)=NULL;
@@ -254,6 +263,9 @@ test_3 (void)
error:
return -1;
+#else
+ return 0;
+#endif
}