summaryrefslogtreecommitdiffstats
path: root/hl/test/test_lite.c
diff options
context:
space:
mode:
authorRaymond Lu <songyulu@hdfgroup.org>2006-05-17 18:09:12 (GMT)
committerRaymond Lu <songyulu@hdfgroup.org>2006-05-17 18:09:12 (GMT)
commit0f98d2009b6c3a190d7303170468a1f711e1b00a (patch)
tree6e885e6424b33ab8184ab6681889bdb254e606ab /hl/test/test_lite.c
parentb562825fc5b7555ec39c55dbcd002dde8cdfafec (diff)
downloadhdf5-0f98d2009b6c3a190d7303170468a1f711e1b00a.zip
hdf5-0f98d2009b6c3a190d7303170468a1f711e1b00a.tar.gz
hdf5-0f98d2009b6c3a190d7303170468a1f711e1b00a.tar.bz2
[svn-r12351] Purpose: Follow-up what's committed yesterday.
Description: Yesterday, a definition of the macro YY_BUF_SIZE of 256KB was committed in, but copper complained it can't be redefined. Solution: Added #ifdef and #undef to make sure the macro is undefined first. Also integrated a complicated compound type test. It reads input from a text file. The datatype is unusually large, of 101 member fields. Platforms tested: h5committest and fuss.
Diffstat (limited to 'hl/test/test_lite.c')
-rw-r--r--hl/test/test_lite.c88
1 files changed, 88 insertions, 0 deletions
diff --git a/hl/test/test_lite.c b/hl/test/test_lite.c
index 705cf3a..07002e0 100644
--- a/hl/test/test_lite.c
+++ b/hl/test/test_lite.c
@@ -19,6 +19,7 @@
#define FILE_NAME "test_lite1.h5"
#define FILE_NAME2 "test_lite2.h5"
+#define INPUT_FILE "dtype_file.txt"
#define DSET0_NAME "2D int array"
#define DSET1_NAME "dataset char"
@@ -43,6 +44,9 @@
#define ATTR10_NAME "attr float"
#define ATTR11_NAME "attr double"
+/*Initial input buffer size for testing H5LTtext_to_dtype()*/
+#define BUF_SIZE 1024
+
static herr_t make_attributes( hid_t loc_id, const char* obj_name );
@@ -1513,6 +1517,87 @@ out:
}
/*-------------------------------------------------------------------------
+ * subroutine for test_text_dtype(): test_complicated_compound().
+ *-------------------------------------------------------------------------
+ */
+static int test_complicated_compound(void)
+{
+ hid_t dtype;
+ int nmembs;
+ H5T_class_t type_class;
+ size_t str_len;
+ char* line=NULL;
+ FILE *fp;
+ int size = 1024;
+ char *srcdir = getenv("srcdir"); /* the source directory */
+ char filename[1024]="";
+
+ TESTING3(" text for complicated compound types");
+
+ /* compose the name of the file to open, using the srcdir, if appropriate */
+ if(srcdir)
+ {
+ strcpy(filename, srcdir);
+ strcat(filename, "/");
+ }
+ strcat(filename, INPUT_FILE);
+
+ /* Open input file */
+ fp = fopen(filename, "r");
+ if(fp == NULL)
+ {
+ printf( "Could not find file %s. Try set $srcdir \n", filename);
+ goto out;
+ }
+
+ /* This part reads in the input as a string in a slow manner. GNU C
+ * Library has convenient function getline() but isn't available on
+ * all machines.
+ */
+ if((line = (char*)calloc(size, sizeof(char)))==NULL)
+ goto out;
+ if(fgets(line, size, fp)==NULL)
+ goto out;
+ while(strlen(line)==size-1) {
+ size *= 2;
+ if(line)
+ free(line);
+ if((line = (char*)calloc(size, sizeof(char)))==NULL)
+ goto out;
+ if(fseek(fp, 0L, SEEK_SET)!=0)
+ goto out;
+ if(fgets(line, size, fp)==NULL)
+ goto out;
+ }
+
+ fclose(fp);
+
+ if((dtype = H5LTtext_to_dtype(line, H5LT_DDL))<0)
+ goto out;
+
+ if((type_class = H5Tget_class(dtype))<0)
+ goto out;
+ if(type_class != H5T_COMPOUND)
+ goto out;
+
+ /* There should be 101 compound members */
+ if((nmembs = H5Tget_nmembers(dtype))<0)
+ goto out;
+ if(nmembs != 101)
+ goto out;
+
+ if(line)
+ free(line);
+
+ PASSED();
+ return 0;
+
+out:
+ H5_FAILED();
+ return -1;
+}
+
+/*-------------------------------------------------------------------------
* test H5LTtext_to_dtype function
*-------------------------------------------------------------------------
*/
@@ -1543,6 +1628,9 @@ static int test_text_dtype(void)
if(test_compounds()<0)
goto out;
+
+ if(test_complicated_compound()<0)
+ goto out;
return 0;