ICU-770 Verify that ICU can be reused after calling u_cleanup

X-SVN-Rev: 7439
This commit is contained in:
George Rhoten 2002-01-16 04:33:33 +00:00
parent 57571f33e3
commit e6dfe4d735
4 changed files with 85 additions and 74 deletions

View file

@ -57,67 +57,73 @@ int main(int argc, const char* const argv[])
UResourceBundle *rb;
UConverter *cnv;
while (REPEAT_TESTS > 0) {
#ifdef CTST_LEAK_CHECK
ctst_init();
ctst_init();
#endif
/* If no ICU_DATA environment was set, try to fake up one. */
ctest_setICU_DATA();
/* If no ICU_DATA environment was set, try to fake up one. */
ctest_setICU_DATA();
#ifdef XP_MAC_CONSOLE
argc = ccommand((char***)&argv);
argc = ccommand((char***)&argv);
#endif
cnv = ucnv_open(NULL, &errorCode);
if(cnv != NULL) {
/* ok */
ucnv_close(cnv);
} else {
fprintf(stderr,
"*** Failure! The default converter cannot be opened.\n"
"*** Check the ICU_DATA environment variable and \n"
"*** check that the data files are present.\n");
return 1;
}
/* try more data */
cnv = ucnv_open("iso-8859-7", &errorCode);
if(cnv != 0) {
/* ok */
ucnv_close(cnv);
} else {
fprintf(stderr,
"*** Failure! The converter for iso-8859-7 cannot be opened.\n"
cnv = ucnv_open(NULL, &errorCode);
if(cnv != NULL) {
/* ok */
ucnv_close(cnv);
} else {
fprintf(stderr,
"*** Failure! The default converter cannot be opened.\n"
"*** Check the ICU_DATA environment variable and \n"
"*** check that the data files are present.\n");
return 1;
}
return 1;
}
rb = ures_open(NULL, "en", &errorCode);
if(U_SUCCESS(errorCode)) {
/* ok */
ures_close(rb);
} else {
fprintf(stderr,
"*** Failure! The \"en\" locale resource bundle cannot be opened.\n"
"*** Check the ICU_DATA environment variable and \n"
"*** check that the data files are present.\n");
return 1;
}
/* try more data */
cnv = ucnv_open("iso-8859-7", &errorCode);
if(cnv != 0) {
/* ok */
ucnv_close(cnv);
} else {
fprintf(stderr,
"*** Failure! The converter for iso-8859-7 cannot be opened.\n"
"*** Check the ICU_DATA environment variable and \n"
"*** check that the data files are present.\n");
return 1;
}
fprintf(stdout, "Default locale for this run is %s\n", uloc_getDefault());
rb = ures_open(NULL, "en", &errorCode);
if(U_SUCCESS(errorCode)) {
/* ok */
ures_close(rb);
} else {
fprintf(stderr,
"*** Failure! The \"en\" locale resource bundle cannot be opened.\n"
"*** Check the ICU_DATA environment variable and \n"
"*** check that the data files are present.\n");
return 1;
}
root = NULL;
addAllTests(&root);
nerrors = processArgs(root, argc, argv);
cleanUpTestTree(root);
fprintf(stdout, "Default locale for this run is %s\n", uloc_getDefault());
root = NULL;
addAllTests(&root);
nerrors = processArgs(root, argc, argv);
if (--REPEAT_TESTS > 0) {
printf("Repeating tests %d more time(s)\n", REPEAT_TESTS);
}
cleanUpTestTree(root);
#ifdef CTST_LEAK_CHECK
ctst_freeAll();
ctst_freeAll();
/* To check for leaks */
/* To check for leaks */
u_cleanup(); /* nuke the hashtable.. so that any still-open cnvs are leaked */
u_cleanup(); /* nuke the hashtable.. so that any still-open cnvs are leaked */
#endif
}
return nerrors ? 1 : 0;
}
@ -344,5 +350,6 @@ void ctst_freeAll() {
free(ctst_allocated_stuff[i]);
}
}
_testDirectory=NULL;
}
#endif

View file

