[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.
This commit is contained in:
Raymond Lu 2006-05-17 13:09:12 -05:00
parent b562825fc5
commit 0f98d2009b
4 changed files with 170 additions and 71 deletions

View File

@ -784,7 +784,12 @@ int my_yyinput(char *, int);
#undef YY_INPUT
#define YY_INPUT(b, r, ms) (r=my_yyinput(b, ms))
#define token(x) (int)x
#ifdef YY_BUF_SIZE
#undef YY_BUF_SIZE
#endif
#define YY_BUF_SIZE 262144 /*Define read buffer to be 256K*/
extern char *myinput;
extern int input_len;
@ -827,7 +832,7 @@ char *myinput;*/
#define TAG_STRING 1
#line 810 "H5LTanalyze.c"
#line 815 "H5LTanalyze.c"
/* Macros after this point can all be overridden by user definitions in
* section 1.
@ -978,10 +983,10 @@ YY_DECL
register char *yy_cp = NULL, *yy_bp = NULL;
register int yy_act;
#line 70 "H5LTanalyze.l"
#line 75 "H5LTanalyze.l"
#line 964 "H5LTanalyze.c"
#line 969 "H5LTanalyze.c"
if ( yy_init )
{
@ -1067,277 +1072,277 @@ do_action: /* This label is used only to access EOF actions. */
{ /* beginning of action switch */
case 1:
YY_RULE_SETUP
#line 72 "H5LTanalyze.l"
#line 77 "H5LTanalyze.l"
{return token(H5T_STD_I8BE_TOKEN);}
YY_BREAK
case 2:
YY_RULE_SETUP
#line 73 "H5LTanalyze.l"
#line 78 "H5LTanalyze.l"
{return token(H5T_STD_I8LE_TOKEN);}
YY_BREAK
case 3:
YY_RULE_SETUP
#line 74 "H5LTanalyze.l"
#line 79 "H5LTanalyze.l"
{return token(H5T_STD_I16BE_TOKEN);}
YY_BREAK
case 4:
YY_RULE_SETUP
#line 75 "H5LTanalyze.l"
#line 80 "H5LTanalyze.l"
{return token(H5T_STD_I16LE_TOKEN);}
YY_BREAK
case 5:
YY_RULE_SETUP
#line 76 "H5LTanalyze.l"
#line 81 "H5LTanalyze.l"
{return token(H5T_STD_I32BE_TOKEN);}
YY_BREAK
case 6:
YY_RULE_SETUP
#line 77 "H5LTanalyze.l"
#line 82 "H5LTanalyze.l"
{return token(H5T_STD_I32LE_TOKEN);}
YY_BREAK
case 7:
YY_RULE_SETUP
#line 78 "H5LTanalyze.l"
#line 83 "H5LTanalyze.l"
{return token(H5T_STD_I64BE_TOKEN);}
YY_BREAK
case 8:
YY_RULE_SETUP
#line 79 "H5LTanalyze.l"
#line 84 "H5LTanalyze.l"
{return token(H5T_STD_I64LE_TOKEN);}
YY_BREAK
case 9:
YY_RULE_SETUP
#line 81 "H5LTanalyze.l"
#line 86 "H5LTanalyze.l"
{return token(H5T_STD_U8BE_TOKEN);}
YY_BREAK
case 10:
YY_RULE_SETUP
#line 82 "H5LTanalyze.l"
#line 87 "H5LTanalyze.l"
{return token(H5T_STD_U8LE_TOKEN);}
YY_BREAK
case 11:
YY_RULE_SETUP
#line 83 "H5LTanalyze.l"
#line 88 "H5LTanalyze.l"
{return token(H5T_STD_U16BE_TOKEN);}
YY_BREAK
case 12:
YY_RULE_SETUP
#line 84 "H5LTanalyze.l"
#line 89 "H5LTanalyze.l"
{return token(H5T_STD_U16LE_TOKEN);}
YY_BREAK
case 13:
YY_RULE_SETUP
#line 85 "H5LTanalyze.l"
#line 90 "H5LTanalyze.l"
{return token(H5T_STD_U32BE_TOKEN);}
YY_BREAK
case 14:
YY_RULE_SETUP
#line 86 "H5LTanalyze.l"
#line 91 "H5LTanalyze.l"
{return token(H5T_STD_U32LE_TOKEN);}
YY_BREAK
case 15:
YY_RULE_SETUP
#line 87 "H5LTanalyze.l"
#line 92 "H5LTanalyze.l"
{return token(H5T_STD_U64BE_TOKEN);}
YY_BREAK
case 16:
YY_RULE_SETUP
#line 88 "H5LTanalyze.l"
#line 93 "H5LTanalyze.l"
{return token(H5T_STD_U64LE_TOKEN);}
YY_BREAK
case 17:
YY_RULE_SETUP
#line 90 "H5LTanalyze.l"
#line 95 "H5LTanalyze.l"
{return token(H5T_NATIVE_CHAR_TOKEN);}
YY_BREAK
case 18:
YY_RULE_SETUP
#line 91 "H5LTanalyze.l"
#line 96 "H5LTanalyze.l"
{return token(H5T_NATIVE_SCHAR_TOKEN);}
YY_BREAK
case 19:
YY_RULE_SETUP
#line 92 "H5LTanalyze.l"
#line 97 "H5LTanalyze.l"
{return token(H5T_NATIVE_UCHAR_TOKEN);}
YY_BREAK
case 20:
YY_RULE_SETUP
#line 93 "H5LTanalyze.l"
#line 98 "H5LTanalyze.l"
{return token(H5T_NATIVE_SHORT_TOKEN);}
YY_BREAK
case 21:
YY_RULE_SETUP
#line 94 "H5LTanalyze.l"
#line 99 "H5LTanalyze.l"
{return token(H5T_NATIVE_USHORT_TOKEN);}
YY_BREAK
case 22:
YY_RULE_SETUP
#line 95 "H5LTanalyze.l"
#line 100 "H5LTanalyze.l"
{return token(H5T_NATIVE_INT_TOKEN);}
YY_BREAK
case 23:
YY_RULE_SETUP
#line 96 "H5LTanalyze.l"
#line 101 "H5LTanalyze.l"
{return token(H5T_NATIVE_UINT_TOKEN);}
YY_BREAK
case 24:
YY_RULE_SETUP
#line 97 "H5LTanalyze.l"
#line 102 "H5LTanalyze.l"
{return token(H5T_NATIVE_LONG_TOKEN);}
YY_BREAK
case 25:
YY_RULE_SETUP
#line 98 "H5LTanalyze.l"
#line 103 "H5LTanalyze.l"
{return token(H5T_NATIVE_ULONG_TOKEN);}
YY_BREAK
case 26:
YY_RULE_SETUP
#line 99 "H5LTanalyze.l"
#line 104 "H5LTanalyze.l"
{return token(H5T_NATIVE_LLONG_TOKEN);}
YY_BREAK
case 27:
YY_RULE_SETUP
#line 100 "H5LTanalyze.l"
#line 105 "H5LTanalyze.l"
{return token(H5T_NATIVE_ULLONG_TOKEN);}
YY_BREAK
case 28:
YY_RULE_SETUP
#line 102 "H5LTanalyze.l"
#line 107 "H5LTanalyze.l"
{return token(H5T_IEEE_F32BE_TOKEN);}
YY_BREAK
case 29:
YY_RULE_SETUP
#line 103 "H5LTanalyze.l"
#line 108 "H5LTanalyze.l"
{return token(H5T_IEEE_F32LE_TOKEN);}
YY_BREAK
case 30:
YY_RULE_SETUP
#line 104 "H5LTanalyze.l"
#line 109 "H5LTanalyze.l"
{return token(H5T_IEEE_F64BE_TOKEN);}
YY_BREAK
case 31:
YY_RULE_SETUP
#line 105 "H5LTanalyze.l"
#line 110 "H5LTanalyze.l"
{return token(H5T_IEEE_F64LE_TOKEN);}
YY_BREAK
case 32:
YY_RULE_SETUP
#line 106 "H5LTanalyze.l"
#line 111 "H5LTanalyze.l"
{return token(H5T_NATIVE_FLOAT_TOKEN);}
YY_BREAK
case 33:
YY_RULE_SETUP
#line 107 "H5LTanalyze.l"
#line 112 "H5LTanalyze.l"
{return token(H5T_NATIVE_DOUBLE_TOKEN);}
YY_BREAK
case 34:
YY_RULE_SETUP
#line 108 "H5LTanalyze.l"
#line 113 "H5LTanalyze.l"
{return token(H5T_NATIVE_LDOUBLE_TOKEN);}
YY_BREAK
case 35:
YY_RULE_SETUP
#line 110 "H5LTanalyze.l"
#line 115 "H5LTanalyze.l"
{return token(H5T_STRING_TOKEN);}
YY_BREAK
case 36:
YY_RULE_SETUP
#line 111 "H5LTanalyze.l"
#line 116 "H5LTanalyze.l"
{return token(STRSIZE_TOKEN);}
YY_BREAK
case 37:
YY_RULE_SETUP
#line 112 "H5LTanalyze.l"
#line 117 "H5LTanalyze.l"
{return token(STRPAD_TOKEN);}
YY_BREAK
case 38:
YY_RULE_SETUP
#line 113 "H5LTanalyze.l"
#line 118 "H5LTanalyze.l"
{return token(CSET_TOKEN);}
YY_BREAK
case 39:
YY_RULE_SETUP
#line 114 "H5LTanalyze.l"
#line 119 "H5LTanalyze.l"
{return token(CTYPE_TOKEN);}
YY_BREAK
case 40:
YY_RULE_SETUP
#line 115 "H5LTanalyze.l"
#line 120 "H5LTanalyze.l"
{return token(H5T_STR_NULLTERM_TOKEN);}
YY_BREAK
case 41:
YY_RULE_SETUP
#line 116 "H5LTanalyze.l"
#line 121 "H5LTanalyze.l"
{return token(H5T_STR_NULLPAD_TOKEN);}
YY_BREAK
case 42:
YY_RULE_SETUP
#line 117 "H5LTanalyze.l"
#line 122 "H5LTanalyze.l"
{return token(H5T_STR_SPACEPAD_TOKEN);}
YY_BREAK
case 43:
YY_RULE_SETUP
#line 118 "H5LTanalyze.l"
#line 123 "H5LTanalyze.l"
{return token(H5T_CSET_ASCII_TOKEN);}
YY_BREAK
case 44:
YY_RULE_SETUP
#line 119 "H5LTanalyze.l"
#line 124 "H5LTanalyze.l"
{return token(H5T_CSET_UTF8_TOKEN);}
YY_BREAK
case 45:
YY_RULE_SETUP
#line 120 "H5LTanalyze.l"
#line 125 "H5LTanalyze.l"
{return token(H5T_C_S1_TOKEN);}
YY_BREAK
case 46:
YY_RULE_SETUP
#line 121 "H5LTanalyze.l"
#line 126 "H5LTanalyze.l"
{return token(H5T_FORTRAN_S1_TOKEN);}
YY_BREAK
case 47:
YY_RULE_SETUP
#line 122 "H5LTanalyze.l"
#line 127 "H5LTanalyze.l"
{return token(H5T_VARIABLE_TOKEN);}
YY_BREAK
case 48:
YY_RULE_SETUP
#line 124 "H5LTanalyze.l"
#line 129 "H5LTanalyze.l"
{return token(H5T_COMPOUND_TOKEN);}
YY_BREAK
case 49:
YY_RULE_SETUP
#line 125 "H5LTanalyze.l"
#line 130 "H5LTanalyze.l"
{return token(H5T_ENUM_TOKEN);}
YY_BREAK
case 50:
YY_RULE_SETUP
#line 126 "H5LTanalyze.l"
#line 131 "H5LTanalyze.l"
{return token(H5T_ARRAY_TOKEN);}
YY_BREAK
case 51:
YY_RULE_SETUP
#line 127 "H5LTanalyze.l"
#line 132 "H5LTanalyze.l"
{return token(H5T_VLEN_TOKEN);}
YY_BREAK
case 52:
YY_RULE_SETUP
#line 129 "H5LTanalyze.l"
#line 134 "H5LTanalyze.l"
{return token(H5T_OPAQUE_TOKEN);}
YY_BREAK
case 53:
YY_RULE_SETUP
#line 130 "H5LTanalyze.l"
#line 135 "H5LTanalyze.l"
{return token(OPQ_SIZE_TOKEN);}
YY_BREAK
case 54:
YY_RULE_SETUP
#line 131 "H5LTanalyze.l"
#line 136 "H5LTanalyze.l"
{return token(OPQ_TAG_TOKEN);}
YY_BREAK
case 55:
YY_RULE_SETUP
#line 133 "H5LTanalyze.l"
#line 138 "H5LTanalyze.l"
{
if( is_str_size || (is_enum && is_enum_memb) ||
is_opq_size || (asindex>-1 && arr_stack[asindex].is_dim) ||
@ -1350,7 +1355,7 @@ YY_RULE_SETUP
YY_BREAK
case 56:
YY_RULE_SETUP
#line 143 "H5LTanalyze.l"
#line 148 "H5LTanalyze.l"
{
/*if it's first quote, and is a compound field name or an enum symbol*/
if((is_opq_tag || is_enum || (csindex>-1 && cmpd_stack[csindex].is_field))
@ -1364,7 +1369,7 @@ YY_RULE_SETUP
YY_BREAK
case 57:
YY_RULE_SETUP
#line 153 "H5LTanalyze.l"
#line 158 "H5LTanalyze.l"
{
yylval.sval = strdup(yytext);
BEGIN INITIAL;
@ -1373,50 +1378,50 @@ YY_RULE_SETUP
YY_BREAK
case 58:
YY_RULE_SETUP
#line 159 "H5LTanalyze.l"
#line 164 "H5LTanalyze.l"
{return token('{');}
YY_BREAK
case 59:
YY_RULE_SETUP
#line 160 "H5LTanalyze.l"
#line 165 "H5LTanalyze.l"
{return token('}');}
YY_BREAK
case 60:
YY_RULE_SETUP
#line 161 "H5LTanalyze.l"
#line 166 "H5LTanalyze.l"
{return token('[');}
YY_BREAK
case 61:
YY_RULE_SETUP
#line 162 "H5LTanalyze.l"
#line 167 "H5LTanalyze.l"
{return token(']');}
YY_BREAK
case 62:
YY_RULE_SETUP
#line 163 "H5LTanalyze.l"
#line 168 "H5LTanalyze.l"
{return token(':');}
YY_BREAK
case 63:
YY_RULE_SETUP
#line 164 "H5LTanalyze.l"
#line 169 "H5LTanalyze.l"
{return token(';');}
YY_BREAK
case 64:
YY_RULE_SETUP
#line 165 "H5LTanalyze.l"
#line 170 "H5LTanalyze.l"
;
YY_BREAK
case 65:
YY_RULE_SETUP
#line 166 "H5LTanalyze.l"
#line 171 "H5LTanalyze.l"
{ return 0; }
YY_BREAK
case 66:
YY_RULE_SETUP
#line 168 "H5LTanalyze.l"
#line 173 "H5LTanalyze.l"
ECHO;
YY_BREAK
#line 1399 "H5LTanalyze.c"
#line 1404 "H5LTanalyze.c"
case YY_STATE_EOF(INITIAL):
case YY_STATE_EOF(TAG_STRING):
yyterminate();
@ -2292,7 +2297,7 @@ int main()
return 0;
}
#endif
#line 168 "H5LTanalyze.l"
#line 173 "H5LTanalyze.l"
int my_yyinput(char *buf, int max_size)
{

View File

@ -22,7 +22,12 @@ int my_yyinput(char *, int);
#undef YY_INPUT
#define YY_INPUT(b, r, ms) (r=my_yyinput(b, ms))
#define token(x) (int)x
#ifdef YY_BUF_SIZE
#undef YY_BUF_SIZE
#endif
#define YY_BUF_SIZE 262144 /*Define read buffer to be 256K*/
extern char *myinput;
extern int input_len;

1
hl/test/dtype_file.txt Normal file

File diff suppressed because one or more lines are too long

View File

@ -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 );
@ -1512,6 +1516,87 @@ out:
return -1;
}
/*-------------------------------------------------------------------------
* 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;