From cbb3d91299a494fbf1166f368607cf9a1a23cea3 Mon Sep 17 00:00:00 2001 From: John Pye Date: Tue, 19 May 2026 11:09:58 +1000 Subject: [PATCH 1/4] cleanup of build warnings and autotools macro warnings, autotools 'make check' support --- .github/workflows/msys2-build.yml | 4 +- .github/workflows/release.yml | 3 +- .github/workflows/ubuntu-build.yml | 8 +-- .gitignore | 6 ++ CUnit/Sources/Console/Console.c | 70 +++++++++++++++++----- CUnit/Sources/Framework/MyMem.c | 2 +- CUnit/Sources/Framework/TestDB.c | 30 ++++------ CUnit/Sources/Framework/TestRun.c | 35 ++++++----- CUnit/Sources/Test/Makefile.am | 5 +- CUnit/Sources/Test/test_cunit.c | 2 +- Examples/wxWidgetsTest/Makefile.am | 2 +- Makefile.am | 1 + README.md | 94 +++++++++++++++++------------- VERSION | 2 +- configure.in => configure.ac | 21 +++---- 15 files changed, 168 insertions(+), 117 deletions(-) rename configure.in => configure.ac (96%) diff --git a/.github/workflows/msys2-build.yml b/.github/workflows/msys2-build.yml index a9b2e06..cac6427 100644 --- a/.github/workflows/msys2-build.yml +++ b/.github/workflows/msys2-build.yml @@ -45,9 +45,7 @@ jobs: run: make -j"$(nproc)" - name: Run internal self-tests - run: | - ./CUnit/Sources/Test/test_cunit | tee test_cunit.log - grep -q "Failures: 0" test_cunit.log + run: make check - name: Install run: make install diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 825922b..63a78eb 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -198,8 +198,7 @@ jobs: --enable-examples \ --enable-test make -j"$(nproc)" - ./CUnit/Sources/Test/test_cunit | tee test_cunit.log - grep -q "Failures: 0" test_cunit.log + make check test-package: name: Test installed release package (UCRT64) diff --git a/.github/workflows/ubuntu-build.yml b/.github/workflows/ubuntu-build.yml index e8e85e6..ecc1cb6 100644 --- a/.github/workflows/ubuntu-build.yml +++ b/.github/workflows/ubuntu-build.yml @@ -42,9 +42,7 @@ jobs: run: make -j"$(nproc)" - name: Run internal self-tests - run: | - ./CUnit/Sources/Test/test_cunit | tee test_cunit.log - grep -q "Failures: 0" test_cunit.log + run: make check - name: Install run: make install @@ -84,9 +82,7 @@ jobs: run: make -j"$(nproc)" - name: Run internal self-tests - run: | - ./CUnit/Sources/Test/test_cunit | tee test_cunit.log - grep -q "Failures: 0" test_cunit.log + run: make check - name: Generate coverage report run: | diff --git a/.gitignore b/.gitignore index c93d06a..698f857 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ +m4 +test-driver **/Makefile.in aclocal.m4 autom4te.cache/ @@ -30,3 +32,7 @@ CUnit/Headers/CUnit.h CUnit*Dump.xml stamp-h1 CUnit/Sources/Test/test_cunit +CUnit/Sources/Test/test-suite.log +CUnit/Sources/Test/test_cunit.log +CUnit/Sources/Test/test_cunit.trs +cunit-*.tar.gz diff --git a/CUnit/Sources/Console/Console.c b/CUnit/Sources/Console/Console.c index 8f0bc75..c42f183 100644 --- a/CUnit/Sources/Console/Console.c +++ b/CUnit/Sources/Console/Console.c @@ -54,6 +54,7 @@ #include #include #include +#include #include #include "CUnit.h" @@ -80,6 +81,17 @@ static CU_pSuite f_pRunningSuite = NULL; /** Common width measurements for output formatting. */ static size_t f_yes_width = 0; static size_t f_no_width = 0; +/* printf width and precision arguments are typed as int. */ +static int display_width(size_t width) +{ + assert(width <= INT_MAX); + return (int)width; +} + +static size_t max_size_t(size_t a, size_t b) +{ + return (a >= b) ? a : b; +} /*================================================================= * Static function forward declarations @@ -104,6 +116,23 @@ static CU_ErrorCode select_suite(CU_pTestRegistry pRegistry, CU_pSuite* ppSuite) static void list_suites(CU_pTestRegistry pRegistry); static void list_tests(CU_pSuite pSuite); static void show_failures(void); +static int read_line(char* buffer, size_t size); + +/*================================================================= + * Private helper functions + *=================================================================*/ +static int read_line(char* buffer, size_t size) +{ + if (NULL == fgets(buffer, (int)size, stdin)) { + if (size > 0) { + buffer[0] = '\0'; + } + clearerr(stdin); + return 0; + } + + return 1; +} /*================================================================= * Public Interface functions @@ -164,7 +193,10 @@ static void console_registry_level_run(CU_pTestRegistry pRegistry) _("(R)un (S)elect (L)ist (A)ctivate (F)ailures (O)ptions (H)elp (Q)uit"), _("Enter command: ")); chChoice = toupper(getchar()); - fgets(szTemp, 256, stdin); /* flush any chars out of the read buffer */ + if (!read_line(szTemp, sizeof(szTemp))) { + eStatus = CU_STATUS_STOP; + continue; + } if (chChoice == _("R")[0]) { console_run_all_tests(pRegistry); @@ -243,7 +275,10 @@ static CU_STATUS console_suite_level_run(CU_pSuite pSuite) _("(R)un (S)elect (L)ist (A)ctivate (F)ailures (U)p (O)ptions (H)elp (Q)uit"), _("Enter command: ")); chChoice = toupper(getchar()); - fgets(szTemp, 256, stdin); /* flush any chars out of the read buffer */ + if (!read_line(szTemp, sizeof(szTemp))) { + eStatus = CU_STATUS_STOP; + continue; + } if (chChoice == _("R")[0]) { console_run_suite(pSuite); @@ -322,7 +357,10 @@ static CU_STATUS console_set_options_run(void) fprintf(stdout, "%s", _("Enter number of option to change : ")); chChoice = getchar(); - fgets(szTemp, 256, stdin); /* flush any chars out of the read buffer */ + if (!read_line(szTemp, sizeof(szTemp))) { + eStatus = CU_STATUS_MOVE_UP; + continue; + } switch (tolower(chChoice)) { case '1': @@ -420,7 +458,9 @@ static CU_ErrorCode select_test(CU_pSuite pSuite, CU_pTest* ppTest) fprintf(stdout, "\n"); fprintf(stdout, _("Enter number of test to select (1-%u) : "), pSuite->uiNumberOfTests); - fgets(buffer, 100, stdin); + if (!read_line(buffer, sizeof(buffer))) { + return CUE_NOTEST; + } *ppTest = CU_get_test_by_index(atol(buffer), pSuite); } @@ -459,7 +499,9 @@ static CU_ErrorCode select_suite(CU_pTestRegistry pRegistry, CU_pSuite* ppSuite) fprintf(stdout, "\n"); fprintf(stdout, _("Enter number of suite to select (1-%u) : "), pRegistry->uiNumberOfSuites); - fgets(buffer, 100, stdin); + if (!read_line(buffer, sizeof(buffer))) { + return CUE_NOSUITE; + } *ppSuite = CU_get_suite_by_index(atol(buffer), pRegistry); } @@ -476,7 +518,7 @@ static void list_suites(CU_pTestRegistry pRegistry) { CU_pSuite pCurSuite = NULL; int i; - static size_t width[6]; + static int width[6]; if (NULL == pRegistry) { pRegistry = CU_get_registry(); @@ -492,12 +534,12 @@ static void list_suites(CU_pTestRegistry pRegistry) /* only need to calculate formatting widths once */ if (0 == width[0]) { - width[0] = CU_number_width(pRegistry->uiNumberOfSuites) + 1; + width[0] = display_width(CU_number_width(pRegistry->uiNumberOfSuites) + 1); width[1] = 34; - width[2] = CU_MAX(strlen(_("Init?")), CU_MAX(f_yes_width, f_no_width)) + 1; - width[3] = CU_MAX(strlen(_("Cleanup?")), CU_MAX(f_yes_width, f_no_width)) + 1; - width[4] = CU_MAX(strlen(_("#Tests")), CU_number_width(pRegistry->uiNumberOfTests) + 1) + 1; - width[5] = CU_MAX(strlen(_("Active?")), CU_MAX(f_yes_width, f_no_width)) + 1; + width[2] = display_width(max_size_t(strlen(_("Init?")), max_size_t(f_yes_width, f_no_width)) + 1); + width[3] = display_width(max_size_t(strlen(_("Cleanup?")), max_size_t(f_yes_width, f_no_width)) + 1); + width[4] = display_width(CU_MAX(strlen(_("#Tests")), CU_number_width(pRegistry->uiNumberOfTests) + 1) + 1); + width[5] = display_width(max_size_t(strlen(_("Active?")), max_size_t(f_yes_width, f_no_width)) + 1); } fprintf(stdout, "\n%s", _("--------------------- Registered Suites -----------------------------")); @@ -533,7 +575,7 @@ static void list_tests(CU_pSuite pSuite) { CU_pTest pCurTest = NULL; unsigned int uiCount; - static size_t width[3]; + static int width[3]; assert(NULL != pSuite); assert(NULL != pSuite->pName); @@ -548,10 +590,10 @@ static void list_tests(CU_pSuite pSuite) assert(NULL != pSuite->pTest); /* only number of tests can change between calls */ - width[0] = CU_number_width(pSuite->uiNumberOfTests) + 1; + width[0] = display_width(CU_number_width(pSuite->uiNumberOfTests) + 1); if (0 == width[1]) { width[1] = 34; - width[2] = CU_MAX(strlen(_("Active?")), CU_MAX(f_yes_width, f_no_width)) + 1; + width[2] = display_width(max_size_t(strlen(_("Active?")), max_size_t(f_yes_width, f_no_width)) + 1); } fprintf(stdout, "\n%s", diff --git a/CUnit/Sources/Framework/MyMem.c b/CUnit/Sources/Framework/MyMem.c index bebdd11..e72286a 100644 --- a/CUnit/Sources/Framework/MyMem.c +++ b/CUnit/Sources/Framework/MyMem.c @@ -360,7 +360,7 @@ void CU_dump_memory_usage(const char* szFilename) pTempEvent = pTempNode->pFirstEvent; while (NULL != pTempEvent) { fprintf(pFile, "\n "); - fprintf(pFile, "\n %u ", pTempEvent->Size); + fprintf(pFile, "\n %zu ", pTempEvent->Size); fprintf(pFile, "\n %s ", pTempEvent->AllocFilename); fprintf(pFile, "\n %u ", pTempEvent->AllocLine); fprintf(pFile, "\n %s ", pTempEvent->DeallocFilename); diff --git a/CUnit/Sources/Framework/TestDB.c b/CUnit/Sources/Framework/TestDB.c index 1fbe9a7..feec5cd 100644 --- a/CUnit/Sources/Framework/TestDB.c +++ b/CUnit/Sources/Framework/TestDB.c @@ -1405,16 +1405,6 @@ static void test_get_suite_functions(void) CU_pSuite pSuite3 = NULL; CU_pSuite pSuite4 = NULL; CU_pSuite pSuite5 = NULL; - CU_pTest pTest1 = NULL; - CU_pTest pTest2 = NULL; - CU_pTest pTest3 = NULL; - CU_pTest pTest4 = NULL; - CU_pTest pTest5 = NULL; - CU_pTest pTest6 = NULL; - CU_pTest pTest7 = NULL; - CU_pTest pTest8 = NULL; - CU_pTest pTest9 = NULL; - CU_pTest pTest10 = NULL; /* error condition - registry not initialized */ CU_cleanup_registry(); @@ -1438,19 +1428,19 @@ static void test_get_suite_functions(void) /* register some suites and tests */ CU_initialize_registry(); pSuite1 = CU_add_suite("suite1", NULL, NULL); - pTest1 = CU_add_test(pSuite1, "test1", test_succeed); - pTest2 = CU_add_test(pSuite1, "test2", test_fail); - pTest3 = CU_add_test(pSuite1, "test1", test_succeed); /* duplicate test name */ - pTest4 = CU_add_test(pSuite1, "test4", test_fail); - pTest5 = CU_add_test(pSuite1, "test1", test_succeed); /* duplicate test name */ + CU_add_test(pSuite1, "test1", test_succeed); + CU_add_test(pSuite1, "test2", test_fail); + CU_add_test(pSuite1, "test1", test_succeed); /* duplicate test name */ + CU_add_test(pSuite1, "test4", test_fail); + CU_add_test(pSuite1, "test1", test_succeed); /* duplicate test name */ pSuite2 = CU_add_suite("suite2", suite_fail, NULL); - pTest6 = CU_add_test(pSuite2, "test6", test_succeed); - pTest7 = CU_add_test(pSuite2, "test7", test_succeed); + CU_add_test(pSuite2, "test6", test_succeed); + CU_add_test(pSuite2, "test7", test_succeed); pSuite3 = CU_add_suite("suite1", NULL, NULL); /* duplicate suite name */ - pTest8 = CU_add_test(pSuite3, "test8", test_fail); - pTest9 = CU_add_test(pSuite3, "test9", test_succeed); + CU_add_test(pSuite3, "test8", test_fail); + CU_add_test(pSuite3, "test9", test_succeed); pSuite4 = CU_add_suite("suite4", NULL, suite_fail); - pTest10 = CU_add_test(pSuite4, "test10", test_succeed); + CU_add_test(pSuite4, "test10", test_succeed); /* error condition - invalid parameters */ diff --git a/CUnit/Sources/Framework/TestRun.c b/CUnit/Sources/Framework/TestRun.c index 9a67783..d5e4248 100644 --- a/CUnit/Sources/Framework/TestRun.c +++ b/CUnit/Sources/Framework/TestRun.c @@ -74,6 +74,10 @@ @{ */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include #include @@ -299,7 +303,7 @@ static void cu_capture_stop(int dump){ } cu_capture_cleanup_files(); } -#else +#elif defined(HAVE_UNISTD_H) && defined(HAVE_FCNTL_H) && defined(HAVE_SYS_STAT_H) && defined(HAVE_CLOSE) && defined(HAVE_DUP) && defined(HAVE_DUP2) && defined(HAVE_FILENO) && defined(HAVE_MKSTEMP) && defined(HAVE_UNLINK) # include # include # include @@ -425,6 +429,14 @@ static void cu_capture_stop(int dump){ } cu_capture_cleanup_files(); } +#else +static int cu_capture_start(void){ + return -1; +} + +static void cu_capture_stop(int dump){ + (void)dump; +} #endif /* CU_PLATFORM_WIN32 */ /*================================================================= * Private function forward declarations @@ -1638,9 +1650,9 @@ static CU_ErrorCode run_single_test(CU_pTest pTest, CU_pRunSummary pRunSummary) /* keep track of the last failure BEFORE running the test */ volatile CU_pFailureRecord pLastFailure = f_last_failure; jmp_buf buf; - CU_ErrorCode result = CUE_SUCCESS; - int capture_enabled = 0; - int test_failed = 0; + volatile CU_ErrorCode result = CUE_SUCCESS; + volatile int capture_enabled = 0; + volatile int test_failed = 0; assert(NULL != f_pCurSuite); assert(CU_FALSE != f_pCurSuite->fActive); @@ -2169,7 +2181,6 @@ static void test_message_handlers(void) CU_pTest pTest1 = NULL; CU_pTest pTest2 = NULL; CU_pTest pTest3 = NULL; - CU_pTest pTest4 = NULL; CU_pTest pTest5 = NULL; CU_pTest pTest6 = NULL; CU_pTest pTest7 = NULL; @@ -2194,7 +2205,7 @@ static void test_message_handlers(void) pTest2 = CU_add_test(pSuite1, "test2", test_fail); pTest3 = CU_add_test(pSuite1, "test3", test_succeed); pSuite2 = CU_add_suite("suite2", suite_fail, NULL); - pTest4 = CU_add_test(pSuite2, "test4", test_succeed); + CU_add_test(pSuite2, "test4", test_succeed); pSuite3 = CU_add_suite("suite3", suite_succeed, suite_fail); pTest5 = CU_add_test(pSuite3, "test5", test_fail); pTest6 = CU_add_test(pSuite3, "test6", test_fail); @@ -3087,12 +3098,8 @@ static void test_CU_run_suite(void) CU_pTest pTest3 = NULL; CU_pTest pTest4 = NULL; CU_pTest pTest5 = NULL; - CU_pTest pTest6 = NULL; - CU_pTest pTest7 = NULL; CU_pTest pTest8 = NULL; CU_pTest pTest9 = NULL; - CU_pTest pTest10 = NULL; - CU_pTest pTest11 = NULL; /* error - NULL suite (CUEA_IGNORE) */ CU_set_error_action(CUEA_IGNORE); @@ -3123,16 +3130,16 @@ static void test_CU_run_suite(void) pTest4 = CU_add_test(pSuite1, "test4", test_fail); pTest5 = CU_add_test(pSuite1, "test5", test_succeed); pSuite2 = CU_add_suite("suite1", suite_fail, NULL); /* duplicate suite name OK */ - pTest6 = CU_add_test(pSuite2, "test6", test_succeed); - pTest7 = CU_add_test(pSuite2, "test7", test_succeed); + CU_add_test(pSuite2, "test6", test_succeed); + CU_add_test(pSuite2, "test7", test_succeed); pSuite3 = CU_add_suite("suite3", NULL, suite_fail); pTest8 = CU_add_test(pSuite3, "test8", test_fail); pTest9 = CU_add_test(pSuite3, "test8", test_succeed); /* duplicate test name OK */ pSuite4 = CU_add_suite("suite4", NULL, NULL); pSuite5 = CU_add_suite_with_setup_and_teardown("suite5", NULL, NULL, suite_setup, suite_teardown); - pTest10 = CU_add_test(pSuite5, "test10", test_succeed_if_setup); + CU_add_test(pSuite5, "test10", test_succeed_if_setup); pSuite6 = CU_add_suite("suite6", NULL, NULL); - pTest11 = CU_add_test(pSuite6, "test11", test_fail_if_not_setup); + CU_add_test(pSuite6, "test11", test_fail_if_not_setup); TEST_FATAL(6 == CU_get_registry()->uiNumberOfSuites); TEST_FATAL(11 == CU_get_registry()->uiNumberOfTests); diff --git a/CUnit/Sources/Test/Makefile.am b/CUnit/Sources/Test/Makefile.am index 3875492..91db1e5 100644 --- a/CUnit/Sources/Test/Makefile.am +++ b/CUnit/Sources/Test/Makefile.am @@ -1,13 +1,14 @@ ## Process this file with automake to produce Makefile.in if ENABLE_TEST -AM_CPPFLAGS = -I$(top_builddir)/CUnit/Headers -I$(top_srcdir)/CUnit/Headers +AM_CPPFLAGS = -I$(top_builddir)/CUnit/Headers -I$(top_srcdir)/CUnit/Headers \ + -DMEMTRACE -DCUNIT_BUILD_TESTS -DCUNIT_DO_NOT_DEFINE_UNLESS_BUILDING_TESTS testdir=${datadir}/@PACKAGE@/Test test_PROGRAMS = test_cunit +TESTS = $(test_PROGRAMS) test_cunit_SOURCES = test_cunit.c test_cunit.h test_cunit_LDADD = ../libcunit_test.a test_cunit_LDFLAGS = -L.. -INCLUDES = -DMEMTRACE -DCUNIT_BUILD_TESTS -DCUNIT_DO_NOT_DEFINE_UNLESS_BUILDING_TESTS endif diff --git a/CUnit/Sources/Test/test_cunit.c b/CUnit/Sources/Test/test_cunit.c index c6431cc..57455db 100644 --- a/CUnit/Sources/Test/test_cunit.c +++ b/CUnit/Sources/Test/test_cunit.c @@ -71,7 +71,7 @@ int main() test_cunit_report_results(); CU_cleanup_registry(); - return 0; + return (0 == f_nFailures) ? 0 : 1; } void test_cunit_start_tests(const char* strName) diff --git a/Examples/wxWidgetsTest/Makefile.am b/Examples/wxWidgetsTest/Makefile.am index cea91c3..47eb67d 100644 --- a/Examples/wxWidgetsTest/Makefile.am +++ b/Examples/wxWidgetsTest/Makefile.am @@ -10,7 +10,7 @@ example_PROGRAMS = ConsoleTest ConsoleTest_SOURCES = ConsoleTest.c ConsoleTest.h ConsoleTest_LDADD = -lcunit -lcunitexamples ConsoleTest_LDFLAGS = -L.. -lm -INCLUDES = -I.. +AM_CPPFLAGS = -I.. if ENABLE_CURSES ConsoleTest_LDADD += -l$(CURSES_LIB) diff --git a/Makefile.am b/Makefile.am index d9b6e40..270f81c 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,6 +1,7 @@ ## Process this file with automake to produce Makefile.in AUTOMAKE_OPTIONS = foreign +ACLOCAL_AMFLAGS = -I m4 COMPILE_DIRS = CUnit doc Man Share diff --git a/README.md b/README.md index 47cb2ff..b30f0ec 100644 --- a/README.md +++ b/README.md @@ -26,46 +26,6 @@ Note: the Windows-specific GUI interface is not yet written. It is still necessary to use either the automated, basic, or console interfaces to CUnit on Windows at this time. -## Important Note: Changes to CUnit Structure and Interface - -As of version 2.0, the interface functions used to interact with the CUnit -framework have changed. The original interface did not attempt to protect user -code from name clashes with public CUnit functions and variables. To minimize -such name clashes, all CUnit public functions are now prefixed with `CU_`. - -The old public names are deprecated as of version 2.0, but continue to be -supported with conversion macros. In order to compile older code using the -original interface, it is now necessary to compile with the macro -`-DUSE_DEPRECATED_CUNIT_NAMES` defined. If there are any problems compiling -older code, please file a bug report. - -In addition, the DTD and XSL files for output from the automated test -interface have been updated to support both old and new file structure. A List -or Run file generated using the version 1.1 library should be valid under the -version 2 DTDs and formatted correctly by the version 2 XSLs. This has not -been extended to the Memory-Dump DTD and XSL files; memory dumps created using -version 1.1 are ill-formed and incorrectly formatted using the version 2 DTD -and XSL files. - -Another exception to backward compatibility occurs if the user has directly -manipulated the global variables in version 1.1. The original CUnit structure -included global variables `error_number` and `g_pTestRegistry` which have been -removed from the global namespace as of version 2.0. Any user code which -directly accessed these variables will break. The variables must be retrieved -using the accessor functions `CU__get_error()` and `CU_get_registry()`. - -Similarly, user code retrieving the active test registry and directly -manipulating the `uiNumberOfFailures` or `pResult` members will break. These -members have been moved to the `TestRun.c` part of the framework and are no -longer available in the test registry as of version 2.0. - -Another change in version 2.0 is the update of the framework terminology. What -were termed "test groups" in the original structure are now called "suites", -and "test cases" are now just "tests". This change was made to bring CUnit -into conformance with standard testing terminology, and results in a change in -the name of some functions, for example `run_group_tests()` is now -`CU_run_suite()`. - ## Building the CUnit Library and Examples ### All Platforms @@ -94,6 +54,19 @@ What is installed: 5. The HTML users guide in the `doc` subdirectory of the installation path 6. Example and test programs in the `share` subdirectory of the install path +### Testing + +To build the internal CUnit self-tests from a git checkout, configure with `--enable-test` and then run `make check`: + +1. `./configure --enable-test --prefix ` +2. `make check` + +The internal test runner is built as `CUnit/Sources/Test/test_cunit`. You can also run it directly after `make` or `make check`: + +- `./CUnit/Sources/Test/test_cunit` + +`make check` works because the internal runner is wired into Automake's usual `TESTS` mechanism in `CUnit/Sources/Test/Makefile.am`, and the runner exits non-zero if any internal assertions fail. + ### Windows Jam support has been removed. A set of old VC6 project files is included which @@ -158,3 +131,44 @@ The release workflow publishes both a source tarball and the MSYS2 UCRT64 with Automake `make distcheck`, so it includes `configure` and the generated `Makefile.in` files. Building directly from a git checkout still requires `./bootstrap` before `./configure`. + +## Important Note: Changes to CUnit Structure and Interface + +As of version 2.0, the interface functions used to interact with the CUnit +framework have changed. The original interface did not attempt to protect user +code from name clashes with public CUnit functions and variables. To minimize +such name clashes, all CUnit public functions are now prefixed with `CU_`. + +The old public names are deprecated as of version 2.0, but continue to be +supported with conversion macros. In order to compile older code using the +original interface, it is now necessary to compile with the macro +`-DUSE_DEPRECATED_CUNIT_NAMES` defined. If there are any problems compiling +older code, please file a bug report. + +In addition, the DTD and XSL files for output from the automated test +interface have been updated to support both old and new file structure. A List +or Run file generated using the version 1.1 library should be valid under the +version 2 DTDs and formatted correctly by the version 2 XSLs. This has not +been extended to the Memory-Dump DTD and XSL files; memory dumps created using +version 1.1 are ill-formed and incorrectly formatted using the version 2 DTD +and XSL files. + +Another exception to backward compatibility occurs if the user has directly +manipulated the global variables in version 1.1. The original CUnit structure +included global variables `error_number` and `g_pTestRegistry` which have been +removed from the global namespace as of version 2.0. Any user code which +directly accessed these variables will break. The variables must be retrieved +using the accessor functions `CU__get_error()` and `CU_get_registry()`. + +Similarly, user code retrieving the active test registry and directly +manipulating the `uiNumberOfFailures` or `pResult` members will break. These +members have been moved to the `TestRun.c` part of the framework and are no +longer available in the test registry as of version 2.0. + +Another change in version 2.0 is the update of the framework terminology. What +were termed "test groups" in the original structure are now called "suites", +and "test cases" are now just "tests". This change was made to bring CUnit +into conformance with standard testing terminology, and results in a change in +the name of some functions, for example `run_group_tests()` is now +`CU_run_suite()`. + diff --git a/VERSION b/VERSION index 34e6b71..4562fa0 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.3-1 +2.3-2 diff --git a/configure.in b/configure.ac similarity index 96% rename from configure.in rename to configure.ac index 6b0a270..d452f80 100644 --- a/configure.in +++ b/configure.ac @@ -2,7 +2,9 @@ dnl Applied patch to handle AC_ARG_ENABLE targets (Patch 1250604) - Provided by m4_define([CUNIT_DIST_VERSION], m4_esyscmd_s([cat VERSION])) AC_INIT([CUnit], [CUNIT_DIST_VERSION]) -AM_INIT_AUTOMAKE([CUnit], [CUNIT_DIST_VERSION]) +AC_CONFIG_MACRO_DIRS([m4]) +AM_INIT_AUTOMAKE([foreign]) +AC_USE_SYSTEM_EXTENSIONS dnl Package version information PACKAGE=CUnit @@ -169,7 +171,7 @@ dnl Check for programs. AC_PROG_CC AC_PROG_INSTALL AC_PROG_MAKE_SET -AC_PROG_LIBTOOL +LT_INIT dnl Check for libraries AC_CHECK_LIB(c, main) @@ -209,17 +211,12 @@ AC_CHECK_FUNC(setvbuf, [], [echo setvbuf not found; exit 1]) AC_CHECK_FUNC(time, [], [echo time not found; exit 1]) AC_CHECK_FUNC(ctime, [], [echo ctime not found; exit 1]) +AC_CHECK_FUNCS([close dup dup2 fileno mkstemp unlink]) + dnl Check for header files. -AC_HEADER_STDC -AC_CHECK_HEADERS(assert.h) -AC_CHECK_HEADERS(ctype.h) -AC_CHECK_HEADERS(math.h) -AC_CHECK_HEADERS(file.h) -AC_CHECK_HEADERS(stdio.h) -AC_CHECK_HEADERS(stdlib.h) -AC_CHECK_HEADERS(string.h) - -AM_CONFIG_HEADER(config.h) +AC_CHECK_HEADERS([assert.h ctype.h errno.h fcntl.h math.h file.h stdio.h stdlib.h string.h sys/stat.h unistd.h]) + +AC_CONFIG_HEADERS([config.h]) dnl Check for typedefs, structures, and compiler characteristics. AC_C_CONST From cfc3db183ccc60e8adfc0f929c5c92fa46acb658 Mon Sep 17 00:00:00 2001 From: John Pye Date: Tue, 19 May 2026 11:15:44 +1000 Subject: [PATCH 2/4] update release version check --- .github/workflows/release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 63a78eb..a7c51da 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -66,8 +66,8 @@ jobs: exit 1 fi - if ! grep -Fq 'm4_esyscmd_s([cat VERSION])' configure.in; then - echo "configure.in does not read VERSION for AC_INIT" >&2 + if ! grep -Fq 'm4_esyscmd_s([cat VERSION])' configure.ac; then + echo "configure.ac does not read VERSION for AC_INIT" >&2 exit 1 fi From b8be35138761a83ecc782bcb9bd9cac14cdf54f1 Mon Sep 17 00:00:00 2001 From: John Pye Date: Tue, 19 May 2026 11:22:18 +1000 Subject: [PATCH 3/4] addressing distcleancheck and GHA Node 24 warnings --- .github/workflows/msys2-build.yml | 2 +- .github/workflows/release.yml | 20 ++++++++++---------- .github/workflows/ubuntu-build.yml | 4 ++-- CUnit/Sources/Test/Makefile.am | 1 + Examples/AutomatedTest/Makefile.am | 1 + 5 files changed, 15 insertions(+), 13 deletions(-) diff --git a/.github/workflows/msys2-build.yml b/.github/workflows/msys2-build.yml index cac6427..2750356 100644 --- a/.github/workflows/msys2-build.yml +++ b/.github/workflows/msys2-build.yml @@ -23,7 +23,7 @@ jobs: run: git config --global core.autocrlf input - name: Check out source - uses: actions/checkout@v4 + uses: actions/checkout@v5 - name: Set up MSYS2 uses: msys2/setup-msys2@v2 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a7c51da..653daa7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -27,7 +27,7 @@ jobs: steps: - name: Check out source - uses: actions/checkout@v4 + uses: actions/checkout@v5 - name: Verify tag matches VERSION id: verify @@ -84,7 +84,7 @@ jobs: steps: - name: Check out source - uses: actions/checkout@v4 + uses: actions/checkout@v5 - name: Install build dependencies run: | @@ -113,7 +113,7 @@ jobs: tar -tzf "${DIST_FILE}.tar.gz" | grep -Fx "${DIST_FILE}/Examples/ExampleTests.h" - name: Upload source dist - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v6 with: name: cunit-source-dist path: ${{ needs.verify-version.outputs.dist_file }}.tar.gz @@ -136,7 +136,7 @@ jobs: run: git config --global core.autocrlf input - name: Check out source - uses: actions/checkout@v4 + uses: actions/checkout@v5 - name: Set up MSYS2 uses: msys2/setup-msys2@v2 @@ -149,7 +149,7 @@ jobs: git - name: Download source dist for PKGBUILD - uses: actions/download-artifact@v4 + uses: actions/download-artifact@v5 with: name: cunit-source-dist path: packaging/msys2 @@ -159,7 +159,7 @@ jobs: run: MINGW_ARCH=ucrt64 makepkg-mingw -sCLf --noconfirm - name: Upload release assets - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v6 with: name: cunit-release-assets path: | @@ -180,7 +180,7 @@ jobs: run: dnf -y install gcc make diffutils findutils tar gzip - name: Download source dist - uses: actions/download-artifact@v4 + uses: actions/download-artifact@v5 with: name: cunit-source-dist path: . @@ -221,7 +221,7 @@ jobs: mingw-w64-ucrt-x86_64-pkgconf - name: Download release assets - uses: actions/download-artifact@v4 + uses: actions/download-artifact@v5 with: name: cunit-release-assets path: release-assets @@ -263,12 +263,12 @@ jobs: steps: - name: Check out source - uses: actions/checkout@v4 + uses: actions/checkout@v5 with: fetch-depth: 0 - name: Download release assets - uses: actions/download-artifact@v4 + uses: actions/download-artifact@v5 with: name: cunit-release-assets path: release-assets diff --git a/.github/workflows/ubuntu-build.yml b/.github/workflows/ubuntu-build.yml index ecc1cb6..4f2c09c 100644 --- a/.github/workflows/ubuntu-build.yml +++ b/.github/workflows/ubuntu-build.yml @@ -21,7 +21,7 @@ jobs: steps: - name: Check out source - uses: actions/checkout@v4 + uses: actions/checkout@v5 - name: Install build dependencies run: | @@ -57,7 +57,7 @@ jobs: steps: - name: Check out source - uses: actions/checkout@v4 + uses: actions/checkout@v5 - name: Install build dependencies run: | diff --git a/CUnit/Sources/Test/Makefile.am b/CUnit/Sources/Test/Makefile.am index 91db1e5..e074ab2 100644 --- a/CUnit/Sources/Test/Makefile.am +++ b/CUnit/Sources/Test/Makefile.am @@ -10,5 +10,6 @@ TESTS = $(test_PROGRAMS) test_cunit_SOURCES = test_cunit.c test_cunit.h test_cunit_LDADD = ../libcunit_test.a test_cunit_LDFLAGS = -L.. +DISTCLEANFILES = CUnit-Memory-Dump.xml endif diff --git a/Examples/AutomatedTest/Makefile.am b/Examples/AutomatedTest/Makefile.am index b969b32..c193508 100644 --- a/Examples/AutomatedTest/Makefile.am +++ b/Examples/AutomatedTest/Makefile.am @@ -17,6 +17,7 @@ AutomatedTest_LDADD += -l$(CURSES_LIB) endif example_DATA = README +DISTCLEANFILES = TestAutomated-Listing.xml TestAutomated-Results.xml CUnit-Memory-Dump.xml endif endif From bde4a93cbaa266d3def6fa7e20a445feb50c62c0 Mon Sep 17 00:00:00 2001 From: John Pye Date: Tue, 19 May 2026 11:27:47 +1000 Subject: [PATCH 4/4] update GHA download-artifact --- .github/workflows/release.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 653daa7..c8926cc 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -149,7 +149,7 @@ jobs: git - name: Download source dist for PKGBUILD - uses: actions/download-artifact@v5 + uses: actions/download-artifact@v7 with: name: cunit-source-dist path: packaging/msys2 @@ -180,7 +180,7 @@ jobs: run: dnf -y install gcc make diffutils findutils tar gzip - name: Download source dist - uses: actions/download-artifact@v5 + uses: actions/download-artifact@v7 with: name: cunit-source-dist path: . @@ -221,7 +221,7 @@ jobs: mingw-w64-ucrt-x86_64-pkgconf - name: Download release assets - uses: actions/download-artifact@v5 + uses: actions/download-artifact@v7 with: name: cunit-release-assets path: release-assets @@ -268,7 +268,7 @@ jobs: fetch-depth: 0 - name: Download release assets - uses: actions/download-artifact@v5 + uses: actions/download-artifact@v7 with: name: cunit-release-assets path: release-assets