2001-03-21 23:22:16 +00:00
|
|
|
/*
|
2000-01-18 02:12:32 +00:00
|
|
|
*****************************************************************************************
|
|
|
|
*
|
2001-03-21 23:22:16 +00:00
|
|
|
* Copyright (C) 1996-2000, International Business Machines
|
2000-01-18 02:12:32 +00:00
|
|
|
* Corporation and others. All Rights Reserved.
|
|
|
|
*
|
|
|
|
*****************************************************************************************
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef CTEST_H
|
|
|
|
#define CTEST_H
|
|
|
|
|
2002-07-19 23:25:41 +00:00
|
|
|
#include "unicode/utypes.h"
|
2000-01-18 02:12:32 +00:00
|
|
|
|
|
|
|
/*Deals with imports and exports of the dynamic library*/
|
2002-07-19 23:25:41 +00:00
|
|
|
#if defined(_WIN32) || defined(U_CYGWIN)
|
2000-01-18 02:12:32 +00:00
|
|
|
#define T_CTEST_EXPORT __declspec(dllexport)
|
|
|
|
#define T_CTEST_IMPORT __declspec(dllimport)
|
|
|
|
#else
|
|
|
|
#define T_CTEST_EXPORT
|
|
|
|
#define T_CTEST_IMPORT
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
#define C_CTEST_API extern "C"
|
|
|
|
#else
|
|
|
|
#define C_CTEST_API
|
2001-03-21 23:22:16 +00:00
|
|
|
#endif
|
2000-01-18 02:12:32 +00:00
|
|
|
|
|
|
|
#ifdef T_CTEST_IMPLEMENTATION
|
|
|
|
#define T_CTEST_API C_CTEST_API T_CTEST_EXPORT
|
|
|
|
#define T_CTEST_EXPORT_API T_CTEST_EXPORT
|
|
|
|
#else
|
|
|
|
#define T_CTEST_API C_CTEST_API T_CTEST_IMPORT
|
|
|
|
#define T_CTEST_EXPORT_API T_CTEST_IMPORT
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* True and false for sanity. (removes ICU dependancy) */
|
|
|
|
|
|
|
|
#ifndef FALSE
|
|
|
|
#define FALSE 0
|
|
|
|
#endif
|
|
|
|
#ifndef TRUE
|
|
|
|
#define TRUE 1
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* prototypes *********************************/
|
|
|
|
|
2002-03-28 18:26:25 +00:00
|
|
|
typedef void (*TestFunctionPtr)(void);
|
2000-01-18 02:12:32 +00:00
|
|
|
typedef struct TestNode TestNode;
|
|
|
|
|
|
|
|
/**
|
2002-01-16 04:33:33 +00:00
|
|
|
* Set this to zero to disable log_verbose() messages.
|
|
|
|
* Otherwise nonzero to see log_verbose() messages.
|
|
|
|
*
|
2000-05-30 21:11:39 +00:00
|
|
|
* @internal Internal APIs for testing purpose only
|
2000-01-18 02:12:32 +00:00
|
|
|
*/
|
2002-01-16 04:33:33 +00:00
|
|
|
T_CTEST_EXPORT_API extern int REPEAT_TESTS;
|
2000-01-18 02:12:32 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set this to zero to disable log_verbose() messages.
|
|
|
|
* Otherwise nonzero to see log_verbose() messages.
|
|
|
|
*
|
2002-01-16 04:33:33 +00:00
|
|
|
* @internal Internal APIs for testing purpose only
|
2000-01-18 02:12:32 +00:00
|
|
|
*/
|
2001-03-21 23:22:16 +00:00
|
|
|
T_CTEST_EXPORT_API extern int VERBOSITY;
|
2000-01-18 02:12:32 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set this to zero to disable log_verbose() messages.
|
|
|
|
* Otherwise nonzero to see log_verbose() messages.
|
|
|
|
*
|
2002-01-16 04:33:33 +00:00
|
|
|
* @internal Internal APIs for testing purpose only
|
2000-01-18 02:12:32 +00:00
|
|
|
*/
|
2001-03-21 23:22:16 +00:00
|
|
|
T_CTEST_EXPORT_API extern int ERR_MSG;
|
2000-01-18 02:12:32 +00:00
|
|
|
|
2002-01-16 04:33:33 +00:00
|
|
|
/**
|
|
|
|
* 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;
|
|
|
|
|
2000-01-18 02:12:32 +00:00
|
|
|
/**
|
|
|
|
* Show the names of all nodes.
|
2001-03-21 23:22:16 +00:00
|
|
|
*
|
2000-01-18 02:12:32 +00:00
|
|
|
* @param root Subtree of tests.
|
2000-05-30 21:11:39 +00:00
|
|
|
* @internal Internal APIs for testing purpose only
|
2000-01-18 02:12:32 +00:00
|
|
|
*/
|
|
|
|
T_CTEST_API void showTests ( const TestNode *root);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Run a subtree of tests.
|
2001-03-21 23:22:16 +00:00
|
|
|
*
|
2000-01-18 02:12:32 +00:00
|
|
|
* @param root Subtree of tests.
|
2000-05-30 21:11:39 +00:00
|
|
|
* @internal Internal APIs for testing purpose only
|
2000-01-18 02:12:32 +00:00
|
|
|
*/
|
|
|
|
T_CTEST_API void runTests ( const TestNode* root);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Add a test to the subtree.
|
|
|
|
* Example usage:
|
|
|
|
* <PRE>
|
|
|
|
* TestNode* root=NULL;
|
|
|
|
* addTest(&root, &mytest, "/a/b/mytest" );
|
|
|
|
* </PRE>
|
|
|
|
* @param root Pointer to the root pointer.
|
|
|
|
* @param test Pointer to 'void function(void)' for actual test.
|
|
|
|
* @param path Path from root under which test will be placed. Ex. '/a/b/mytest'
|
2000-05-30 21:11:39 +00:00
|
|
|
* @internal Internal APIs for testing purpose only
|
2000-01-18 02:12:32 +00:00
|
|
|
*/
|
|
|
|
T_CTEST_API void addTest ( TestNode** root,
|
|
|
|
TestFunctionPtr test,
|
|
|
|
const char *path);
|
|
|
|
|
2000-07-06 23:01:50 +00:00
|
|
|
T_CTEST_API void cleanUpTestTree(TestNode *tn);
|
|
|
|
|
2000-01-18 02:12:32 +00:00
|
|
|
/**
|
|
|
|
* Retreive a specific subtest. (subtree).
|
|
|
|
*
|
|
|
|
* @param root Pointer to the root.
|
|
|
|
* @param path Path relative to the root, Ex. '/a/b'
|
|
|
|
* @return The subtest, or NULL on failure.
|
2000-05-30 21:11:39 +00:00
|
|
|
* @internal Internal APIs for testing purpose only
|
2000-01-18 02:12:32 +00:00
|
|
|
*/
|
|
|
|
T_CTEST_API const TestNode* getTest (const TestNode* root,
|
|
|
|
const char *path);
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Log an error message. (printf style)
|
|
|
|
* @param pattern printf-style format string
|
2000-05-30 21:11:39 +00:00
|
|
|
* @internal Internal APIs for testing purpose only
|
2000-01-18 02:12:32 +00:00
|
|
|
*/
|
|
|
|
T_CTEST_API void log_err(const char* pattern, ...);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Log an informational message. (printf style)
|
|
|
|
* @param pattern printf-style format string
|
2000-05-30 21:11:39 +00:00
|
|
|
* @internal Internal APIs for testing purpose only
|
2000-01-18 02:12:32 +00:00
|
|
|
*/
|
|
|
|
T_CTEST_API void log_info(const char* pattern, ...);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Log a verbose informational message. (printf style)
|
|
|
|
* This message will only appear if the global VERBOSITY is nonzero
|
|
|
|
* @param pattern printf-style format string
|
2000-05-30 21:11:39 +00:00
|
|
|
* @internal Internal APIs for testing purpose only
|
2000-01-18 02:12:32 +00:00
|
|
|
*/
|
|
|
|
T_CTEST_API void log_verbose(const char* pattern, ...);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Processes the command line arguments.
|
|
|
|
* This is a sample implementation
|
|
|
|
* <PRE>Usage: %s [ -l ] [ -v ] [ -? ] [ /path/to/test ]
|
|
|
|
* -l List only, do not run\
|
|
|
|
* -v turn OFF verbosity
|
|
|
|
* -? print this message</PRE>
|
|
|
|
* @param root Testnode root with tests already attached to it
|
|
|
|
* @param argv argument list from main (stdio.h)
|
|
|
|
* @param argc argument list count from main (stdio.h)
|
|
|
|
* @return positive for error count, 0 for success, negative for illegal argument
|
2000-05-30 21:11:39 +00:00
|
|
|
* @internal Internal APIs for testing purpose only
|
2000-01-18 02:12:32 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
T_CTEST_API int processArgs(const TestNode* root,
|
|
|
|
int argc,
|
2000-09-21 18:41:55 +00:00
|
|
|
const char* const argv[]);
|
2000-01-18 02:12:32 +00:00
|
|
|
|
|
|
|
|
2002-05-02 21:16:33 +00:00
|
|
|
T_CTEST_API
|
|
|
|
const char* getTestName(void);
|
|
|
|
|
2000-01-18 02:12:32 +00:00
|
|
|
|
|
|
|
|
|
|
|
#endif
|