Commit 68ea9984 authored by jds2's avatar jds2

Added callback for suite cleanup failure.


git-svn-id: http://svn.code.sf.net/p/cunit/code/trunk@72 f00e6729-6848-4c17-8bfb-678c97c00071
parent f017dee1
......@@ -68,6 +68,9 @@
extern "C" {
#endif
/** CUnit version number. */
#define CU_VERSION "2.0-3"
/* Max string lengths for names (includes terminating NULL. */
/** Maximum length of a test name string. */
#define MAX_TEST_NAME_LENGTH 256
......
......@@ -125,22 +125,31 @@ typedef void (*CU_TestCompleteMessageHandler)(const CU_pTest pTest, const CU_pSu
* message handler is called.
*/
typedef void (*CU_AllTestsCompleteMessageHandler)(const CU_pFailureRecord pFailure);
/** Message handler called when a suite initializer fails.
* The test run is considered in progress when the
* message handler is called.
*/
typedef void (*CU_SuiteInitFailureMessageHandler)(const CU_pSuite pSuite);
/** Message handler called when a suite cleanup function fails.
* The test run is considered in progress when the
* message handler is called.
*/
typedef void (*CU_SuiteCleanupFailureMessageHandler)(const CU_pSuite pSuite);
/* Get/Set functions for Message Handlers. */
void CU_set_test_start_handler(CU_TestStartMessageHandler pTestStartMessage);
void CU_set_test_complete_handler(CU_TestCompleteMessageHandler pTestCompleteMessage);
void CU_set_all_test_complete_handler(CU_AllTestsCompleteMessageHandler pAllTestsCompleteMessage);
void CU_set_suite_init_failure_handler(CU_SuiteInitFailureMessageHandler pSuiteInitFailureMessage);
void CU_set_suite_cleanup_failure_handler(CU_SuiteCleanupFailureMessageHandler pSuiteCleanupFailureMessage);
CU_TestStartMessageHandler CU_get_test_start_handler(void);
CU_TestCompleteMessageHandler CU_get_test_complete_handler(void);
CU_AllTestsCompleteMessageHandler CU_get_all_test_complete_handler(void);
CU_SuiteInitFailureMessageHandler CU_get_suite_init_failure_handler(void);
CU_TestStartMessageHandler CU_get_test_start_handler(void);
CU_TestCompleteMessageHandler CU_get_test_complete_handler(void);
CU_AllTestsCompleteMessageHandler CU_get_all_test_complete_handler(void);
CU_SuiteInitFailureMessageHandler CU_get_suite_init_failure_handler(void);
CU_SuiteCleanupFailureMessageHandler CU_get_suite_cleanup_failure_handler(void);
/* Functions for running registered tests and suites. */
CU_ErrorCode CU_run_all_tests(void);
......
/*
* CUnit - A Unit testing framework library for C.
* Copyright (C) 2001 Anil Kumar
* Copyright (C) 2004 Anil Kumar, Jerry St.Clair
* Copyright (C) 2004, 2005 Anil Kumar, Jerry St.Clair
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
......@@ -40,6 +40,10 @@
* automated_run_tests now assigns a generic file name if
* none has been supplied.
* Email : jds2@users.sourceforge.net
*
* Modified : 30-Apr-2005 (JDS)
* Comment : Added notification of failed suite cleanup function.
* Email : jds2@users.sourceforge.net
*/
/** @file
......@@ -82,6 +86,7 @@ static void automated_test_start_message_handler(const CU_pTest pTest, const CU_
static void automated_test_complete_message_handler(const CU_pTest pTest, const CU_pSuite pSuite, const CU_pFailureRecord pFailure);
static void automated_all_tests_complete_message_handler(const CU_pFailureRecord pFailure);
static void automated_suite_init_failure_message_handler(const CU_pSuite pSuite);
static void automated_suite_cleanup_failure_message_handler(const CU_pSuite pSuite);
/*------------------------------------------------------------------------*/
/** Run CUnit tests using the automated interface.
......@@ -113,6 +118,7 @@ void CU_automated_run_tests(void)
CU_set_test_complete_handler(automated_test_complete_message_handler);
CU_set_all_test_complete_handler(automated_all_tests_complete_message_handler);
CU_set_suite_init_failure_handler(automated_suite_init_failure_message_handler);
CU_set_suite_cleanup_failure_handler(automated_suite_cleanup_failure_message_handler);
f_bWriting_CUNIT_RUN_SUITE = FALSE;
......@@ -388,7 +394,33 @@ static void automated_suite_init_failure_message_handler(const CU_pSuite pSuite)
" <FAILURE_REASON> %s </FAILURE_REASON> \n"
" </CUNIT_RUN_SUITE_FAILURE> \n"
" </CUNIT_RUN_SUITE> \n",
pSuite->pName, "Initialize Failed");
pSuite->pName, "Suite Initialization Failed");
}
/*------------------------------------------------------------------------*/
/** Handler function called when suite cleanup fails.
* @param pSuite The suite for which cleanup failed.
*/
static void automated_suite_cleanup_failure_message_handler(const CU_pSuite pSuite)
{
assert(pSuite);
assert(f_pTestResultFile);
if (f_bWriting_CUNIT_RUN_SUITE) {
fprintf(f_pTestResultFile,
" </CUNIT_RUN_SUITE_SUCCESS> \n"
" </CUNIT_RUN_SUITE> \n");
f_bWriting_CUNIT_RUN_SUITE = FALSE;
}
fprintf(f_pTestResultFile,
" <CUNIT_RUN_SUITE> \n"
" <CUNIT_RUN_SUITE_FAILURE> \n"
" <SUITE_NAME> %s </SUITE_NAME> \n"
" <FAILURE_REASON> %s </FAILURE_REASON> \n"
" </CUNIT_RUN_SUITE_FAILURE> \n"
" </CUNIT_RUN_SUITE> \n",
pSuite->pName, "Suite Cleanup Failed");
}
/*------------------------------------------------------------------------*/
......@@ -407,7 +439,7 @@ static CU_ErrorCode uninitialize_result_file(void)
time(&tTime);
szTime = ctime(&tTime);
fprintf(f_pTestResultFile,
" <CUNIT_FOOTER> File Generated By CUnit at %s </CUNIT_FOOTER> \n"
" <CUNIT_FOOTER> File Generated By CUnit v" CU_VERSION " at %s </CUNIT_FOOTER> \n"
"</CUNIT_TEST_RUN_REPORT>",
szTime ? szTime : "");
......@@ -432,7 +464,7 @@ static CU_ErrorCode automated_list_all_tests(CU_pTestRegistry pRegistry, const c
CU_pTest pTest = NULL;
FILE* pTestListFile = NULL;
char* szTime;
time_t tTime = 0;
time_t tTime = 0;
CU_set_error(CUE_SUCCESS);
......@@ -511,7 +543,7 @@ static CU_ErrorCode automated_list_all_tests(CU_pTestRegistry pRegistry, const c
time(&tTime);
szTime = ctime(&tTime);
fprintf(pTestListFile,
" <CUNIT_FOOTER> File Generated By CUnit at %s </CUNIT_FOOTER> \n"
" <CUNIT_FOOTER> File Generated By CUnit v" CU_VERSION " at %s </CUNIT_FOOTER> \n"
"</CUNIT_TEST_LIST_REPORT>",
szTime ? szTime : "");
......
......@@ -27,6 +27,10 @@
* Modified : 8-Jan-2005 (JDS)
* Comment : Fixed reporting bug (bug report cunit-Bugs-1093861).
* Email : jds2@users.sourceforge.net
*
* Modified : 30-Apr-2005 (JDS)
* Comment : Added notification of suite cleanup failure.
* Email : jds2@users.sourceforge.net
*/
/** @file
......@@ -62,6 +66,7 @@ static void basic_test_start_message_handler(const CU_pTest pTest, const CU_pSui
static void basic_test_complete_message_handler(const CU_pTest pTest, const CU_pSuite pSuite, const CU_pFailureRecord pFailure);
static void basic_all_tests_complete_message_handler(const CU_pFailureRecord pFailure);
static void basic_suite_init_failure_message_handler(const CU_pSuite pSuite);
static void basic_suite_cleanup_failure_message_handler(const CU_pSuite pSuite);
/*------------------------------------------------------------------------*/
/** Run all registered CUnit tests using the basic interface.
......@@ -187,13 +192,14 @@ static CU_ErrorCode basic_initialize(void)
CU_set_error(CUE_SUCCESS);
if (CU_BRM_SILENT != f_run_mode)
fprintf(stdout, "\n\n CUnit : A Unit testing framework for C."
fprintf(stdout, "\n\n CUnit - A Unit testing framework for C - Version " CU_VERSION
"\n http://cunit.sourceforge.net/\n\n");
CU_set_test_start_handler(basic_test_start_message_handler);
CU_set_test_complete_handler(basic_test_complete_message_handler);
CU_set_all_test_complete_handler(basic_all_tests_complete_message_handler);
CU_set_suite_init_failure_handler(basic_suite_init_failure_message_handler);
CU_set_suite_cleanup_failure_handler(basic_suite_cleanup_failure_message_handler);
return CU_get_error();
}
......@@ -358,4 +364,18 @@ static void basic_suite_init_failure_message_handler(const CU_pSuite pSuite)
pSuite->pName);
}
/*------------------------------------------------------------------------*/
/** Handler function called when suite cleanup fails.
* @param pSuite The suite for which cleanup failed.
*/
static void basic_suite_cleanup_failure_message_handler(const CU_pSuite pSuite)
{
assert(pSuite);
if (CU_BRM_SILENT != f_run_mode)
fprintf(stdout,
"\nWARNING - Suite cleanup failed for %s.",
pSuite->pName);
}
/** @} */
/*
* CUnit - A Unit testing framework library for C.
* Copyright (C) 2001 Anil Kumar
* Copyright (C) 2004 Anil Kumar, Jerry St.Clair
* Copyright (C) 2004, 2005 Anil Kumar, Jerry St.Clair
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
......@@ -33,7 +33,11 @@
* Email : aksaharan@yahoo.com
*
* Modified : 17-Jul-2004 (JDS)
* Comment : New interface, doxygen comments, reformat console output
* Comment : New interface, doxygen comments, reformat console output.
* Email : jds2@users.sourceforge.net
*
* Modified : 30-Apr-2005 (JDS)
* Comment : Added notification of suite cleanup failure.
* Email : jds2@users.sourceforge.net
*/
......@@ -79,6 +83,7 @@ static void console_test_start_message_handler(const CU_pTest pTest, const CU_pS
static void console_test_complete_message_handler(const CU_pTest pTest, const CU_pSuite pSuite, const CU_pFailureRecord pFailure);
static void console_all_tests_complete_message_handler(const CU_pFailureRecord pFailure);
static void console_suite_init_failure_message_handler(const CU_pSuite pSuite);
static void console_suite_cleanup_failure_message_handler(const CU_pSuite pSuite);
static CU_ErrorCode select_test(CU_pSuite pSuite, CU_pTest* pTest);
static CU_ErrorCode select_suite(CU_pTestRegistry pRegistry, CU_pSuite* pSuite);
......@@ -100,7 +105,7 @@ void CU_console_run_tests(void)
setvbuf(stdout, NULL, _IONBF, 0);
setvbuf(stderr, NULL, _IONBF, 0);
fprintf(stdout, "\n\n CUnit : A Unit testing framework for C."
fprintf(stdout, "\n\n CUnit - A Unit testing framework for C - Version " CU_VERSION
"\n http://cunit.sourceforge.net/\n\n");
if (NULL == pRegistry) {
......@@ -112,6 +117,7 @@ void CU_console_run_tests(void)
CU_set_test_complete_handler(console_test_complete_message_handler);
CU_set_all_test_complete_handler(console_all_tests_complete_message_handler);
CU_set_suite_init_failure_handler(console_suite_init_failure_message_handler);
CU_set_suite_cleanup_failure_handler(console_suite_cleanup_failure_message_handler);
console_registry_level_run(pRegistry);
}
......@@ -489,7 +495,7 @@ static void console_all_tests_complete_message_handler(const CU_pFailureRecord p
pRunSummary->nAsserts - pRunSummary->nAssertsFailed,
pRunSummary->nAssertsFailed);
}
/*------------------------------------------------------------------------*/
/** Handler function called when suite initialization fails.
* @param pSuite The suite for which initialization failed.
......@@ -502,4 +508,16 @@ static void console_suite_init_failure_message_handler(const CU_pSuite pSuite)
pSuite->pName);
}
/*------------------------------------------------------------------------*/
/** Handler function called when suite cleanup fails.
* @param pSuite The suite for which cleanup failed.
*/
static void console_suite_cleanup_failure_message_handler(const CU_pSuite pSuite)
{
assert(pSuite);
fprintf(stdout, "\nWARNING - Suite cleanup failed for %s.",
pSuite->pName);
}
/** @} */
/*
* CUnit - A Unit testing framework library for C.
* Copyright (C) 2001 Anil Kumar
* Copyright (C) 2004 Anil Kumar, Jerry St.Clair
* Copyright (C) 2004, 2005 Anil Kumar, Jerry St.Clair
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
......@@ -383,7 +383,7 @@ static void refresh_windows(void)
/** Refresh the title window. */
static void refresh_title_window(void)
{
const char* const szPackageTitle = "CUnit - A Unit Testing Framework for \'C\'";
const char* const szPackageTitle = "CUnit - A Unit Testing Framework for \'C\' (v" CU_VERSION ")";
const char* const szSite = "http:\\\\cunit.sourceforge.net\\";
static bool bFirstTime = true;
......
/*
* CUnit - A Unit testing framework library for C.
* Copyright (C) 2001 Anil Kumar
* Copyright (C) 2004 Anil Kumar, Jerry St.Clair
* Copyright (C) 2004, 2005 Anil Kumar, Jerry St.Clair
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
......@@ -37,6 +37,11 @@
* tracking to detect reallocations & multiple deletions.
* EMail : jds2@users.sourceforge.net
*
* Modified : 24-Apr-2005 (JDS)
* Comment : Changed type of allocated sizes to size_t to avoid
* signed-unsigned mismatch.
* EMail : jds2@users.sourceforge.net
*
*/
/** @file
......
This diff is collapsed.
......@@ -32,7 +32,7 @@
* run, CUnit cannot be used directly to test itself. That is,
* individual functions could set up and initiate CUnit test runs,
* but the functions themselves cannot be run as CUnit test functions.
* <P />
* <br><br>
* The approach taken here is to set up a mimimal test framework to
* keep track of logical tests. The various unit test functions are
* then free to use the CUnit framework as needed.
......@@ -52,13 +52,14 @@
extern "C" {
#endif
/** Notify the test system that a set of tests is starting
* (optional, for reporting purposes only.
/** Notify the test system that a set of tests is starting.
* Optional - for reporting purposes only.
* @param strName Name to use to designate this set of tests.
*/
void test_cunit_start_tests(const char* strName);
/** Notify the test system that a set of tests is complete
* (optional, for reporting purposes only.
/** Notify the test system that a set of tests is complete.
* Optional - for reporting purposes only.
*/
void test_cunit_end_tests(void);
......@@ -67,6 +68,7 @@ void test_cunit_add_failure(void); /**< Register failure of a test. *
unsigned int test_cunit_test_count(void); /**< Retrieve the number of tests run. */
unsigned int test_cunit_failure_count(void); /**< Retrieve the number of failed tests. */
/** Implementation of test assertion. */
BOOL test_cunit_assert_impl(BOOL value, const char* condition, const char* file, unsigned int line);
/** Test a logical condition.
......
/*
* CUnit - A Unit testing framework library for C.
* Copyright (C) 2001 Anil Kumar
* Copyright (C) 2004, 2005 Anil Kumar, Jerry St.Clair
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
......
* Sun May 01 2005 Jerry St.Clair <jds2@users.sourceforge.net>
- Added callback for suite cleanup failure to TestRun.
- Added processing of suite failure to interfaces.
- Added output of version number from interfaces.
* Sun Apr 24 2005 Jerry St.Clair <jds2@users.sourceforge.net>
- Streamlined jam build system.
- jam now builds in compiler- and debug-specific subdirectories.
......
# Doxyfile 1.3.6
# Doxyfile 1.3.9.1
#---------------------------------------------------------------------------
# Project related configuration options
#---------------------------------------------------------------------------
PROJECT_NAME = CUnit
PROJECT_NUMBER = 2.1.0
PROJECT_NAME = "CUnit Programmers Reference"
PROJECT_NUMBER = 2.0-2
OUTPUT_DIRECTORY = ./doc
CREATE_SUBDIRS = NO
OUTPUT_LANGUAGE = English
USE_WINDOWS_ENCODING = NO
BRIEF_MEMBER_DESC = YES
......@@ -15,6 +16,7 @@ ALWAYS_DETAILED_SEC = NO
INLINE_INHERITED_MEMB = NO
FULL_PATH_NAMES = NO
STRIP_FROM_PATH =
STRIP_FROM_INC_PATH =
SHORT_NAMES = NO
JAVADOC_AUTOBRIEF = YES
MULTILINE_CPP_IS_BRIEF = NO
......@@ -33,6 +35,7 @@ EXTRACT_ALL = NO
EXTRACT_PRIVATE = YES
EXTRACT_STATIC = YES
EXTRACT_LOCAL_CLASSES = YES
EXTRACT_LOCAL_METHODS = NO
HIDE_UNDOC_MEMBERS = NO
HIDE_UNDOC_CLASSES = NO
HIDE_FRIEND_COMPOUNDS = NO
......@@ -52,6 +55,7 @@ GENERATE_DEPRECATEDLIST= YES
ENABLED_SECTIONS =
MAX_INITIALIZER_LINES = 30
SHOW_USED_FILES = YES
SHOW_DIRECTORIES = YES
#---------------------------------------------------------------------------
# configuration options related to warning and progress messages
#---------------------------------------------------------------------------
......@@ -60,12 +64,13 @@ WARNINGS = YES
WARN_IF_UNDOCUMENTED = YES
WARN_IF_DOC_ERROR = YES
WARN_FORMAT = "$file:$line: $text"
WARN_LOGFILE =
WARN_LOGFILE =
#---------------------------------------------------------------------------
# configuration options related to the input files
#---------------------------------------------------------------------------
INPUT = ./CUnit
FILE_PATTERNS = *.c *.h
FILE_PATTERNS = *.c \
*.h
RECURSIVE = YES
EXCLUDE = ./CUnit/Sources/Win
EXCLUDE_SYMLINKS = NO
......@@ -75,6 +80,7 @@ EXAMPLE_PATTERNS =
EXAMPLE_RECURSIVE = NO
IMAGE_PATH =
INPUT_FILTER =
FILTER_PATTERNS =
FILTER_SOURCE_FILES = NO
#---------------------------------------------------------------------------
# configuration options related to source browsing
......@@ -97,9 +103,9 @@ IGNORE_PREFIX =
GENERATE_HTML = YES
HTML_OUTPUT = html
HTML_FILE_EXTENSION = .html
HTML_HEADER =
HTML_FOOTER =
HTML_STYLESHEET = CUnit_dox.css
HTML_HEADER =
HTML_FOOTER =
HTML_STYLESHEET =
HTML_ALIGN_MEMBERS = YES
GENERATE_HTMLHELP = NO
CHM_FILE =
......
......@@ -214,7 +214,7 @@ Does not depend on the run mode.
<H3 ID="console">5.5. Interactive Console Mode</H3>
The console interface is interactive. All the client needs to do is
initiate the console session, and the user controls the test run
interactively. This include selection & running of registered suites
interactively. This includes selection & running of registered suites
and tests, and viewing test results. To start a console session, use
<P ID="console-run" CLASS="indent2"><CITE>void <B>CU_console_run_tests</B>(void)</CITE></P>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment