2000-01-15 02:00:06 +00:00
|
|
|
/********************************************************************
|
2001-07-31 23:32:59 +00:00
|
|
|
* COPYRIGHT:
|
2001-03-21 19:46:49 +00:00
|
|
|
* Copyright (c) 1997-2001, International Business Machines Corporation and
|
2000-01-15 02:00:06 +00:00
|
|
|
* others. All Rights Reserved.
|
|
|
|
********************************************************************/
|
|
|
|
/********************************************************************************
|
1999-08-16 21:50:52 +00:00
|
|
|
*
|
|
|
|
* File CINTLTST.C
|
|
|
|
*
|
|
|
|
* Modification History:
|
2000-12-15 19:16:43 +00:00
|
|
|
* Name Description
|
1999-08-16 21:50:52 +00:00
|
|
|
* Madhu Katragadda Creation
|
|
|
|
*********************************************************************************
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*The main root for C API tests*/
|
|
|
|
|
2000-08-28 21:43:03 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
2000-08-15 02:39:18 +00:00
|
|
|
#include "unicode/utypes.h"
|
2001-01-03 00:18:57 +00:00
|
|
|
#include "unicode/putil.h"
|
2000-08-15 02:39:18 +00:00
|
|
|
|
1999-08-16 21:50:52 +00:00
|
|
|
#include "cintltst.h"
|
2001-08-24 02:49:04 +00:00
|
|
|
#include "umutex.h"
|
2000-08-15 02:39:18 +00:00
|
|
|
|
1999-12-28 23:57:50 +00:00
|
|
|
#include "unicode/uchar.h"
|
|
|
|
#include "unicode/ustring.h"
|
|
|
|
#include "unicode/ucnv.h"
|
2000-03-29 21:48:44 +00:00
|
|
|
#include "unicode/ures.h"
|
2001-08-24 02:49:04 +00:00
|
|
|
#include "unicode/uclean.h"
|
1999-08-16 21:50:52 +00:00
|
|
|
|
2000-08-28 20:24:40 +00:00
|
|
|
#ifdef XP_MAC_CONSOLE
|
|
|
|
# include <console.h>
|
|
|
|
#endif
|
|
|
|
|
2001-08-25 01:06:41 +00:00
|
|
|
#define CTST_LEAK_CHECK 1
|
2001-08-24 02:49:04 +00:00
|
|
|
#ifdef CTST_LEAK_CHECK
|
2001-10-10 00:54:27 +00:00
|
|
|
U_CFUNC void ctst_freeAll(void);
|
2001-08-24 02:49:04 +00:00
|
|
|
U_CFUNC void ctst_init(void);
|
|
|
|
#endif
|
|
|
|
|
2002-02-07 19:37:34 +00:00
|
|
|
static char* _testDataPath=NULL;
|
2000-09-21 18:41:55 +00:00
|
|
|
|
2001-07-31 17:29:43 +00:00
|
|
|
/*
|
|
|
|
* Forward Declarations
|
|
|
|
*/
|
2001-08-18 01:05:52 +00:00
|
|
|
void ctest_setICU_DATA(void);
|
2001-07-31 17:29:43 +00:00
|
|
|
|
2000-09-21 18:41:55 +00:00
|
|
|
int main(int argc, const char* const argv[])
|
1999-08-16 21:50:52 +00:00
|
|
|
{
|
2002-02-20 17:36:11 +00:00
|
|
|
int nerrors = 0;
|
1999-12-08 00:15:46 +00:00
|
|
|
TestNode *root;
|
1999-08-16 21:50:52 +00:00
|
|
|
|
1999-12-08 00:15:46 +00:00
|
|
|
/* initial check for the default converter */
|
|
|
|
UErrorCode errorCode = U_ZERO_ERROR;
|
2000-03-29 21:48:44 +00:00
|
|
|
UResourceBundle *rb;
|
2000-08-28 20:24:40 +00:00
|
|
|
UConverter *cnv;
|
2000-09-21 18:41:55 +00:00
|
|
|
|
2002-04-23 23:24:25 +00:00
|
|
|
/* This must be tested before using anything! */
|
|
|
|
if (!umtx_isInitialized(NULL)) {
|
|
|
|
fprintf(stderr,
|
|
|
|
"*** Failure! The global mutex was not initialized.\n"
|
|
|
|
"*** Make sure the right linker was used.\n");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2002-01-16 04:33:33 +00:00
|
|
|
while (REPEAT_TESTS > 0) {
|
|
|
|
|
2001-08-24 02:49:04 +00:00
|
|
|
#ifdef CTST_LEAK_CHECK
|
2002-01-16 04:33:33 +00:00
|
|
|
ctst_init();
|
2001-08-24 02:49:04 +00:00
|
|
|
#endif
|
2002-03-20 18:36:17 +00:00
|
|
|
/* try opening the data from dll instead of the dat file */
|
|
|
|
cnv = ucnv_open("iso-8859-7", &errorCode);
|
|
|
|
if(cnv != 0) {
|
|
|
|
/* ok */
|
|
|
|
ucnv_close(cnv);
|
|
|
|
} else {
|
|
|
|
fprintf(stderr,
|
|
|
|
"#### WARNING! The converter for iso-8859-7 cannot be loaded from data dll/so."
|
|
|
|
"Proceeding to load data from dat file.\n");
|
|
|
|
errorCode = U_ZERO_ERROR;
|
|
|
|
|
|
|
|
}
|
2001-07-31 17:29:43 +00:00
|
|
|
|
2002-01-16 04:33:33 +00:00
|
|
|
/* If no ICU_DATA environment was set, try to fake up one. */
|
|
|
|
ctest_setICU_DATA();
|
2001-07-31 17:29:43 +00:00
|
|
|
|
2000-08-28 20:24:40 +00:00
|
|
|
#ifdef XP_MAC_CONSOLE
|
2002-01-16 04:33:33 +00:00
|
|
|
argc = ccommand((char***)&argv);
|
2000-08-28 20:24:40 +00:00
|
|
|
#endif
|
|
|
|
|
2002-01-16 04:33:33 +00:00
|
|
|
cnv = ucnv_open(NULL, &errorCode);
|
|
|
|
if(cnv != NULL) {
|
|
|
|
/* ok */
|
|
|
|
ucnv_close(cnv);
|
|
|
|
} else {
|
|
|
|
fprintf(stderr,
|
|
|
|
"*** Failure! The default converter cannot be opened.\n"
|
2000-03-29 21:48:44 +00:00
|
|
|
"*** Check the ICU_DATA environment variable and \n"
|
|
|
|
"*** check that the data files are present.\n");
|
2002-01-16 04:33:33 +00:00
|
|
|
return 1;
|
|
|
|
}
|
2000-03-29 21:48:44 +00:00
|
|
|
|
2002-01-16 04:33:33 +00:00
|
|
|
/* 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;
|
|
|
|
}
|
2000-03-29 21:48:44 +00:00
|
|
|
|
2002-01-16 04:33:33 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
fprintf(stdout, "Default locale for this run is %s\n", uloc_getDefault());
|
2000-06-09 00:05:21 +00:00
|
|
|
|
2002-01-16 04:33:33 +00:00
|
|
|
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);
|
2000-09-21 18:41:55 +00:00
|
|
|
#ifdef CTST_LEAK_CHECK
|
2002-01-16 04:33:33 +00:00
|
|
|
ctst_freeAll();
|
2000-08-11 04:29:07 +00:00
|
|
|
|
2002-01-16 04:33:33 +00:00
|
|
|
/* To check for leaks */
|
2000-08-14 23:14:23 +00:00
|
|
|
|
2002-01-16 04:33:33 +00:00
|
|
|
u_cleanup(); /* nuke the hashtable.. so that any still-open cnvs are leaked */
|
2000-08-14 23:14:23 +00:00
|
|
|
#endif
|
2002-01-16 04:33:33 +00:00
|
|
|
}
|
2000-08-14 23:14:23 +00:00
|
|
|
|
2000-08-11 04:29:07 +00:00
|
|
|
return nerrors ? 1 : 0;
|
1999-08-16 21:50:52 +00:00
|
|
|
}
|
|
|
|
|
2001-07-31 23:32:59 +00:00
|
|
|
void
|
|
|
|
ctest_pathnameInContext( char* fullname, int32_t maxsize, const char* relPath )
|
1999-08-16 21:50:52 +00:00
|
|
|
{
|
2000-12-15 19:16:43 +00:00
|
|
|
char mainDirBuffer[1024];
|
2000-05-15 18:39:17 +00:00
|
|
|
char* mainDir = NULL;
|
2000-12-15 19:16:43 +00:00
|
|
|
const char *dataDirectory = u_getDataDirectory();
|
1999-08-16 21:50:52 +00:00
|
|
|
const char inpSepChar = '|';
|
|
|
|
char* tmp;
|
|
|
|
int32_t lenMainDir;
|
2000-12-15 19:16:43 +00:00
|
|
|
int32_t lenRelPath;
|
|
|
|
|
|
|
|
#ifdef XP_MAC
|
|
|
|
Str255 volName;
|
|
|
|
int16_t volNum;
|
|
|
|
OSErr err = GetVol( volName, &volNum );
|
|
|
|
if (err != noErr)
|
|
|
|
volName[0] = 0;
|
|
|
|
mainDir = (char*) &(volName[1]);
|
|
|
|
mainDir[volName[0]] = 0;
|
1999-08-16 21:50:52 +00:00
|
|
|
#else
|
2000-12-15 19:16:43 +00:00
|
|
|
if (dataDirectory != NULL) {
|
|
|
|
strcpy(mainDirBuffer, dataDirectory);
|
2000-03-22 01:57:16 +00:00
|
|
|
strcat(mainDirBuffer, ".." U_FILE_SEP_STRING);
|
2000-12-15 19:16:43 +00:00
|
|
|
} else {
|
|
|
|
mainDirBuffer[0]='\0';
|
|
|
|
}
|
|
|
|
mainDir = mainDirBuffer;
|
1999-08-16 21:50:52 +00:00
|
|
|
#endif
|
|
|
|
|
2001-03-29 01:08:13 +00:00
|
|
|
lenMainDir = (int32_t)strlen(mainDir);
|
2000-03-22 01:57:16 +00:00
|
|
|
if(lenMainDir > 0 && mainDir[lenMainDir - 1] != U_FILE_SEP_CHAR) {
|
|
|
|
mainDir[lenMainDir++] = U_FILE_SEP_CHAR;
|
|
|
|
mainDir[lenMainDir] = 0;
|
|
|
|
}
|
|
|
|
|
2000-12-15 19:16:43 +00:00
|
|
|
if (relPath[0] == '|')
|
|
|
|
relPath++;
|
2001-03-29 01:08:13 +00:00
|
|
|
lenRelPath = (int32_t)strlen(relPath);
|
2000-12-15 19:16:43 +00:00
|
|
|
if (maxsize < lenMainDir + lenRelPath + 2) {
|
|
|
|
fullname[0] = 0;
|
|
|
|
return;
|
|
|
|
}
|
2001-03-29 01:08:13 +00:00
|
|
|
strcpy(fullname, mainDir);
|
|
|
|
/*strcat(fullname, U_FILE_SEP_STRING);*/
|
|
|
|
strcat(fullname, relPath);
|
|
|
|
strchr(fullname, inpSepChar);
|
1999-08-16 21:50:52 +00:00
|
|
|
tmp = strchr(fullname, inpSepChar);
|
|
|
|
while (tmp) {
|
2000-03-22 01:57:16 +00:00
|
|
|
*tmp = U_FILE_SEP_CHAR;
|
2001-03-29 01:08:13 +00:00
|
|
|
tmp = strchr(tmp+1, inpSepChar);
|
1999-08-16 21:50:52 +00:00
|
|
|
}
|
|
|
|
}
|
2000-03-22 01:57:16 +00:00
|
|
|
|
2001-07-31 17:29:43 +00:00
|
|
|
|
|
|
|
/* ctest_setICU_DATA - if the ICU_DATA environment variable is not already
|
|
|
|
* set, try to deduce the directory in which ICU was built,
|
|
|
|
* and set ICU_DATA to "icu/source/data" in that location.
|
|
|
|
* The intent is to allow the tests to have a good chance
|
|
|
|
* of running without requiring that the user manually set
|
|
|
|
* ICU_DATA. Common data isn't a problem, since it is
|
|
|
|
* picked up via a static (build time) reference, but the
|
|
|
|
* tests dynamically load some data.
|
|
|
|
*/
|
|
|
|
void ctest_setICU_DATA() {
|
2001-08-20 23:48:50 +00:00
|
|
|
const char *original_ICU_DATA = getenv("ICU_DATA");
|
2001-07-31 17:29:43 +00:00
|
|
|
|
2001-11-08 01:29:11 +00:00
|
|
|
if (original_ICU_DATA != NULL && *original_ICU_DATA != 0) {
|
2001-08-20 23:48:50 +00:00
|
|
|
/* If the user set ICU_DATA, don't second-guess the person. */
|
2001-07-31 17:29:43 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2001-11-02 02:24:15 +00:00
|
|
|
/* U_TOPBUILDDIR is set by the makefiles on UNIXes when building cintltst and intltst
|
2002-04-02 02:55:31 +00:00
|
|
|
// to point to the top of the build hierarchy, which may or
|
|
|
|
// may not be the same as the source directory, depending on
|
|
|
|
// the configure options used. At any rate,
|
|
|
|
// set the data path to the built data from this directory.
|
|
|
|
// The value is complete with quotes, so it can be used
|
|
|
|
// as-is as a string constant.
|
|
|
|
*/
|
2001-11-02 02:24:15 +00:00
|
|
|
#if defined (U_TOPBUILDDIR)
|
2001-07-31 17:29:43 +00:00
|
|
|
{
|
2002-01-31 19:38:26 +00:00
|
|
|
static char env_string[] = U_TOPBUILDDIR U_FILE_SEP_STRING "data"U_FILE_SEP_STRING"out"U_FILE_SEP_STRING;
|
2001-08-20 23:48:50 +00:00
|
|
|
u_setDataDirectory(env_string);
|
2001-07-31 18:52:47 +00:00
|
|
|
return;
|
2001-07-31 17:29:43 +00:00
|
|
|
}
|
2001-09-18 21:02:14 +00:00
|
|
|
#else
|
2001-07-31 17:29:43 +00:00
|
|
|
|
2001-07-31 23:32:59 +00:00
|
|
|
/* On Windows, the file name obtained from __FILE__ includes a full path.
|
|
|
|
* This file is "wherever\icu\source\test\cintltst\cintltst.c"
|
|
|
|
* Change to "wherever\icu\source\data"
|
2001-07-31 17:29:43 +00:00
|
|
|
*/
|
|
|
|
{
|
2001-11-02 02:24:15 +00:00
|
|
|
char p[sizeof(__FILE__) + 10];
|
2001-07-31 17:29:43 +00:00
|
|
|
char *pBackSlash;
|
|
|
|
int i;
|
2001-07-31 23:32:59 +00:00
|
|
|
|
2001-08-20 23:48:50 +00:00
|
|
|
strcpy(p, __FILE__);
|
2001-07-31 17:29:43 +00:00
|
|
|
/* We want to back over three '\' chars. */
|
|
|
|
/* Only Windows should end up here, so looking for '\' is safe. */
|
|
|
|
for (i=1; i<=3; i++) {
|
2001-08-20 23:48:50 +00:00
|
|
|
pBackSlash = strrchr(p, U_FILE_SEP_CHAR);
|
2001-07-31 17:29:43 +00:00
|
|
|
if (pBackSlash != NULL) {
|
|
|
|
*pBackSlash = 0; /* Truncate the string at the '\' */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pBackSlash != NULL) {
|
2001-07-31 23:32:59 +00:00
|
|
|
/* We found and truncated three names from the path.
|
2001-07-31 17:29:43 +00:00
|
|
|
* Now append "source\data" and set the environment
|
|
|
|
*/
|
2002-02-19 02:07:41 +00:00
|
|
|
strcpy(pBackSlash, U_FILE_SEP_STRING "data" U_FILE_SEP_STRING "out" U_FILE_SEP_STRING);
|
2001-08-20 23:48:50 +00:00
|
|
|
u_setDataDirectory(p); /* p is "ICU_DATA=wherever\icu\source\data" */
|
2001-07-31 17:29:43 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2001-09-18 21:02:14 +00:00
|
|
|
#endif
|
2001-07-31 17:29:43 +00:00
|
|
|
|
|
|
|
/* No location for the data dir was identifiable.
|
|
|
|
* Add other fallbacks for the test data location here if the need arises
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1999-08-16 21:50:52 +00:00
|
|
|
char *austrdup(const UChar* unichars)
|
|
|
|
{
|
|
|
|
int length;
|
|
|
|
char *newString;
|
|
|
|
|
|
|
|
length = u_strlen ( unichars );
|
2000-07-06 23:01:50 +00:00
|
|
|
/*newString = (char*)malloc ( sizeof( char ) * 4 * ( length + 1 ) );*/ /* this leaks for now */
|
|
|
|
newString = (char*)ctst_malloc ( sizeof( char ) * 4 * ( length + 1 ) ); /* this shouldn't */
|
2000-12-15 19:16:43 +00:00
|
|
|
|
1999-08-16 21:50:52 +00:00
|
|
|
if ( newString == NULL )
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
u_austrcpy ( newString, unichars );
|
|
|
|
|
|
|
|
return newString;
|
|
|
|
}
|
2000-07-06 23:01:50 +00:00
|
|
|
|
2002-04-02 03:36:54 +00:00
|
|
|
char *aescstrdup(const UChar* unichars,int32_t length){
|
2001-03-13 23:43:54 +00:00
|
|
|
char *newString,*targetLimit,*target;
|
|
|
|
UConverterFromUCallback cb;
|
2001-06-26 22:51:14 +00:00
|
|
|
const void *p;
|
2001-03-13 23:43:54 +00:00
|
|
|
UErrorCode errorCode = U_ZERO_ERROR;
|
2001-03-14 02:29:54 +00:00
|
|
|
UConverter* conv = ucnv_open("US-ASCII",&errorCode);
|
2002-04-02 03:36:54 +00:00
|
|
|
if(length==-1){
|
|
|
|
length = u_strlen( unichars);
|
|
|
|
}
|
2001-03-14 02:29:54 +00:00
|
|
|
newString = (char*)ctst_malloc ( sizeof(char) * 8 * (length +1));
|
2001-03-13 23:43:54 +00:00
|
|
|
target = newString;
|
2001-03-14 02:29:54 +00:00
|
|
|
targetLimit = newString+sizeof(char) * 8 * (length +1);
|
2001-03-15 00:43:12 +00:00
|
|
|
ucnv_setFromUCallBack(conv, UCNV_FROM_U_CALLBACK_ESCAPE, UCNV_ESCAPE_JAVA, &cb, &p, &errorCode);
|
2001-03-13 23:43:54 +00:00
|
|
|
ucnv_fromUnicode(conv,&target,targetLimit, &unichars, (UChar*)(unichars+length),NULL,TRUE,&errorCode);
|
2001-03-16 02:03:24 +00:00
|
|
|
ucnv_close(conv);
|
2001-03-13 23:43:54 +00:00
|
|
|
*target = '\0';
|
|
|
|
return newString;
|
|
|
|
}
|
|
|
|
|
2002-02-07 19:37:34 +00:00
|
|
|
const char* loadTestData(UErrorCode* err){
|
2002-01-29 04:01:49 +00:00
|
|
|
const char* directory=NULL;
|
|
|
|
UResourceBundle* test =NULL;
|
2002-02-07 19:37:34 +00:00
|
|
|
char* tdpath=NULL;
|
2002-01-29 04:01:49 +00:00
|
|
|
const char* tdrelativepath = ".."U_FILE_SEP_STRING"test"U_FILE_SEP_STRING"testdata"U_FILE_SEP_STRING"out"U_FILE_SEP_STRING;
|
2002-02-07 19:37:34 +00:00
|
|
|
if( _testDataPath == NULL){
|
|
|
|
directory= u_getDataDirectory();
|
2002-01-29 04:01:49 +00:00
|
|
|
|
2002-02-07 19:37:34 +00:00
|
|
|
tdpath = (char*) ctst_malloc(sizeof(char) *(( strlen(directory) * strlen(tdrelativepath)) + 10));
|
|
|
|
|
|
|
|
|
|
|
|
/* u_getDataDirectory shoul return \source\data ... set the
|
|
|
|
* directory to ..\source\data\..\test\testdata\out\testdata
|
|
|
|
*
|
|
|
|
* Fallback: When Memory mapped file is built
|
|
|
|
* ..\source\data\out\..\..\test\testdata\out\testdata
|
|
|
|
*/
|
|
|
|
strcpy(tdpath, directory);
|
|
|
|
strcat(tdpath, tdrelativepath);
|
|
|
|
strcat(tdpath,"testdata");
|
2001-03-13 23:43:54 +00:00
|
|
|
|
2002-01-29 04:01:49 +00:00
|
|
|
|
2002-02-07 19:37:34 +00:00
|
|
|
test=ures_open(tdpath, "testtypes", err);
|
2002-01-29 04:01:49 +00:00
|
|
|
|
2002-02-07 19:37:34 +00:00
|
|
|
/* we could not find the data in tdpath
|
|
|
|
* try tdpathFallback
|
|
|
|
*/
|
|
|
|
if(U_FAILURE(*err))
|
|
|
|
{
|
|
|
|
strcpy(tdpath,directory);
|
|
|
|
strcat(tdpath,".."U_FILE_SEP_STRING);
|
|
|
|
strcat(tdpath, tdrelativepath);
|
|
|
|
strcat(tdpath,"testdata");
|
|
|
|
*err =U_ZERO_ERROR;
|
2002-04-25 21:38:10 +00:00
|
|
|
test=ures_open(tdpath, "testtypes", err);
|
|
|
|
/* we could not find the data in tdpath
|
|
|
|
* try one more tdpathFallback
|
|
|
|
*/
|
2002-02-07 19:37:34 +00:00
|
|
|
if(U_FAILURE(*err)){
|
2002-04-25 21:38:10 +00:00
|
|
|
strcpy(tdpath,directory);
|
|
|
|
strcat(tdpath,".."U_FILE_SEP_STRING);
|
|
|
|
strcat(tdpath,".."U_FILE_SEP_STRING);
|
|
|
|
strcat(tdpath, tdrelativepath);
|
|
|
|
strcat(tdpath,"testdata");
|
|
|
|
*err =U_ZERO_ERROR;
|
|
|
|
test=ures_open(tdpath, "testtypes", err);
|
|
|
|
/* Fall back did not succeed either so return */
|
|
|
|
if(U_FAILURE(*err)){
|
|
|
|
*err = U_FILE_ACCESS_ERROR;
|
|
|
|
log_err("construction of NULL did not succeed : %s \n", u_errorName(*err));
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
ures_close(test);
|
|
|
|
_testDataPath = tdpath;
|
|
|
|
return _testDataPath;
|
2002-02-07 19:37:34 +00:00
|
|
|
}
|
|
|
|
ures_close(test);
|
|
|
|
_testDataPath = tdpath;
|
|
|
|
return _testDataPath;
|
2002-01-29 04:01:49 +00:00
|
|
|
}
|
|
|
|
ures_close(test);
|
2002-02-07 19:37:34 +00:00
|
|
|
_testDataPath = tdpath;
|
|
|
|
return _testDataPath;
|
2002-01-29 04:01:49 +00:00
|
|
|
}
|
2002-02-07 19:37:34 +00:00
|
|
|
return _testDataPath;
|
2002-01-29 04:01:49 +00:00
|
|
|
}
|
2001-03-13 23:43:54 +00:00
|
|
|
|
2000-07-06 23:01:50 +00:00
|
|
|
#define CTST_MAX_ALLOC 10000
|
2001-08-24 02:49:04 +00:00
|
|
|
/* Array used as a queue */
|
2000-07-06 23:01:50 +00:00
|
|
|
static void * ctst_allocated_stuff[CTST_MAX_ALLOC];
|
|
|
|
static int ctst_allocated = 0;
|
2001-08-24 02:49:04 +00:00
|
|
|
static UBool ctst_free = FALSE;
|
|
|
|
|
|
|
|
void ctst_init(void) {
|
|
|
|
int i;
|
|
|
|
for(i=0; i<CTST_MAX_ALLOC; i++) {
|
|
|
|
ctst_allocated_stuff[i] = NULL;
|
|
|
|
}
|
|
|
|
}
|
2000-07-06 23:01:50 +00:00
|
|
|
|
|
|
|
void *ctst_malloc(size_t size) {
|
2001-08-24 02:49:04 +00:00
|
|
|
if(ctst_allocated >= CTST_MAX_ALLOC - 1) {
|
2000-07-06 23:01:50 +00:00
|
|
|
ctst_allocated = 0;
|
2001-08-24 02:49:04 +00:00
|
|
|
ctst_free = TRUE;
|
2000-07-06 23:01:50 +00:00
|
|
|
}
|
2001-08-24 02:49:04 +00:00
|
|
|
if(ctst_allocated_stuff[ctst_allocated]) {
|
2000-07-06 23:01:50 +00:00
|
|
|
free(ctst_allocated_stuff[ctst_allocated]);
|
|
|
|
}
|
2001-08-24 02:49:04 +00:00
|
|
|
return ctst_allocated_stuff[ctst_allocated++] = malloc(size);
|
2000-07-06 23:01:50 +00:00
|
|
|
}
|
|
|
|
|
2000-09-21 18:41:55 +00:00
|
|
|
#ifdef CTST_LEAK_CHECK
|
2000-07-06 23:01:50 +00:00
|
|
|
void ctst_freeAll() {
|
|
|
|
int i;
|
|
|
|
if(ctst_free == 0) {
|
|
|
|
for(i=0; i<ctst_allocated; i++) {
|
|
|
|
free(ctst_allocated_stuff[i]);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
for(i=0; i<CTST_MAX_ALLOC; i++) {
|
|
|
|
free(ctst_allocated_stuff[i]);
|
|
|
|
}
|
|
|
|
}
|
2002-02-07 19:37:34 +00:00
|
|
|
_testDataPath=NULL;
|
2000-07-06 23:01:50 +00:00
|
|
|
}
|
2000-09-25 20:56:12 +00:00
|
|
|
#endif
|