summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/big.c12
-rw-r--r--test/fillval.c90
2 files changed, 82 insertions, 20 deletions
diff --git a/test/big.c b/test/big.c
index 53240e1..c2c81bf 100644
--- a/test/big.c
+++ b/test/big.c
@@ -180,12 +180,6 @@ writer (int wrt_n)
fflush(stdout);
/*
- * Make sure that `hsize_t' is large enough to represent the entire data
- * space.
- */
- assert (sizeof(hsize_t)>4);
-
- /*
* We might be on a machine that has 32-bit files, so create an HDF5 file
* which is a family of files. Each member of the family will be 1GB
*/
@@ -392,6 +386,12 @@ main (void)
puts("Test skipped because of quota (file size or num open files).");
exit(0);
}
+ if (sizeof(hsize_t)<=4) {
+ puts("Test skipped because the hdf5 library was configured with the");
+ puts("--disable-hsizet flag in order to work around a compiler bug.");
+ exit(0);
+ }
+
/* Set the error handler */
H5Eset_auto (display_error_cb, NULL);
diff --git a/test/fillval.c b/test/fillval.c
index 3880e23..061e9a8 100644
--- a/test/fillval.c
+++ b/test/fillval.c
@@ -228,10 +228,11 @@ test_getset(void)
static int
test_create(const char *filename, H5D_layout_t layout)
{
- hid_t file, space, dcpl, dset;
+ hid_t file, space, dcpl, dset1, dset2, dset3;
hsize_t cur_size[5] = {32, 16, 8, 4, 2};
hsize_t ch_size[5] = {1, 1, 1, 4, 2};
- int fillval = 0x4c70f1cd, fillval_rd=0;
+ short rd_s, fill_s = 0x1234;
+ long rd_l, fill_l = 0x4321;
char test[256];
if (H5D_CHUNKED==layout) {
@@ -242,7 +243,11 @@ test_create(const char *filename, H5D_layout_t layout)
printf("%-70s", test);
fflush(stdout);
- /* Create a file and dataset */
+ /*
+ * Create a file and three datasets. The three datasets test three fill
+ * conversion paths: small to large, large to small, and no conversion.
+ * They depend on `short' being smaller than `long'.
+ */
if ((file=H5Fcreate(filename, H5F_ACC_TRUNC,
H5P_DEFAULT, H5P_DEFAULT))<0) goto error;
if ((space=H5Screate_simple(5, cur_size, cur_size))<0) goto error;
@@ -250,33 +255,88 @@ test_create(const char *filename, H5D_layout_t layout)
if (H5D_CHUNKED==layout) {
if (H5Pset_chunk(dcpl, 5, ch_size)<0) goto error;
}
+
+ /* Small to large fill conversion */
#ifndef NO_FILLING
- if (H5Pset_fill_value(dcpl, H5T_NATIVE_INT, &fillval)<0) goto error;
+ if (H5Pset_fill_value(dcpl, H5T_NATIVE_SHORT, &fill_s)<0) goto error;
#endif
- if ((dset=H5Dcreate(file, "dset", H5T_NATIVE_INT, space, dcpl))<0)
+ if ((dset1=H5Dcreate(file, "dset1", H5T_NATIVE_LONG, space, dcpl))<0)
goto error;
- if (H5Dclose(dset)<0) goto error;
+
+ /* Large to small fill conversion */
+#ifndef NO_FILLING
+ if (H5Pset_fill_value(dcpl, H5T_NATIVE_LONG, &fill_l)<0) goto error;
+#endif
+ if ((dset2=H5Dcreate(file, "dset2", H5T_NATIVE_SHORT, space, dcpl))<0)
+ goto error;
+
+ /* No conversion */
+#ifndef NO_FILLING
+ if (H5Pset_fill_value(dcpl, H5T_NATIVE_LONG, &fill_l)<0) goto error;
+#endif
+ if ((dset3=H5Dcreate(file, "dset3", H5T_NATIVE_LONG, space, dcpl))<0)
+ goto error;
+
+ /* Close everything */
+ if (H5Dclose(dset1)<0) goto error;
+ if (H5Dclose(dset2)<0) goto error;
+ if (H5Dclose(dset3)<0) goto error;
if (H5Sclose(space)<0) goto error;
if (H5Pclose(dcpl)<0) goto error;
if (H5Fclose(file)<0) goto error;
- /* Open the file and get the dataset fill value */
+ /* Open the file and get the dataset fill value from each dataset */
if ((file=H5Fopen(FILE_NAME_1, H5F_ACC_RDONLY, H5P_DEFAULT))<0)
goto error;
- if ((dset=H5Dopen(file, "dset"))<0) goto error;
- if ((dcpl=H5Dget_create_plist(dset))<0) goto error;
+
+ /* Large to small conversion */
+ if ((dset1=H5Dopen(file, "dset1"))<0) goto error;
+ if ((dcpl=H5Dget_create_plist(dset1))<0) goto error;
+ if (H5Dclose(dset1)<0) goto error;
#ifndef NO_FILLING
- if (H5Pget_fill_value(dcpl, H5T_NATIVE_INT, &fillval_rd)<0) goto error;
- if (fillval_rd!=fillval) {
+ if (H5Pget_fill_value(dcpl, H5T_NATIVE_SHORT, &rd_s)<0) goto error;
+ if (rd_s!=fill_s) {
puts("*FAILED*");
puts(" Got a different fill value than what was set.");
+ printf(" Got %d, set %d\n", rd_s, fill_s);
goto error;
}
#endif
if (H5Pclose(dcpl)<0) goto error;
- if (H5Dclose(dset)<0) goto error;
- if (H5Fclose(file)<0) goto error;
+ /* Small to large conversion */
+ if ((dset2=H5Dopen(file, "dset2"))<0) goto error;
+ if ((dcpl=H5Dget_create_plist(dset2))<0) goto error;
+ if (H5Dclose(dset2)<0) goto error;
+#ifndef NO_FILLING
+ if (H5Pget_fill_value(dcpl, H5T_NATIVE_LONG, &rd_l)<0) goto error;
+ if (rd_l!=fill_l) {
+ puts("*FAILED*");
+ puts(" Got a different fill value than what was set.");
+ printf(" Got %ld, set %ld\n", rd_l, fill_l);
+ goto error;
+ }
+#endif
+ if (H5Pclose(dcpl)<0) goto error;
+
+ /* No conversion */
+ if ((dset3=H5Dopen(file, "dset3"))<0) goto error;
+ if ((dcpl=H5Dget_create_plist(dset3))<0) goto error;
+ if (H5Dclose(dset3)<0) goto error;
+#ifndef NO_FILLING
+ if (H5Pget_fill_value(dcpl, H5T_NATIVE_LONG, &rd_l)<0) goto error;
+ if (rd_l!=fill_l) {
+ puts("*FAILED*");
+ puts(" Got a different fill value than what was set.");
+ printf(" Got %ld, set %ld\n", rd_l, fill_l);
+ goto error;
+ }
+#endif
+ if (H5Pclose(dcpl)<0) goto error;
+
+
+
+ if (H5Fclose(file)<0) goto error;
puts(" PASSED");
return 0;
@@ -284,7 +344,9 @@ test_create(const char *filename, H5D_layout_t layout)
H5E_BEGIN_TRY {
H5Pclose(dcpl);
H5Sclose(space);
- H5Dclose(dset);
+ H5Dclose(dset1);
+ H5Dclose(dset2);
+ H5Dclose(dset3);
H5Fclose(file);
} H5E_END_TRY;
return 1;