@ -91,6 +91,7 @@ static void TestEnd()
{
TOCLOSE_ = TRUE;
close();
TOCLOSE_ = TRUE;
}
/**

View file

@ -57,10 +57,13 @@ static void iterateTestsWithLevel( const TestNode *root, int len,
static void help ( const char *argv0 );
static int ERRONEOUS_FUNCTION_COUNT = 0;
int ERROR_COUNT = 0;
static int ERROR_COUNT = 0; /* Count of errors from all tests. */
static int INDENT_LEVEL = 0;
int VERBOSITY = 0; /* be No-verbose by default */
int ERR_MSG =1; /*error messages will be displayed by default*/
int REPEAT_TESTS_INIT = 0; /* Was REPEAT_TESTS initialized? */
int REPEAT_TESTS = 1; /* Number of times to run the test */
int VERBOSITY = 0; /* be No-verbose by default */
int ERR_MSG =1; /* error messages will be displayed by default*/
int QUICK = 1; /* Skip some of the slower tests? */
/*-------------------------------------------*/
/* strncmp that also makes sure there's a \0 at s2[0] */
@ -420,7 +423,6 @@ int processArgs(const TestNode* root,
const TestNode* toRun;
int i;
int doList = FALSE;
int runAll = FALSE;
int subtreeOptionSeen = FALSE;
int errorCount = 0;
@ -448,8 +450,6 @@ int processArgs(const TestNode* root,
if( doList == TRUE)
showTests(toRun);
else if( runAll == TRUE)
runTests(toRun);
else
runTests(toRun);
@ -457,11 +457,7 @@ int processArgs(const TestNode* root,
subtreeOptionSeen = TRUE;
}
else if (strcmp( argv[i], "-v" )==0 )
{
VERBOSITY = TRUE;
}
else if (strcmp( argv[i], "-verbose")==0 )
else if (strcmp( argv[i], "-v" )==0 || strcmp( argv[i], "-verbose")==0)
{
VERBOSITY = TRUE;
}
@ -469,21 +465,19 @@ int processArgs(const TestNode* root,
{
doList = TRUE;
}
else if (strcmp( argv[i], "-all") ==0)
else if (strcmp( argv[i], "-e") ==0)
{
runAll = TRUE;
QUICK = TRUE;
}
else if(strcmp( argv[i], "-a") == 0)
{
runAll = TRUE;
}
else if(strcmp( argv[i], "-n") == 0)
else if(strcmp( argv[i], "-n") == 0 || strcmp( argv[i], "-no_err_msg") == 0)
{
ERR_MSG = FALSE;
}
else if (strcmp( argv[i], "-no_err_msg") == 0)
else if (strcmp( argv[i], "-r") == 0)
{
ERR_MSG = FALSE;
if (!REPEAT_TESTS_INIT) {
REPEAT_TESTS++;
}
}
else if (strcmp( argv[1], "-h" )==0 )
{
@ -502,8 +496,6 @@ int processArgs(const TestNode* root,
{
if( doList == TRUE)
showTests(toRun);
else if( runAll == TRUE)
runTests(toRun);
else
runTests(toRun);
@ -515,6 +507,8 @@ int processArgs(const TestNode* root,
printf(" Total errors: %d\n", errorCount );
}
REPEAT_TESTS_INIT = 1;
return errorCount; /* total error count */
}
@ -527,13 +521,13 @@ static void help ( const char *argv0 )
printf("Usage: %s [ -l ] [ -v ] [ -verbose] [-a] [ -all] [-n] \n [ -no_err_msg] [ -h ] [ /path/to/test ]\n",
argv0);
printf(" -l To get a list of test names\n");
printf(" -all To run all the test\n");
printf(" -a To run all the test(same a -all)\n");
printf(" -e to do exhaustive testing\n");
printf(" -verbose To turn ON verbosity\n");
printf(" -v To turn ON verbosity(same as -verbose)\n");
printf(" -h To print this message\n");
printf(" -n To turn OFF printing error messages\n");
printf(" -no_err_msg (same as -n) \n");
printf(" -r repeat tests after calling u_cleanup \n");
printf(" -[/subtest] To run a subtest \n");
printf(" eg: to run just the utility tests type: cintltest /tsutil) \n");
}

View file

@ -55,28 +55,37 @@ typedef void (*TestFunctionPtr)();
typedef struct TestNode TestNode;
/**
* Count of errors from all tests.
* May be reset.
* Set this to zero to disable log_verbose() messages.
* Otherwise nonzero to see log_verbose() messages.
*
* @internal Internal APIs for testing purpose only
*/
T_CTEST_EXPORT_API extern int ERROR_COUNT;
T_CTEST_EXPORT_API extern int REPEAT_TESTS;
/**
* Set this to zero to disable log_verbose() messages.
* Otherwise nonzero to see log_verbose() messages.
* @internal Internal APIs for testing purpose only
*
* @internal Internal APIs for testing purpose only
*/
T_CTEST_EXPORT_API extern int VERBOSITY;
/**
* Set this to zero to disable log_verbose() messages.
* Otherwise nonzero to see log_verbose() messages.
* @internal Internal APIs for testing purpose only
*
* @internal Internal APIs for testing purpose only
*/
T_CTEST_EXPORT_API extern int ERR_MSG;
/**
* Set this to zero to disable some of the slower tests.
* Otherwise nonzero to run the slower tests.
*
* @internal Internal APIs for testing purpose only
*/
T_CTEST_EXPORT_API extern int QUICK;
/**
* Show the names of all nodes.
*