mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-08 06:53:45 +00:00
ICU-2403 tracing, have cintltst save trace settings across u_cleanup().
Add trace Open and Close option to cintltst X-SVN-Rev: 13896
This commit is contained in:
parent
4a005de2c6
commit
22b16ab91e
4 changed files with 53 additions and 6 deletions
|
@ -158,7 +158,7 @@ ucnv_safeClone(const UConverter* cnv, void *stackBuffer, int32_t *pBufferSize, U
|
|||
UTRACE_ENTRY_OC(UTRACE_UCNV_CLONE);
|
||||
|
||||
if (status == NULL || U_FAILURE(*status)){
|
||||
UTRACE_EXIT_STATUS(*status);
|
||||
UTRACE_EXIT_STATUS(status? *status: U_ILLEGAL_ARGUMENT_ERROR);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -134,15 +134,18 @@ int main(int argc, const char* const argv[])
|
|||
warnOnMissingData = 1;
|
||||
warnOrErr = "Warning";
|
||||
}
|
||||
else if (strcmp( argv[i], "-t_info") == 0) {
|
||||
ICU_TRACE = UTRACE_INFO;
|
||||
}
|
||||
else if (strcmp( argv[i], "-t_error") == 0) {
|
||||
ICU_TRACE = UTRACE_ERROR;
|
||||
}
|
||||
else if (strcmp( argv[i], "-t_warn") == 0) {
|
||||
ICU_TRACE = UTRACE_WARNING;
|
||||
}
|
||||
else if (strcmp( argv[i], "-t_oc") == 0) {
|
||||
ICU_TRACE = UTRACE_OPEN_CLOSE;
|
||||
}
|
||||
else if (strcmp( argv[i], "-t_info") == 0) {
|
||||
ICU_TRACE = UTRACE_INFO;
|
||||
}
|
||||
else if (strcmp( argv[i], "-t_verbose") == 0) {
|
||||
ICU_TRACE = UTRACE_VERBOSE;
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include "unicode/ures.h"
|
||||
#include "cintltst.h"
|
||||
#include "umutex.h"
|
||||
#include "unicode/utrace.h"
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
|
@ -112,15 +113,26 @@ static void TestHeapFunctions() {
|
|||
UResourceBundle *rb = NULL;
|
||||
char *icuDataDir;
|
||||
|
||||
UTraceEntry *traceEntryFunc; /* Tracing function ptrs. We need to save */
|
||||
UTraceExit *traceExitFunc; /* and restore them across calls to */
|
||||
UTraceData *traceDataFunc; /* u_cleanup() that we make in this test. */
|
||||
const void *traceContext;
|
||||
int32_t traceLevel;
|
||||
|
||||
icuDataDir = safeGetICUDataDirectory(); /* save icu data dir, so we can put it back
|
||||
* after doing u_cleanup(). */
|
||||
|
||||
utrace_getFunctions(&traceContext, &traceEntryFunc, &traceExitFunc, &traceDataFunc);
|
||||
traceLevel = utrace_getLevel();
|
||||
|
||||
/* Can not set memory functions if ICU is already initialized */
|
||||
u_setMemoryFunctions(&gContext, myMemAlloc, myMemRealloc, myMemFree, &status);
|
||||
TEST_STATUS(status, U_INVALID_STATE_ERROR);
|
||||
|
||||
/* Un-initialize ICU */
|
||||
u_cleanup();
|
||||
utrace_setFunctions(traceContext, traceEntryFunc, traceExitFunc, traceDataFunc);
|
||||
utrace_setLevel(traceLevel);
|
||||
|
||||
/* Can not set memory functions with NULL values */
|
||||
status = U_ZERO_ERROR;
|
||||
|
@ -161,6 +173,8 @@ static void TestHeapFunctions() {
|
|||
|
||||
/* Cleanup should put the heap back to its default implementation. */
|
||||
u_cleanup();
|
||||
utrace_setFunctions(traceContext, traceEntryFunc, traceExitFunc, traceDataFunc);
|
||||
utrace_setLevel(traceLevel);
|
||||
u_setDataDirectory(icuDataDir);
|
||||
status = U_ZERO_ERROR;
|
||||
u_init(&status);
|
||||
|
@ -242,13 +256,27 @@ static void TestMutexFunctions() {
|
|||
UResourceBundle *rb = NULL;
|
||||
char *icuDataDir;
|
||||
|
||||
UTraceEntry *traceEntryFunc; /* Tracing function ptrs. We need to save */
|
||||
UTraceExit *traceExitFunc; /* and restore them across calls to */
|
||||
UTraceData *traceDataFunc; /* u_cleanup() that we make in this test. */
|
||||
const void *traceContext;
|
||||
int32_t traceLevel;
|
||||
|
||||
/* Save initial ICU state so that it can be restored later.
|
||||
* u_cleanup(), which is called in this test, resets ICU's state.
|
||||
*/
|
||||
icuDataDir = safeGetICUDataDirectory();
|
||||
utrace_getFunctions(&traceContext, &traceEntryFunc, &traceExitFunc, &traceDataFunc);
|
||||
traceLevel = utrace_getLevel();
|
||||
|
||||
/* Can not set mutex functions if ICU is already initialized */
|
||||
u_setMutexFunctions(&gContext, myMutexInit, myMutexDestroy, myMutexLock, myMutexUnlock, &status);
|
||||
TEST_STATUS(status, U_INVALID_STATE_ERROR);
|
||||
|
||||
/* Un-initialize ICU */
|
||||
u_cleanup();
|
||||
utrace_setFunctions(traceContext, traceEntryFunc, traceExitFunc, traceDataFunc);
|
||||
utrace_setLevel(traceLevel);
|
||||
|
||||
/* Can not set Mutex functions with NULL values */
|
||||
status = U_ZERO_ERROR;
|
||||
|
@ -293,6 +321,8 @@ static void TestMutexFunctions() {
|
|||
/* Cleanup should destroy all of the mutexes. */
|
||||
u_cleanup();
|
||||
u_setDataDirectory(icuDataDir);
|
||||
utrace_setFunctions(traceContext, traceEntryFunc, traceExitFunc, traceDataFunc);
|
||||
utrace_setLevel(traceLevel);
|
||||
status = U_ZERO_ERROR;
|
||||
TEST_ASSERT(gTotalMutexesInitialized > 0);
|
||||
TEST_ASSERT(gTotalMutexesActive == 0);
|
||||
|
@ -350,6 +380,11 @@ static void TestIncDecFunctions() {
|
|||
int32_t t = 1; /* random value to make sure that Inc/dec works */
|
||||
char *dataDir;
|
||||
|
||||
UTraceEntry *traceEntryFunc; /* Tracing function ptrs. We need to save */
|
||||
UTraceExit *traceExitFunc; /* and restore them across calls to */
|
||||
UTraceData *traceDataFunc; /* u_cleanup() that we make in this test. */
|
||||
const void *traceContext;
|
||||
int32_t traceLevel;
|
||||
|
||||
/* Can not set mutex functions if ICU is already initialized */
|
||||
u_setAtomicIncDecFunctions(&gIncDecContext, myIncFunc, myDecFunc, &status);
|
||||
|
@ -357,7 +392,11 @@ static void TestIncDecFunctions() {
|
|||
|
||||
/* Un-initialize ICU */
|
||||
dataDir = safeGetICUDataDirectory();
|
||||
utrace_getFunctions(&traceContext, &traceEntryFunc, &traceExitFunc, &traceDataFunc);
|
||||
traceLevel = utrace_getLevel();
|
||||
u_cleanup();
|
||||
utrace_setFunctions(traceContext, traceEntryFunc, traceExitFunc, traceDataFunc);
|
||||
utrace_setLevel(traceLevel);
|
||||
|
||||
/* Can not set functions with NULL values */
|
||||
status = U_ZERO_ERROR;
|
||||
|
@ -397,6 +436,8 @@ static void TestIncDecFunctions() {
|
|||
/* Cleanup should cancel use of our inc/dec functions. */
|
||||
/* Additional ICU operations should not use them */
|
||||
u_cleanup();
|
||||
utrace_setFunctions(traceContext, traceEntryFunc, traceExitFunc, traceDataFunc);
|
||||
utrace_setLevel(traceLevel);
|
||||
gIncCount = 0;
|
||||
gDecCount = 0;
|
||||
status = U_ZERO_ERROR;
|
||||
|
|
|
@ -594,6 +594,9 @@ int processArgs(const TestNode* root,
|
|||
else if (strcmp( argv[i], "-t_verbose") == 0) {
|
||||
ICU_TRACE = UTRACE_VERBOSE;
|
||||
}
|
||||
else if (strcmp( argv[i], "-t_oc") == 0) {
|
||||
ICU_TRACE = UTRACE_OPEN_CLOSE;
|
||||
}
|
||||
else if (strcmp( argv[i], "-h" )==0 || strcmp( argv[i], "--help" )==0)
|
||||
{
|
||||
help( argv[0] );
|
||||
|
@ -634,7 +637,7 @@ int processArgs(const TestNode* root,
|
|||
static void help ( const char *argv0 )
|
||||
{
|
||||
printf("Usage: %s [ -l ] [ -v ] [ -verbose] [-a] [ -all] [-n] [ -no_err_msg]\n"
|
||||
" [ -h ] [-t_info | -t_error | -t_warn | -t_verbose]"
|
||||
" [ -h ] [-t_info | -t_error | -t_warn | -t_oc | -t_verbose]"
|
||||
" [ /path/to/test ]\n",
|
||||
argv0);
|
||||
printf(" -l To get a list of test names\n");
|
||||
|
@ -645,7 +648,7 @@ static void help ( const char *argv0 )
|
|||
printf(" -n To turn OFF printing error messages\n");
|
||||
printf(" -w Don't fail on data-loading errs, just warn. Useful if\n"
|
||||
" user has reduced/changed the common set of ICU data \n");
|
||||
printf(" -t_info | -t_error | -t_warn | -t_verbose Enable ICU tracing\n");
|
||||
printf(" -t_info | -t_error | -t_warn | -t_oc | -t_verbose Enable ICU tracing\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");
|
||||
|
|
Loading…
Add table
Reference in a new issue