summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/Makefile.in16
-rw-r--r--test/gass_append.c148
-rw-r--r--test/gass_read.c200
-rw-r--r--test/gass_write.c157
4 files changed, 519 insertions, 2 deletions
diff --git a/test/Makefile.in b/test/Makefile.in
index 2e602a4..f438e6a 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -20,7 +20,7 @@ CPPFLAGS=-I. -I$(srcdir) -I../src -I$(top_srcdir)/src @CPPFLAGS@
RUNTEST=$(LT_RUN)
TEST_PROGS=testhdf5 lheap ohdr stab gheap hyperslab istore bittests dtypes \
dsets cmpd_dset extend external links unlink big mtime fillval mount \
- flush1 flush2 enum
+ flush1 flush2 enum gass_write gass_read gass_append
TIMINGS=iopipe chunk ragged overhead
## The libh5test.a library provides common support code for the tests. We link
@@ -58,7 +58,9 @@ TEST_SRC=big.c bittests.c chunk.c cmpd_dset.c dsets.c dtypes.c extend.c \
external.c fillval.c flush1.c flush2.c gheap.c h5test.c hyperslab.c \
iopipe.c istore.c lheap.c links.c mount.c mtime.c ohdr.c overhead.c \
ragged.c stab.c tattr.c testhdf5.c tfile.c th5s.c tmeta.c trefer.c \
- tselect.c tvltypes.c unlink.c enum.c
+ tselect.c tvltypes.c unlink.c enum.c gass_write.c gass_read.c \
+ gass_append.c
+
TEST_OBJ=$(TEST_SRC:.c=.lo)
## Private header files (not to be installed)...
@@ -155,4 +157,14 @@ flush2: flush2.lo
enum: enum.lo
@$(LT_LINK_EXE) $(CFLAGS) -o $@ enum.lo $(LIB) $(LIBHDF5) $(LDFLAGS) $(LIBS)
+gass_write: gass_write.lo
+ @$(LT_LINK_EXE) $(CFLAGS) -o $@ gass_write.lo $(LIB) $(LIBHDF5) $(LDFLAGS) $(LIBS)
+
+gass_read: gass_read.lo
+ @$(LT_LINK_EXE) $(CFLAGS) -o $@ gass_read.lo $(LIB) $(LIBHDF5) $(LDFLAGS) $(LIBS)
+
+gass_append: gass_append.lo
+ @$(LT_LINK_EXE) $(CFLAGS) -o $@ gass_append.lo $(LIB) $(LIBHDF5) $(LDFLAGS) $(LIBS)
+
@CONCLUDE@
+
diff --git a/test/gass_append.c b/test/gass_append.c
new file mode 100644
index 0000000..0764a39
--- /dev/null
+++ b/test/gass_append.c
@@ -0,0 +1,148 @@
+/*
+ * Copyright © 1998 NCSA
+ * All rights reserved.
+ *
+ * Programmer: Saurabh Bagchi (bagchi@uiuc.edu)
+ * Wednesday, August 11, 1999.
+ *
+ * Modifications: Saurabh Bagchi (Aug 17, 1999)
+ * Modified to work with VFL (HDF51.3).
+ */
+
+/* Test the following functionality of the GASS driver.
+ 1. Open a remote file for append.
+ 2. Create a new dataset within the file.
+ 3. Create a local memory buffer to hold the data.
+ 4. Write the local data to the remote dataset.
+*/
+#include <h5test.h>
+
+#ifndef HAVE_GASS
+int main(void)
+{
+ printf("Test skipped because GASS driver not available\n");
+ return 0;
+}
+#else
+
+#define URL "ftp://bagchi:bagchi12@hdfspare1/scratch-fuga/home/bagchi/junk.w"
+#define DATASETNAME "Int1Array"
+#define NX 5 /* dataset dimensions */
+#define NY 6
+#define RANK 2
+
+int main (void)
+{
+
+ hid_t fapl =-1, file;
+ hid_t dataspace, datatype, dataset;
+ hsize_t dimsf[2];
+
+ herr_t status = 0;
+ int data[NX][NY]; /* data to write */
+ int i, j;
+ GASS_Info ginf;
+
+ /*
+ * Data and output buffer initialization.
+ */
+ for (j = 0; j < NX; j++) {
+ for (i = 0; i < NY; i++)
+ data[j][i] = i*i + j*j;
+ }
+ /*
+ * 0 1 4 9 16 25
+ * 1 2 5 10 17 26
+ * 4 5 8 13 20 29
+ * 9 10 13 18 25 34
+ * 16 17 20 25 32 41
+ */
+
+ /* Create access property list and set the driver to GASS */
+ fapl = H5Pcreate (H5P_FILE_ACCESS);
+ if (fapl < 0) {
+ printf (" H5Pcreate failed. \n");
+ return -1;
+ }
+
+ ginf.block_size = 0;
+ ginf.max_length =0;
+ /* ginf = GASS_INFO_NULL; */
+
+ status = H5Pset_fapl_gass (fapl, ginf);
+ if (status < 0) {
+ printf ("H5Pset_fapl_gass failed. \n");
+ return -1;
+ }
+
+ /*
+ * Open an existing file using H5F_ACC_RDWR access,
+ * and gass file access properties.
+ */
+ file = H5Fopen(URL, H5F_ACC_RDWR, fapl);
+ if (file < 0) {
+ printf ("H5Fopen failed. \n");
+ return -1;
+ }
+
+ /*
+ * Describe the size of the array and create the data space for fixed
+ * size dataset.
+ */
+ dimsf[0] = NX;
+ dimsf[1] = NY;
+ dataspace = H5Screate_simple(RANK, dimsf, NULL);
+ if (dataspace < 0) {
+ printf ("H5Screate failed. \n");
+ return -1;
+ }
+
+ /*
+ * Define datatype for the data in the file.
+ * We will store little endian INT numbers.
+ */
+ datatype = H5Tcopy(H5T_NATIVE_INT);
+ if (datatype < 0) {
+ printf ("H5Tcopy failed. \n");
+ return -1;
+ }
+
+ status = H5Tset_order(datatype, H5T_ORDER_LE);
+ if (status < 0) {
+ printf ("H5Tset_order failed. \n");
+ return -1;
+ }
+
+ /*
+ * Create a new dataset within the file using defined dataspace and
+ * datatype and default dataset creation properties.
+ */
+ dataset = H5Dcreate(file, DATASETNAME, datatype, dataspace,
+ H5P_DEFAULT);
+ if (dataset < 0) {
+ printf ("H5Dcreate failed. \n");
+ return -1;
+ }
+
+ /*
+ * Write the data to the dataset using default transfer properties.
+ */
+ status = H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL,
+ H5P_DEFAULT, data);
+ if (status < 0) {
+ printf ("H5Dwrite failed. \n");
+ return -1;
+ }
+
+ /*
+ * Close/release resources.
+ */
+ H5Sclose(dataspace);
+ H5Tclose(datatype);
+ H5Dclose(dataset);
+ H5Fclose(file);
+ H5Pclose(fapl);
+
+ return 0;
+}
+#endif
diff --git a/test/gass_read.c b/test/gass_read.c
new file mode 100644
index 0000000..f43cd02
--- /dev/null
+++ b/test/gass_read.c
@@ -0,0 +1,200 @@
+/*
+ * Copyright © 1998 NCSA
+ * All rights reserved.
+ *
+ * Programmer: Saurabh Bagchi (bagchi@uiuc.edu)
+ * Wednesday, August 11, 1999.
+ *
+ * Modifications: Saurabh Bagchi (Aug 17, 1999)
+ * Modified to work with VFL (HDF51.3).
+ */
+
+/* Test the following functionality of the GASS driver.
+ 1. Open a remote file for read (the dataset was written using gass_write.c).
+ 2. Create a memory buffer to hold the dataset.
+ 3. Read the dataset into the memory buffer.
+ 4. Get some information about the dataset from the file.
+*/
+#include <h5test.h>
+#include <strings.h>
+
+#ifndef HAVE_GASS
+int main(void)
+{
+ printf("Test skipped because GASS driver not available\n");
+ return 0;
+}
+#else
+
+#define URL "ftp://bagchi:bagchi12@hdfspare1/scratch-fuga/home/bagchi/junk.w"
+
+/* #define DATASETNAME "Int1Array" */
+#define NX_SUB 3 /* hyperslab dimensions */
+#define NY_SUB 4
+#define NX 7 /* output buffer dimensions */
+#define NY 7
+#define NZ 3
+#define RANK 2
+#define RANK_OUT 3
+
+int
+main (int argc, char **argv)
+{
+ hid_t fapl = -1, file, dataset; /* handles */
+ char DATASETNAME[32];
+ hid_t datatype, dataspace;
+ hid_t memspace;
+ H5T_class_t class; /* data type class */
+ H5T_order_t order; /* data order */
+ size_t size; /*
+ * size of the data element
+ * stored in file
+ */
+ hsize_t dimsm[3]; /* memory space dimensions */
+ hsize_t dims_out[2]; /* dataset dimensions */
+ herr_t status;
+
+ int data_out[NX][NY][NZ ]; /* output buffer */
+
+ hsize_t count[2]; /* size of the hyperslab in the file */
+ hssize_t offset[2]; /* hyperslab offset in the file */
+ hsize_t count_out[3]; /* size of the hyperslab in memory */
+ hssize_t offset_out[3]; /* hyperslab offset in memory */
+ int i, j, k, status_n, rank;
+ GASS_Info ginf;
+
+ if (argc > 2) {
+ printf ("Incorrect command line. \n");
+ printf ("Correct command line: %s [DATASET NAME] \n", argv[0]);
+ printf ("The two datasets present in the file are: \"IntArray\" and "
+ "\"Int1Array\"\n");
+ exit(1);
+ }
+
+ printf ("Correct command line: %s [DATASET NAME] \n", argv[0]);
+ printf ("The two datasets present in the file are: \"IntArray\" and "
+ "\"Int1Array\"\n");
+ printf ("Default dataset is IntArray. \n");
+
+ if (argc == 1)
+ strcpy (DATASETNAME, "IntArray");
+ else if (!strcmp(argv[1],"IntArray") || !strcmp(argv[1],"Int1Array"))
+ strcpy (DATASETNAME, argv[1]);
+ else
+ strcpy (DATASETNAME, "IntArray");
+ printf ("\n Reading dataset %s \n\n", DATASETNAME);
+
+ for (j = 0; j < NX; j++) {
+ for (i = 0; i < NY; i++) {
+ for (k = 0; k < NZ ; k++)
+ data_out[j][i][k] = 0;
+ }
+ }
+
+ /* Create access property list and set the driver to GASS */
+ fapl = H5Pcreate (H5P_FILE_ACCESS);
+ if (fapl < 0) {
+ printf (" H5Pcreate failed. \n");
+ return -1;
+ }
+
+
+ ginf.block_size = 0;
+ ginf.max_length =0;
+
+ /* ginf = GASS_INFO_NULL; */
+
+ status = H5Pset_fapl_gass (fapl, ginf);
+ if (status < 0) {
+ printf ("H5Pset_fapl_gass failed. \n");
+ return -1;
+ }
+
+ /*
+ * Open the file and the dataset.
+ */
+ file = H5Fopen(URL, H5F_ACC_RDONLY, fapl);
+ dataset = H5Dopen(file, DATASETNAME);
+
+ /*
+ * Get datatype and dataspace handles and then query
+ * dataset class, order, size, rank and dimensions.
+ */
+ datatype = H5Dget_type(dataset); /* datatype handle */
+ class = H5Tget_class(datatype);
+ if (class == H5T_INTEGER) printf("Data set has INTEGER type \n");
+ order = H5Tget_order(datatype);
+ if (order == H5T_ORDER_LE) printf("Little endian order \n");
+
+ size = H5Tget_size(datatype);
+ printf(" Data size is %d \n", size);
+
+ dataspace = H5Dget_space(dataset); /* dataspace handle */
+ rank = H5Sget_simple_extent_ndims(dataspace);
+ status_n = H5Sget_simple_extent_dims(dataspace, dims_out, NULL);
+ printf("rank %d, dimensions %lu x %lu \n", rank,
+ (unsigned long)(dims_out[0]), (unsigned long)(dims_out[1]));
+
+ /*
+ * Define hyperslab in the dataset.
+ */
+ offset[0] = 1;
+ offset[1] = 2;
+ count[0] = NX_SUB;
+ count[1] = NY_SUB;
+ status = H5Sselect_hyperslab(dataspace, H5S_SELECT_SET, offset, NULL,
+ count, NULL);
+
+ /*
+ * Define the memory dataspace.
+ */
+ dimsm[0] = NX;
+ dimsm[1] = NY;
+ dimsm[2] = NZ ;
+ memspace = H5Screate_simple(RANK_OUT,dimsm,NULL);
+
+ /*
+ * Define memory hyperslab.
+ */
+ offset_out[0] = 3;
+ offset_out[1] = 0;
+ offset_out[2] = 0;
+ count_out[0] = NX_SUB;
+ count_out[1] = NY_SUB;
+ count_out[2] = 1;
+ status = H5Sselect_hyperslab(memspace, H5S_SELECT_SET, offset_out, NULL,
+ count_out, NULL);
+
+ /*
+ * Read data from hyperslab in the file into the hyperslab in
+ * memory and display.
+ */
+ status = H5Dread(dataset, H5T_NATIVE_INT, memspace, dataspace,
+ H5P_DEFAULT, data_out);
+ for (j = 0; j < NX; j++) {
+ for (i = 0; i < NY; i++) printf("%d ", data_out[j][i][0]);
+ printf("\n");
+ }
+ /*
+ * 0 0 0 0 0 0 0
+ * 0 0 0 0 0 0 0
+ * 0 0 0 0 0 0 0
+ * 3 4 5 6 0 0 0
+ * 4 5 6 7 0 0 0
+ * 5 6 7 8 0 0 0
+ * 0 0 0 0 0 0 0
+ */
+
+ /*
+ * Close/release resources.
+ */
+ H5Tclose(datatype);
+ H5Dclose(dataset);
+ H5Sclose(dataspace);
+ H5Sclose(memspace);
+ H5Fclose(file);
+ H5Pclose(fapl);
+
+ return 0;
+}
+#endif
diff --git a/test/gass_write.c b/test/gass_write.c
new file mode 100644
index 0000000..a6000ed
--- /dev/null
+++ b/test/gass_write.c
@@ -0,0 +1,157 @@
+/*
+ * Copyright © 1998 NCSA
+ * All rights reserved.
+ *
+ * Programmer: Saurabh Bagchi (bagchi@uiuc.edu)
+ * Friday, August 6, 1999.
+ *
+ * Modifications: Saurabh Bagchi (Aug 17, 1999)
+ * Modified to work with VFL (HDF51.3).
+ */
+
+/* Test the following functionality of the GASS driver.
+ 1. Open a remote file for write.
+ 2. Create a new dataset within the file.
+ 3. Create a local memory buffer to hold the data.
+ 4. Write the local data to the remote dataset.
+*/
+#include <h5test.h>
+
+#ifndef HAVE_GASS
+int main(void)
+{
+ printf("Test skipped because GASS driver not available\n");
+ return 0;
+}
+#else
+
+#define URL "ftp://bagchi:bagchi12@hdfspare1/scratch-fuga/home/bagchi/junk.w"
+
+#define DATASETNAME "IntArray"
+#define NX 5 /* dataset dimensions */
+#define NY 6
+#define RANK 2
+
+int main (void)
+{
+
+ hid_t fapl =-1, file;
+ hid_t dataspace, datatype, dataset;
+ hsize_t dimsf[2];
+
+ herr_t status = 0;
+ int data[NX][NY]; /* data to write */
+ int i, j;
+ GASS_Info ginf;
+
+ /*
+ * Data and output buffer initialization.
+ */
+ for (j = 0; j < NX; j++) {
+ for (i = 0; i < NY; i++)
+ data[j][i] = i + j;
+ }
+ /*
+ * 0 1 2 3 4 5
+ * 1 2 3 4 5 6
+ * 2 3 4 5 6 7
+ * 3 4 5 6 7 8
+ * 4 5 6 7 8 9
+ */
+
+ /* Create access property list and set the driver to GASS */
+ fapl = H5Pcreate (H5P_FILE_ACCESS);
+ if (fapl < 0) {
+ printf (" H5Pcreate failed. \n");
+ return -1;
+ }
+
+ ginf.block_size = 0;
+ ginf.max_length =0;
+ /* ginf = GASS_INFO_NULL;*/
+
+ status = H5Pset_fapl_gass (fapl, ginf);
+ if (status < 0) {
+ printf ("H5Pset_fapl_gass failed. \n");
+ return -1;
+ }
+
+ /*
+ * Create a new file using H5F_ACC_TRUNC access,
+ * default file creation properties, and gass file
+ * access properties.
+ */
+ // file = H5Fcreate(URL, H5F_ACC_TRUNC, H5P_DEFAULT, fapl);
+ // Works. Truncates existing files.
+ // file = H5Fcreate(URL, H5F_ACC_EXCL, H5P_DEFAULT, fapl);
+ // Works. Croaks if existing file, else creates.
+ // Any other flag has no effect as long as one and exactly one of TRUNC/
+ // EXCL is there
+ /* printf ("I'm here just before H5Fcreate. \n");*/
+ file = H5Fcreate(URL, H5F_ACC_TRUNC, H5P_DEFAULT, fapl);
+ if (file < 0) {
+ printf ("H5Fcreate failed. \n");
+ return -1;
+ }
+
+ /*
+ * Describe the size of the array and create the data space for fixed
+ * size dataset.
+ */
+ dimsf[0] = NX;
+ dimsf[1] = NY;
+ dataspace = H5Screate_simple(RANK, dimsf, NULL);
+ if (dataspace < 0) {
+ printf ("H5Screate failed. \n");
+ return -1;
+ }
+
+ /*
+ * Define datatype for the data in the file.
+ * We will store little endian INT numbers.
+ */
+ datatype = H5Tcopy(H5T_NATIVE_INT);
+ if (datatype < 0) {
+ printf ("H5Tcopy failed. \n");
+ return -1;
+ }
+
+ status = H5Tset_order(datatype, H5T_ORDER_LE);
+ if (status < 0) {
+ printf ("H5Tset_order failed. \n");
+ return -1;
+ }
+
+ /*
+ * Create a new dataset within the file using defined dataspace and
+ * datatype and default dataset creation properties.
+ */
+ dataset = H5Dcreate(file, DATASETNAME, datatype, dataspace,
+ H5P_DEFAULT);
+ if (dataset < 0) {
+ printf ("H5Dcreate failed. \n");
+ return -1;
+ }
+
+ /*
+ * Write the data to the dataset using default transfer properties.
+ */
+ status = H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL,
+ H5P_DEFAULT, data);
+ if (status < 0) {
+ printf ("H5Dwrite failed. \n");
+ return -1;
+ }
+
+ /*
+ * Close/release resources.
+ */
+ H5Sclose(dataspace);
+ H5Tclose(datatype);
+ H5Dclose(dataset);
+ H5Fclose(file);
+ H5Pclose(fapl);
+
+ return 0;
+}
+#endif