2003-04-01 01:59:04 +08:00
|
|
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
|
|
|
* Copyright by the Board of Trustees of the University of Illinois. *
|
|
|
|
* All rights reserved. *
|
|
|
|
* *
|
|
|
|
* This file is part of HDF5. The full HDF5 copyright notice, including *
|
|
|
|
* terms governing use, modification, and redistribution, is contained in *
|
|
|
|
* the files COPYING and Copyright.html. COPYING can be found at the root *
|
|
|
|
* of the source code distribution tree; Copyright.html can be found at the *
|
|
|
|
* root level of an installed copy of the electronic HDF5 document set and *
|
|
|
|
* is linked from the top-level documents page. It can also be found at *
|
|
|
|
* http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have *
|
|
|
|
* access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. *
|
|
|
|
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
2000-05-19 03:13:33 +08:00
|
|
|
|
|
|
|
/*
|
2000-05-20 07:00:03 +08:00
|
|
|
* FILE
|
|
|
|
* ttsafe.c - HDF5 threadsafe testing framework main file.
|
|
|
|
*
|
|
|
|
* REMARKS
|
|
|
|
* General test wrapper for HDF5 library thread safety test programs
|
|
|
|
*
|
|
|
|
* DESIGN
|
|
|
|
* Each test function should be implemented as function having no
|
|
|
|
* parameters and returning void (i.e. no return value). They should be put
|
|
|
|
* into the list of InitTest() calls in main() below. Functions which depend
|
|
|
|
* on other functionality should be placed below the InitTest() call for the
|
|
|
|
* base functionality testing.
|
|
|
|
* Each test module should include ttsafe.h and define a unique set of
|
|
|
|
* names for test files they create.
|
|
|
|
*
|
|
|
|
* BUGS/LIMITATIONS
|
|
|
|
*
|
|
|
|
* EXPORTED ROUTINES/VARIABLES:
|
2004-01-10 09:41:13 +08:00
|
|
|
*
|
2000-05-19 03:13:33 +08:00
|
|
|
*/
|
|
|
|
|
2004-01-06 05:58:37 +08:00
|
|
|
#include "h5test.h"
|
2004-01-07 01:53:13 +08:00
|
|
|
|
|
|
|
/* ANY new test needs to have a prototype in ttsafe.h */
|
2001-04-04 02:09:16 +08:00
|
|
|
#include "ttsafe.h"
|
2000-05-20 07:00:03 +08:00
|
|
|
|
|
|
|
#ifndef H5_HAVE_THREADSAFE
|
|
|
|
int main(void)
|
|
|
|
{
|
|
|
|
printf("Test skipped because THREADSAFE not enabled\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
|
2000-05-19 03:13:33 +08:00
|
|
|
#define MAX_NUM_NAME 1000
|
|
|
|
#define NAME_OFFSET 6 /* offset for "name<num>" */
|
|
|
|
|
2004-01-07 01:53:13 +08:00
|
|
|
/* pre-condition: num must be a non-negative number */
|
|
|
|
static int num_digits(int num)
|
2000-05-19 03:13:33 +08:00
|
|
|
{
|
2001-08-15 06:09:56 +08:00
|
|
|
int i;
|
2000-05-20 07:00:03 +08:00
|
|
|
|
2004-01-07 01:53:13 +08:00
|
|
|
if (num == 0)
|
|
|
|
return 1;
|
2000-05-19 03:13:33 +08:00
|
|
|
|
2004-01-07 01:53:13 +08:00
|
|
|
for (i = 0; num > 0; i++)
|
|
|
|
num = num / 10;
|
2000-05-19 03:13:33 +08:00
|
|
|
|
2004-01-07 01:53:13 +08:00
|
|
|
return i;
|
2000-05-19 03:13:33 +08:00
|
|
|
}
|
|
|
|
|
2004-01-07 01:53:13 +08:00
|
|
|
/* Routine to generate attribute names for numeric values */
|
2000-05-20 07:00:03 +08:00
|
|
|
char *gen_name(int value)
|
|
|
|
{
|
|
|
|
char *temp;
|
|
|
|
int i, length;
|
2000-05-19 03:13:33 +08:00
|
|
|
|
2000-05-20 07:00:03 +08:00
|
|
|
length = num_digits(MAX_NUM_NAME - 1);
|
2004-01-07 01:53:13 +08:00
|
|
|
temp = (char *)HDmalloc((NAME_OFFSET + length + 1) * sizeof(char));
|
|
|
|
temp = HDstrcpy(temp, "attrib");
|
2000-05-20 07:00:03 +08:00
|
|
|
temp[NAME_OFFSET + length] = '\0';
|
2000-05-19 03:13:33 +08:00
|
|
|
|
2000-05-20 07:00:03 +08:00
|
|
|
for (i = length - 1; i >= 0; i--) {
|
|
|
|
temp[NAME_OFFSET + i] = (char)((int)'0' + value % 10);
|
|
|
|
value = value / 10;
|
|
|
|
}
|
2000-05-19 03:13:33 +08:00
|
|
|
|
2000-05-20 07:00:03 +08:00
|
|
|
return temp;
|
2000-05-19 03:13:33 +08:00
|
|
|
}
|
|
|
|
|
2000-05-20 07:00:03 +08:00
|
|
|
int main(int argc, char *argv[])
|
2000-05-19 03:13:33 +08:00
|
|
|
{
|
2004-01-07 01:53:13 +08:00
|
|
|
/* Initialize testing framework */
|
2004-08-19 14:32:47 +08:00
|
|
|
TestInit(argv[0], NULL, NULL);
|
2000-05-20 07:00:03 +08:00
|
|
|
|
|
|
|
/* Tests are generally arranged from least to most complexity... */
|
2004-03-31 07:35:16 +08:00
|
|
|
AddTest("dcreate", tts_dcreate, cleanup_dcreate, "multi-dataset creation", NULL);
|
|
|
|
AddTest("error", tts_error, cleanup_error, "per-thread error stacks", NULL);
|
|
|
|
AddTest("cancel", tts_cancel, cleanup_cancel, "thread cancellation safety test", NULL);
|
|
|
|
AddTest("acreate", tts_acreate, cleanup_acreate, "multi-attribute creation", NULL);
|
2000-05-20 07:00:03 +08:00
|
|
|
|
2004-01-07 01:53:13 +08:00
|
|
|
/* Display testing information */
|
|
|
|
TestInfo(argv[0]);
|
2000-05-20 07:00:03 +08:00
|
|
|
|
2004-01-07 01:53:13 +08:00
|
|
|
/* Parse command line arguments */
|
2004-08-19 14:32:47 +08:00
|
|
|
TestParseCmdLine(argc,argv);
|
2000-05-20 07:00:03 +08:00
|
|
|
|
2004-01-07 01:53:13 +08:00
|
|
|
/* Perform requested testing */
|
|
|
|
PerformTests();
|
2000-05-20 07:00:03 +08:00
|
|
|
|
2004-01-07 01:53:13 +08:00
|
|
|
/* Display test summary, if requested */
|
2004-08-19 14:32:47 +08:00
|
|
|
if (GetTestSummary())
|
2004-01-07 01:53:13 +08:00
|
|
|
TestSummary();
|
2000-05-20 07:00:03 +08:00
|
|
|
|
2004-01-07 01:53:13 +08:00
|
|
|
/* Clean up test files, if allowed */
|
2004-08-19 14:32:47 +08:00
|
|
|
if (GetTestCleanup() && !getenv("HDF5_NOCLEANUP"))
|
2004-01-07 01:53:13 +08:00
|
|
|
TestCleanup();
|
2000-05-20 07:00:03 +08:00
|
|
|
|
2004-01-10 09:41:13 +08:00
|
|
|
return GetTestNumErrs();
|
2000-05-20 07:00:03 +08:00
|
|
|
} /* end main() */
|
2000-05-19 03:13:33 +08:00
|
|
|
#endif /*H5_HAVE_THREADSAFE*/
|