apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r..@apache.org
Subject cvs commit: apr/test CuTest.c CuTest.h testall.c testapr.c Makefile.in test_apr.h teststr.c testtime.c
Date Sun, 15 Sep 2002 22:51:28 GMT
rbb         2002/09/15 15:51:28

  Modified:    .        CHANGES
               test     Makefile.in test_apr.h teststr.c testtime.c
  Added:       test     CuTest.c CuTest.h testall.c testapr.c
  Log:
  Begin to migrate the APR test suite to the CuTest framework.  This
  basically moves testtime and teststr to a single binary, testall.  The
  testall binary will run all of the tests that it knows about, and print
  the results.  A document will be added later today that describes how to
  write tests, and how the test suite works.  This is just an initial port
  for these test programs.  There have been no new tests added.
  
  Revision  Changes    Path
  1.335     +6 -0      apr/CHANGES
  
  Index: CHANGES
  ===================================================================
  RCS file: /home/cvs/apr/CHANGES,v
  retrieving revision 1.334
  retrieving revision 1.335
  diff -u -r1.334 -r1.335
  --- CHANGES	13 Sep 2002 15:43:30 -0000	1.334
  +++ CHANGES	15 Sep 2002 22:51:28 -0000	1.335
  @@ -1,5 +1,11 @@
   Changes with APR 0.9.2
   
  +  *) Begin to rehash the test suite.  There is now a new test program called
  +     testall.  This program currently runs testtime and teststr with the
  +     CuTest framework.  The stand-alone programs for testtime and teststr
  +     can be built, but only if a special flag is specified when building.
  +     [Ryan Bloom]
  +
     *) Fix a broken check for a failure to read from the random device file.
        PR 12615  [tenthumbs@cybernex.net]
   
  
  
  
  1.91      +12 -5     apr/test/Makefile.in
  
  Index: Makefile.in
  ===================================================================
  RCS file: /home/cvs/apr/test/Makefile.in,v
  retrieving revision 1.90
  retrieving revision 1.91
  diff -u -r1.90 -r1.91
  --- Makefile.in	5 Sep 2002 05:25:04 -0000	1.90
  +++ Makefile.in	15 Sep 2002 22:51:28 -0000	1.91
  @@ -44,7 +44,8 @@
   	testatomic@EXEEXT@ \
   	testpools@EXEEXT@ \
   	testmutexscope@EXEEXT@ \
  -	testtable@EXEEXT@
  +	testtable@EXEEXT@ \
  +	testall@EXEEXT@
   
   
   TARGETS = $(PROGRAMS) $(NONPORTABLE)
  @@ -59,6 +60,8 @@
   INCDIR=../include
   INCLUDES=-I$(INCDIR)
   
  +CFLAGS=$(MY_CFLAGS)
  +
   all: $(PROGRAMS) $(NONPORTABLE)
   
   check: $(PROGRAMS) $(NONPORTABLE)
  @@ -134,8 +137,8 @@
   sendfile@EXEEXT@: sendfile.lo $(LOCAL_LIBS)
   	$(LINK) sendfile.lo $(LOCAL_LIBS) $(ALL_LIBS)
   
  -testtime@EXEEXT@: testtime.lo $(LOCAL_LIBS)
  -	$(LINK) testtime.lo $(LOCAL_LIBS) $(ALL_LIBS)
  +testtime@EXEEXT@: testtime.lo CuTest.lo testapr.lo $(LOCAL_LIBS)
  +	$(LINK) testtime.lo CuTest.lo testapr.lo $(LOCAL_LIBS) $(ALL_LIBS)
   
   testmmap@EXEEXT@: testmmap.lo $(LOCAL_LIBS)
   	$(LINK) testmmap.lo $(LOCAL_LIBS) $(ALL_LIBS)
  @@ -164,8 +167,8 @@
   testhash@EXEEXT@: testhash.lo $(LOCAL_LIBS)
   	$(LINK) testhash.lo $(LOCAL_LIBS) $(ALL_LIBS)
   
  -teststr@EXEEXT@: teststr.lo $(LOCAL_LIBS)
  -	$(LINK) teststr.lo $(LOCAL_LIBS) $(ALL_LIBS)
  +teststr@EXEEXT@: teststr.lo CuTest.lo testapr.lo $(LOCAL_LIBS)
  +	$(LINK) teststr.lo CuTest.lo testapr.lo $(LOCAL_LIBS) $(ALL_LIBS)
   
   testsockets@EXEEXT@: testsockets.lo $(LOCAL_LIBS)
   	$(LINK) testsockets.lo $(LOCAL_LIBS) $(ALL_LIBS)
  @@ -205,5 +208,9 @@
   
   testtable@EXEEXT@: testtable.lo $(LOCAL_LIBS)
   	$(LINK) testtable.lo $(LOCAL_LIBS) $(ALL_LIBS)
  +
  +testall: testall.lo testtime.lo teststr.lo CuTest.lo $(LOCAL_LIBS)
  +	$(LINK) testall.lo testtime.lo teststr.lo CuTest.lo $(LOCAL_LIBS) $(ALL_LIBS)
  +
   
   # DO NOT REMOVE
  
  
  
  1.9       +13 -0     apr/test/test_apr.h
  
  Index: test_apr.h
  ===================================================================
  RCS file: /home/cvs/apr/test/test_apr.h,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- test_apr.h	13 Mar 2002 20:39:27 -0000	1.8
  +++ test_apr.h	15 Sep 2002 22:51:28 -0000	1.9
  @@ -66,8 +66,21 @@
   #ifndef APR_TEST_INCLUDES
   #define APR_TEST_INCLUDES
   
  +#include "CuTest.h"
  +#include "apr_pools.h"
  +
  +extern apr_pool_t *p;
  +
  +CuSuite *getsuite(void);
  +
  +CuSuite *teststr(void);
  +CuSuite *testtime(void);
  +
  +
  +
   #include "apr_strings.h"
   #include "apr_time.h"
  +
   
   #define TEST_EQ(str, func, value, good, bad) \
       printf("%-60s", str); \
  
  
  
  1.8       +48 -40    apr/test/teststr.c
  
  Index: teststr.c
  ===================================================================
  RCS file: /home/cvs/apr/test/teststr.c,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- teststr.c	27 Aug 2002 00:15:51 -0000	1.7
  +++ teststr.c	15 Sep 2002 22:51:28 -0000	1.8
  @@ -52,6 +52,8 @@
    * <http://www.apache.org/>.
    */
   
  +#include "test_apr.h"
  +
   #include <assert.h>
   #include <stdlib.h>
   #include <stdio.h>
  @@ -60,13 +62,17 @@
   #include "apr_general.h"
   #include "apr_strings.h"
   
  -static void test_strtok(apr_pool_t *p)
  +/* I haven't bothered to check for APR_ENOTIMPL here, AFAIK, all string
  + * functions exist on all platforms.
  + */
  +
  +static void test_strtok(CuTest *tc)
   {
       struct {
           char *input;
           char *sep;
       }
  -    tc[] = {
  +    cases[] = {
           {
               "",
               "Z"
  @@ -96,23 +102,24 @@
       };
       int curtc;
   
  -    for (curtc = 0; curtc < sizeof tc / sizeof tc[0]; curtc++) {
  +    for (curtc = 0; curtc < sizeof cases / sizeof cases[0]; curtc++) {
           char *retval1, *retval2;
           char *str1, *str2;
           char *state;
   
  -        str1 = apr_pstrdup(p, tc[curtc].input);
  -        str2 = apr_pstrdup(p, tc[curtc].input);
  +        str1 = apr_pstrdup(p, cases[curtc].input);
  +        str2 = apr_pstrdup(p, cases[curtc].input);
   
           do {
  -            retval1 = apr_strtok(str1, tc[curtc].sep, &state);
  -            retval2 = strtok(str2, tc[curtc].sep);
  +            retval1 = apr_strtok(str1, cases[curtc].sep, &state);
  +            retval2 = strtok(str2, cases[curtc].sep);
   
  -            if (!retval1)
  -                assert(!retval2);
  +            if (!retval1) {
  +                CuAssertTrue(tc, retval2 == NULL);
  +            }
               else {
  -                assert(retval2);
  -                assert(!strcmp(retval1, retval2));
  +                CuAssertTrue(tc, retval2 != NULL);
  +                CuAssertStrEquals(tc, retval2, retval1);
               }
   
               str1 = str2 = NULL; /* make sure we pass NULL on subsequent calls */
  @@ -120,7 +127,7 @@
       }
   }
   
  -static void test_snprintf(apr_pool_t *p)
  +static void snprintf_noNULL(CuTest *tc)
   {
       char buff[100];
       char *testing = apr_palloc(p, 10);
  @@ -134,43 +141,44 @@
       testing[5] = 'n';
       testing[6] = 'g';
       
  -    fprintf(stderr, "Testing precision  ........  ");
  +    /* If this test fails, we are going to seg fault. */
       apr_snprintf(buff, sizeof(buff), "%.*s", 7, testing);
  -    /* If this test fails, we are going to seg fault, so there is no reason
  -     * to print a failure message.  rbb
  -     */
  -    if (!strncmp(buff, testing, 7)) {
  -        fprintf(stderr, "OK\n");
  -    }
  +    CuAssertStrEquals(tc, buff, testing);
  +}
  +
  +static void snprintf_0NULL(CuTest *tc)
  +{
  +    int rv;
   
  -    fprintf(stderr, "Testing 0 length with NULL ..........  ");
       rv = apr_snprintf(NULL, 0, "%sBAR", "FOO");
  -    if (rv != 6) {
  -        fprintf(stderr, "FAILED\n");
  -    }
  -    fprintf(stderr, "OK\n");
  +    CuAssertIntEquals(tc, 6, rv);
  +}
  +
  +static void snprintf_0nonNULL(CuTest *tc)
  +{
  +    int rv;
  +    char *buff = "testing";
   
  -    fprintf(stderr, "Testing 0 length with non-NULL ..........  ");
       rv = apr_snprintf(buff, 0, "%sBAR", "FOO");
  -    if (rv != 6) {
  -        fprintf(stderr, "FAILED (return val)\n");
  -    }
  -    if (strcmp(buff, "FOOBAR") == 0) {
  -        fprintf(stderr, "FAILED (mangled buff)\n");
  -    }
  -    fprintf(stderr, "OK\n");
  +    CuAssertIntEquals(tc, 6, rv);
  +    CuAssert(tc, "buff unmangled", strcmp(buff, "FOOBAR") != 0);
   }
   
  -int main(int argc, const char * const argv[])
  +CuSuite *teststr(void)
   {
  -    apr_pool_t *p;
  +    CuSuite *suite = CuSuiteNew("Test Strings");
   
  -    apr_initialize();
  -    atexit(apr_terminate);
  -    apr_pool_create(&p, NULL);
  +    SUITE_ADD_TEST(suite, snprintf_0NULL);
  +    SUITE_ADD_TEST(suite, snprintf_0nonNULL);
  +    SUITE_ADD_TEST(suite, snprintf_noNULL);
  +    SUITE_ADD_TEST(suite, test_strtok);
   
  -    test_strtok(p);
  -    test_snprintf(p);
  +    return suite;
  +}
   
  -    return 0;
  +#ifdef SINGLE_PROG
  +CuSuite *getsuite(void)
  +{
  +    return teststr();
   }
  +#endif
  
  
  
  1.34      +219 -131  apr/test/testtime.c
  
  Index: testtime.c
  ===================================================================
  RCS file: /home/cvs/apr/test/testtime.c,v
  retrieving revision 1.33
  retrieving revision 1.34
  diff -u -r1.33 -r1.34
  --- testtime.c	9 Jun 2002 20:25:50 -0000	1.33
  +++ testtime.c	15 Sep 2002 22:51:28 -0000	1.34
  @@ -57,12 +57,21 @@
   #include "apr_general.h"
   #include "apr_lib.h"
   #include <errno.h>
  +#include <time.h>
   #include <stdio.h>
   #include "test_apr.h"
   
   #define STR_SIZE 45
   
  -static const char* print_time (apr_pool_t *pool, const apr_time_exp_t *xt)
  +/* The time value is used throughout the tests, so just make this a global.
  + * Also, we need a single value that we can test for the positive tests, so
  + * I chose the number below, it corresponds to:
  + *           2002-08-14 12:05:36.186711 -25200 [257 Sat].
  + * Which happens to be when I wrote the new tests.
  + */
  +apr_time_t now = 1032030336186711;
  +
  +static char* print_time (apr_pool_t *pool, const apr_time_exp_t *xt)
   {
       return apr_psprintf (pool,
                            "%04d-%02d-%02d %02d:%02d:%02d.%06d %+05d [%d %s]%s",
  @@ -79,145 +88,224 @@
                            (xt->tm_isdst ? " DST" : ""));
   }
   
  -int main(void)
  +
  +static void test_now(CuTest *tc)
  +{
  +    apr_time_t timediff;
  +    apr_time_t current;
  +    time_t os_now;
  +
  +    current = apr_time_now();
  +    time(&os_now);
  +
  +    timediff = os_now - (current / APR_USEC_PER_SEC); 
  +    /* Even though these are called so close together, there is the chance
  +     * that the time will be slightly off, so accept anything between -1 and
  +     * 1 second.
  +     */
  +    CuAssert(tc, "apr_time and OS time do not agree", 
  +             (timediff > -1) && (timediff < 1));
  +}
  +
  +static void test_gmtstr(CuTest *tc)
   {
  -    apr_time_t now;
  -    apr_time_exp_t xt, xt2;
  +    apr_status_t rv;
  +    apr_time_exp_t xt;
  +    time_t os_now;
  +
  +    rv = apr_time_exp_gmt(&xt, now);
  +    os_now = now / APR_USEC_PER_SEC;
  +    if (rv == APR_ENOTIMPL) {
  +        CuNotImpl(tc, "apr_time_exp_gmt");
  +    }
  +    CuAssertTrue(tc, rv == APR_SUCCESS);
  +    CuAssertStrEquals(tc, "2002-08-14 19:05:36.186711 +0000 [257 Sat]", 
  +                      print_time(p, &xt));
  +}
  +
  +static void test_localstr(CuTest *tc)
  +{
  +    apr_status_t rv;
  +    apr_time_exp_t xt;
  +    time_t os_now;
  +
  +    rv = apr_time_exp_lt(&xt, now);
  +    os_now = now / APR_USEC_PER_SEC;
  +    if (rv == APR_ENOTIMPL) {
  +        CuNotImpl(tc, "apr_time_exp_lt");
  +    }
  +    CuAssertTrue(tc, rv == APR_SUCCESS);
  +    CuAssertStrEquals(tc, "2002-08-14 12:05:36.186711 -25200 [257 Sat] DST",
  +                      print_time(p, &xt));
  +}
  +
  +static void test_exp_get_gmt(CuTest *tc)
  +{
  +    apr_status_t rv;
  +    apr_time_exp_t xt;
       apr_time_t imp;
  -    apr_pool_t *p;
  -    char *str, *str2;
  -    apr_size_t sz;
  -    apr_int32_t hr_off = -5 * 3600; /* 5 hours in seconds */
       apr_int64_t hr_off_64;
   
  -    apr_initialize();
  +    rv = apr_time_exp_gmt(&xt, now);
  +    CuAssertTrue(tc, rv == APR_SUCCESS);
  +    rv = apr_time_exp_get(&imp, &xt);
  +    if (rv == APR_ENOTIMPL) {
  +        CuNotImpl(tc, "apr_time_exp_get");
  +    }
  +    CuAssertTrue(tc, rv == APR_SUCCESS);
  +    hr_off_64 = (apr_int64_t) xt.tm_gmtoff * APR_USEC_PER_SEC;
  +    CuAssertTrue(tc, now + hr_off_64 == imp);
  +}
  +
  +static void test_exp_get_lt(CuTest *tc)
  +{
  +    apr_status_t rv;
  +    apr_time_exp_t xt;
  +    apr_time_t imp;
  +    apr_int64_t hr_off_64;
   
  -    printf("APR Time Functions\n==================\n\n");
  +    rv = apr_time_exp_lt(&xt, now);
  +    CuAssertTrue(tc, rv == APR_SUCCESS);
  +    rv = apr_time_exp_get(&imp, &xt);
  +    if (rv == APR_ENOTIMPL) {
  +        CuNotImpl(tc, "apr_time_exp_get");
  +    }
  +    CuAssertTrue(tc, rv == APR_SUCCESS);
  +    hr_off_64 = (apr_int64_t) xt.tm_gmtoff * APR_USEC_PER_SEC;
  +    CuAssertTrue(tc, now + hr_off_64 == imp);
  +}
   
  -    STD_TEST_NEQ("Creating a pool to use", apr_pool_create(&p, NULL))
  +static void test_imp_gmt(CuTest *tc)
  +{
  +    apr_status_t rv;
  +    apr_time_exp_t xt;
  +    apr_time_t imp;
   
  -    printf("%-60s", "    apr_time_now()");
  -    now = apr_time_now();
  -    printf("OK\n");
  +    rv = apr_time_exp_gmt(&xt, now);
  +    CuAssertTrue(tc, rv == APR_SUCCESS);
  +    rv = apr_implode_gmt(&imp, &xt);
  +    if (rv == APR_ENOTIMPL) {
  +        CuNotImpl(tc, "apr_implode_gmt");
  +    }
  +    CuAssertTrue(tc, rv == APR_SUCCESS);
  +    CuAssertTrue(tc, now == imp);
  +}
   
  -    STD_TEST_NEQ("    apr_time_exp_gmt", apr_time_exp_gmt(&xt, now))
  -    printf("        (%s)\n", print_time(p, &xt));
  +static void test_rfcstr(CuTest *tc)
  +{
  +    apr_status_t rv;
  +    char str[STR_SIZE];
   
  -    STD_TEST_NEQ("    apr_time_exp_lt", apr_time_exp_lt(&xt2, now))
  -    printf("        (%s)\n", print_time(p, &xt2));
  +    rv = apr_rfc822_date(str, now);
  +    if (rv == APR_ENOTIMPL) {
  +        CuNotImpl(tc, "apr_rfc822_date");
  +    }
  +    CuAssertTrue(tc, rv == APR_SUCCESS);
  +    CuAssertStrEquals(tc, "Sat, 14 Sep 2002 19:05:36 GMT", str);
  +}
   
  -    STD_TEST_NEQ("    apr_time_exp_get (GMT)", apr_time_exp_get(&imp, &xt))
  +static void test_ctime(CuTest *tc)
  +{
  +    apr_status_t rv;
  +    char str[STR_SIZE];
   
  -    printf("%-60s", "    checking GMT explode == implode");
  -    hr_off_64 = (apr_int64_t) xt.tm_gmtoff * APR_USEC_PER_SEC;
  -    if (imp != now + hr_off_64) {
  -        printf("mismatch\n"
  -                "\t\tapr_now()                %" APR_INT64_T_FMT "\n"
  -                "\t\tapr_implode() returned   %" APR_INT64_T_FMT "\n"
  -                "\t\terror delta was          %" APR_TIME_T_FMT "\n"
  -                "\t\tshould have been         %" APR_INT64_T_FMT "\n",
  -                now, imp, imp-now, hr_off_64);
  -       exit(-1);
  -    }
  -    printf("OK\n");
  -
  -    STD_TEST_NEQ("    apr_time_exp_get (localtime)",
  -                 apr_time_exp_get(&imp, &xt2))
  -
  -    printf("%-60s", "    checking localtime explode == implode");
  -    hr_off_64 = (apr_int64_t) xt2.tm_gmtoff * APR_USEC_PER_SEC;
  -    if (imp != now + hr_off_64) {
  -        printf("mismatch\n"
  -               "\t\tapr_now()                %" APR_INT64_T_FMT "\n"
  -               "\t\tapr_implode() returned   %" APR_INT64_T_FMT "\n"
  -               "\t\terror delta was          %" APR_TIME_T_FMT "\n"
  -               "\t\tshould have been         %" APR_INT64_T_FMT "\n",
  -               now, imp, imp-now, hr_off_64);
  -        exit(-1);
  -    }
  -    printf("OK\n");
  -
  -    STD_TEST_NEQ("    apr_implode_gmt (GMT)",
  -                 apr_implode_gmt(&imp, &xt))
  -
  -    printf("%-60s", "    checking GMT explode == GMT implode");
  -    if (imp != now) {
  -        printf("mismatch\n"
  -                "\t\tapr_now()                %" APR_INT64_T_FMT "\n"
  -                "\t\tapr_implode() returned   %" APR_INT64_T_FMT "\n"
  -                "\t\terror delta was          %" APR_TIME_T_FMT "\n"
  -                "\t\tshould have been         0\n",
  -                now, imp, imp-now);
  -        exit(-1);
  -    }
  -    printf("OK\n");
  -
  -    STD_TEST_NEQ("    apr_implode_gmt (localtime)",
  -                 apr_implode_gmt(&imp, &xt2))
  -
  -    printf("%-60s", "    checking localtime explode == GMT implode");
  -    if (imp != now) {
  -        printf("mismatch\n"
  -                "\t\tapr_now()                %" APR_INT64_T_FMT "\n"
  -                "\t\tapr_implode() returned   %" APR_INT64_T_FMT "\n"
  -                "\t\terror delta was          %" APR_TIME_T_FMT "\n"
  -                "\t\tshould have been         0\n",
  -                now, imp, imp-now);
  -        exit(-1);
  -    }
  -    printf("OK\n");
  -
  -    str = apr_pcalloc(p, sizeof(char) * STR_SIZE);
  -    str2 = apr_pcalloc(p, sizeof(char) * STR_SIZE);
  -    imp = 0;
  -
  -    if (!str || !str2) {
  -        printf("Failure!\n");
  -        fprintf(stderr,"Failed to allocate memory!\n");
  -        exit(-1);
  -    }
  -
  -    STD_TEST_NEQ("    apr_rfc822_date", apr_rfc822_date(str, now))
  -    printf("        ( %s )\n", str);
  -
  -    STD_TEST_NEQ("    apr_ctime (local time)", apr_ctime(str, now))
  -    printf("        ( %s )\n", str);
  -
  -    STD_TEST_NEQ("    apr_strftime (GMT) (24H day date month year)", 
  -                 apr_strftime(str, &sz, STR_SIZE, "%R %A %d %B %Y", &xt))
  -    printf("        ( %s )\n", str);
  -
  -    STD_TEST_NEQ("    apr_strftime (GMT) (HH:MM:SS)",
  -                 apr_strftime(str, &sz, STR_SIZE, "%T", &xt))
  -    printf ("        ( %s )\n", str);    
  -
  -    STD_TEST_NEQ("    apr_time_exp_tz (GMT -5 hours)",
  -                 apr_time_exp_tz(&xt2, now, hr_off))
  -
  -    STD_TEST_NEQ("    apr_strftime (offset) (HH:MM:SS)",
  -                 apr_strftime(str2, &sz, STR_SIZE, "%T", &xt2))
  -    printf("        ( %s )\n", str2);
  -
  -    TEST_EQ("    Comparing the GMT and offset time strings",
  -             strcmp(str, str2), 0, "OK", "Failed")
  -    printf("        ( %s != %s )\n", str, str2);
  -
  -    STD_TEST_NEQ("    apr_time_exp_get (offset)",
  -                 apr_time_exp_get(&imp, &xt2))
  -   
  -    hr_off_64 = (apr_int64_t) hr_off * APR_USEC_PER_SEC; /* microseconds */ 
  -    printf("%-60s","    Checking offset is correct");
  -    if (imp != now + hr_off_64){
  -        printf("Failed! :(\n");
  -        printf("Difference is %" APR_INT64_T_FMT " (should be %"
  -               APR_INT64_T_FMT")\n", imp - now, hr_off_64);
  -        exit(-1);
  -    }
  -    printf("OK\n");
  -    printf("        ( %" APR_TIME_T_FMT " - %" APR_TIME_T_FMT
  -           " = %" APR_INT64_T_FMT " )\n", imp, now, imp - now);
  -
  -    printf("\nTest Complete.\n");
  -    return 0;
  -}    
  +    rv = apr_ctime(str, now);
  +    if (rv == APR_ENOTIMPL) {
  +        CuNotImpl(tc, "apr_ctime");
  +    }
  +    CuAssertTrue(tc, rv == APR_SUCCESS);
  +    CuAssertStrEquals(tc, "Sat Sep 14 12:05:36 2002", str);
  +}
   
  +static void test_strftime(CuTest *tc)
  +{
  +    apr_status_t rv;
  +    apr_time_exp_t xt;
  +    char *str = NULL;
  +    apr_size_t sz;
  +
  +    rv = apr_time_exp_gmt(&xt, now);
  +    str = apr_palloc(p, STR_SIZE + 1);
  +    rv = apr_strftime(str, &sz, STR_SIZE, "%R %A %d %B %Y", &xt);
  +    if (rv == APR_ENOTIMPL) {
  +        CuNotImpl(tc, "apr_strftime");
  +    }
  +    CuAssertTrue(tc, rv == APR_SUCCESS);
  +    CuAssertStrEquals(tc, "19:05 Saturday 14 September 2002", str);
  +}
  +
  +static void test_strftimesmall(CuTest *tc)
  +{
  +    apr_status_t rv;
  +    apr_time_exp_t xt;
  +    char str[STR_SIZE];
  +    apr_size_t sz;
  +
  +    rv = apr_time_exp_gmt(&xt, now);
  +    rv = apr_strftime(str, &sz, STR_SIZE, "%T", &xt);
  +    if (rv == APR_ENOTIMPL) {
  +        CuNotImpl(tc, "apr_strftime");
  +    }
  +    CuAssertTrue(tc, rv == APR_SUCCESS);
  +    CuAssertStrEquals(tc, "19:05:36", str);
  +}
  +
  +static void test_exp_tz(CuTest *tc)
  +{
  +    apr_status_t rv;
  +    apr_time_exp_t xt;
  +    char str[STR_SIZE];
  +    apr_size_t sz;
  +    apr_int32_t hr_off = -5 * 3600; /* 5 hours in seconds */
  +
  +    rv = apr_time_exp_tz(&xt, now, hr_off);
  +    if (rv == APR_ENOTIMPL) {
  +        CuNotImpl(tc, "apr_time_exp_tz");
  +    }
  +    CuAssertTrue(tc, rv == APR_SUCCESS);
  +    CuAssertStrEquals(tc, "19:05:36", str);
  +}
  +
  +static void test_strftimeoffset(CuTest *tc)
  +{
  +    apr_status_t rv;
  +    apr_time_exp_t xt;
  +    char str[STR_SIZE];
  +    apr_size_t sz;
  +    apr_int32_t hr_off = -5 * 3600; /* 5 hours in seconds */
  +
  +    apr_time_exp_tz(&xt, now, hr_off);
  +    rv = apr_strftime(str, &sz, STR_SIZE, "%T", &xt);
  +    if (rv == APR_ENOTIMPL) {
  +        CuNotImpl(tc, "apr_strftime");
  +    }
  +    CuAssertTrue(tc, rv == APR_SUCCESS);
  +    CuAssertStrEquals(tc, "14:05:36", str);
  +}
  +
  +CuSuite *testtime(void)
  +{
  +    CuSuite *suite = CuSuiteNew("Test Time");
  +
  +    SUITE_ADD_TEST(suite, test_now);
  +    SUITE_ADD_TEST(suite, test_gmtstr);
  +    SUITE_ADD_TEST(suite, test_localstr);
  +    SUITE_ADD_TEST(suite, test_exp_get_gmt);
  +    SUITE_ADD_TEST(suite, test_exp_get_lt);
  +    SUITE_ADD_TEST(suite, test_imp_gmt);
  +    SUITE_ADD_TEST(suite, test_rfcstr);
  +    SUITE_ADD_TEST(suite, test_ctime);
  +    SUITE_ADD_TEST(suite, test_strftime);
  +    SUITE_ADD_TEST(suite, test_strftimesmall);
  +    SUITE_ADD_TEST(suite, test_exp_tz);
  +    SUITE_ADD_TEST(suite, test_strftimeoffset);
  +
  +    return suite;
  +}
  +
  +#ifdef SINGLE_PROG
  +CuSuite *getsuite(void)
  +{
  +    return testtime();
  +}
  +#endif
  
  
  
  1.1                  apr/test/CuTest.c
  
  Index: CuTest.c
  ===================================================================
  /*
   * Copyright (c) 2002-2006 Asim Jalis
   * 
   * This library is released under the zlib/libpng license as described at
   * 
   * http://www.opensource.org/licenses/zlib-license.html
   * 
   * Here is the statement of the license:
   * 
   * This software is provided 'as-is', without any express or implied warranty. 
   * In no event will the authors be held liable for any damages arising from 
   * the use of this software.
   * 
   * Permission is granted to anyone to use this software for any purpose, 
   * including commercial applications, and to alter it and redistribute it 
   * freely, subject to the following restrictions:
   * 
   * 1. The origin of this software must not be misrepresented; you must not 
   * claim that you wrote the original software. If you use this software in a 
   * product, an acknowledgment in the product documentation would be 
   * appreciated but is not required.
   * 
   * 2. Altered source versions must be plainly marked as such, and must not be
   * misrepresented as being the original software.
   * 
   * 3. This notice may not be removed or altered from any source distribution.
   */
  /*
   * This file has been modified from the original distribution.
   */
  
  #include <assert.h>
  #include <setjmp.h>
  #include <stdlib.h>
  #include <stdio.h>
  #include <string.h>
  
  #include "CuTest.h"
  
  static int verbose = 0;
  
  void CuInit(int argc, char *argv[])
  {
  	int c;
  	
  	c = getopt(argc, argv, "v");
  	if (c == 'v') {
  		verbose = 1;
  	}
  }
  
  /*-------------------------------------------------------------------------*
   * CuStr
   *-------------------------------------------------------------------------*/
  
  char* CuStrAlloc(int size)
  {
  	char* new = (char*) malloc( sizeof(char) * (size) );
  	return new;
  }
  
  char* CuStrCopy(char* old)
  {
  	int len = strlen(old);
  	char* new = CuStrAlloc(len + 1);
  	strcpy(new, old);
  	return new;
  }
  
  /*-------------------------------------------------------------------------*
   * CuString
   *-------------------------------------------------------------------------*/
  
  void CuStringInit(CuString* str)
  {
  	str->length = 0;
  	str->size = STRING_MAX;
  	str->buffer = (char*) malloc(sizeof(char) * str->size);
  	str->buffer[0] = '\0';
  }
  
  CuString* CuStringNew(void)
  {
  	CuString* str = (CuString*) malloc(sizeof(CuString));
  	str->length = 0;
  	str->size = STRING_MAX;
  	str->buffer = (char*) malloc(sizeof(char) * str->size);
  	str->buffer[0] = '\0';
  	return str;
  }
  
  void CuStringResize(CuString* str, int newSize)
  {
  	str->buffer = (char*) realloc(str->buffer, sizeof(char) * newSize);
  	str->size = newSize;
  }
  
  void CuStringAppend(CuString* str, char* text)
  {
  	int length = strlen(text);
  	if (str->length + length + 1 >= str->size)
  		CuStringResize(str, str->length + length + 1 + STRING_INC);
  	str->length += length;
  	strcat(str->buffer, text);
  }
  
  void CuStringAppendChar(CuString* str, char ch)
  {
  	char text[2];
  	text[0] = ch;
  	text[1] = '\0';
  	CuStringAppend(str, text);
  }
  
  void CuStringAppendFormat(CuString* str, char* format, ...)
  {
  	va_list argp;
  	char buf[HUGE_STRING_LEN];
  	va_start(argp, format);
  	vsprintf(buf, format, argp);
  	va_end(argp);
  	CuStringAppend(str, buf);
  }
  
  void CuStringRead(CuString *str, char *path)
  {
  	path = strdup(str->buffer);
  }
  
  /*-------------------------------------------------------------------------*
   * CuTest
   *-------------------------------------------------------------------------*/
  
  void CuTestInit(CuTest* t, char* name, TestFunction function)
  {
  	t->name = CuStrCopy(name);
  	t->notimpl = 0;
  	t->failed = 0;
  	t->ran = 0;
  	t->message = NULL;
  	t->function = function;
  	t->jumpBuf = NULL;
  }
  
  CuTest* CuTestNew(char* name, TestFunction function)
  {
  	CuTest* tc = CU_ALLOC(CuTest);
  	CuTestInit(tc, name, function);
  	return tc;
  }
  
  void CuNotImpl(CuTest* tc, char* message)
  {
  	CuString* newstr = CuStringNew();
          CuStringAppend(newstr, message);
          CuStringAppend(newstr, " not implemented on this platform");
  	tc->notimpl = 1;
  	tc->message = CuStrCopy(newstr->buffer);
  	if (tc->jumpBuf != 0) longjmp(*(tc->jumpBuf), 0);
  }
  
  void CuFail(CuTest* tc, char* message)
  {
  	tc->failed = 1;
  	tc->message = CuStrCopy(message);
  	if (tc->jumpBuf != 0) longjmp(*(tc->jumpBuf), 0);
  }
  
  void CuAssert(CuTest* tc, char* message, int condition)
  {
  	if (condition) return;
  	CuFail(tc, message);
  }
  
  void CuAssertTrue(CuTest* tc, int condition)
  {
  	if (condition) return;
  	CuFail(tc, "assert failed");
  }
  
  void CuAssertStrEquals(CuTest* tc, char* expected, char* actual)
  {
  	CuString* message;
  	if (strcmp(expected, actual) == 0) return;
  	message = CuStringNew();
  	CuStringAppend(message, "expected\n---->\n");
  	CuStringAppend(message, expected);
  	CuStringAppend(message, "\n<----\nbut saw\n---->\n");
  	CuStringAppend(message, actual);
  	CuStringAppend(message, "\n<----\n");
  	CuFail(tc, message->buffer);
  }
  
  void CuAssertIntEquals(CuTest* tc, int expected, int actual)
  {
  	char buf[STRING_MAX];
  	if (expected == actual) return;
  	sprintf(buf, "expected <%d> but was <%d>", expected, actual);
  	CuFail(tc, buf);
  }
  
  void CuAssertPtrEquals(CuTest* tc, void* expected, void* actual)
  {
  	char buf[STRING_MAX];
  	if (expected == actual) return;
  	sprintf(buf, "expected pointer <0x%X> but was <0x%X>", expected, actual);
  	CuFail(tc, buf);
  }
  
  void CuAssertPtrNotNull(CuTest* tc, void* pointer)
  {
  	char buf[STRING_MAX];
  	if (pointer != NULL ) return;
  	sprintf(buf, "null pointer unexpected", pointer);
  	CuFail(tc, buf);
  }
  
  void CuTestRun(CuTest* tc)
  {
  	jmp_buf buf;
  	tc->jumpBuf = &buf;
  	if (setjmp(buf) == 0)
  	{
  		tc->ran = 1;
  		(tc->function)(tc);
  	}
  	tc->jumpBuf = 0;
  }
  
  /*-------------------------------------------------------------------------*
   * CuSuite
   *-------------------------------------------------------------------------*/
  
  void CuSuiteInit(CuSuite* testSuite, char *name)
  {
  	testSuite->name = strdup(name);
  	testSuite->count = 0;
  	testSuite->failCount = 0;
  	testSuite->notimplCount = 0;
  }
  
  CuSuite* CuSuiteNew(char *name)
  {
  	CuSuite* testSuite = CU_ALLOC(CuSuite);
  	CuSuiteInit(testSuite, name);
  	return testSuite;
  }
  
  void CuSuiteAdd(CuSuite* testSuite, CuTest *testCase)
  {
  	assert(testSuite->count < MAX_TEST_CASES);
  	testSuite->list[testSuite->count] = testCase;
  	testSuite->count++;
  }
  
  void CuSuiteAddSuite(CuSuite* testSuite, CuSuite* testSuite2)
  {
  	int i;
  	for (i = 0 ; i < testSuite2->count ; ++i)
  	{
  		CuTest* testCase = testSuite2->list[i];
  		CuSuiteAdd(testSuite, testCase);
  	}
  }
  
  void CuSuiteRun(CuSuite* testSuite)
  {
  	int i;
  	for (i = 0 ; i < testSuite->count ; ++i)
  	{
  		CuTest* testCase = testSuite->list[i];
  		CuTestRun(testCase);
  		if (testCase->failed) { testSuite->failCount += 1; }
  		if (testCase->notimpl) { testSuite->notimplCount += 1; }
  	}
  }
  
  void CuSuiteSummary(CuSuite* testSuite, CuString* summary)
  {
  	int i;
  	CuStringAppendFormat(summary, "%s:\t", testSuite->name);
  	for (i = 0 ; i < testSuite->count ; ++i)
  	{
  		CuTest* testCase = testSuite->list[i];
  		CuStringAppend(summary, testCase->failed ? "F" : 
                                 testCase->notimpl ? "N": ".");
  	}
  	CuStringAppend(summary, "\n");
  }
  
  void CuSuiteOverView(CuSuite* testSuite, CuString* details)
  {
  	int i;
  	int failCount = 0;
  	int notImpleCount = 0;
  	int passCount = testSuite->count - testSuite->failCount;
  
  	CuStringAppendFormat(details, "%d %s run:  %d passed, %d failed, "
  			     "%d not implemented.\n",
  			     testSuite->count, 
  			     testSuite->count == 1 ? "test" : "tests",
     			     testSuite->count - testSuite->failCount - 
  				testSuite->notimplCount,
  			     testSuite->failCount, testSuite->notimplCount);
  }
  
  void CuSuiteDetails(CuSuite* testSuite, CuString* details)
  {
  	int i;
  	int failCount = 0;
  	int notImpleCount = 0;
  	int passCount = testSuite->count - testSuite->failCount;
  	char* testWord = passCount == 1 ? "test" : "tests";
  
  	if (testSuite->failCount != 0 && verbose)
  	{
  		CuStringAppendFormat(details, "Failed tests:\n");
  		for (i = 0 ; i < testSuite->count ; ++i)
  		{
  			CuTest* testCase = testSuite->list[i];
  			if (testCase->failed)
  			{
  				failCount++;
  				CuStringAppendFormat(details, "%d) %s: %s\n", 
  					failCount, testCase->name, testCase->message);
  			}
  		}
  	}
  	if (testSuite->notimplCount != 0 && verbose)
  	{
  		CuStringAppendFormat(details, "\nNot Implemented tests:\n");
  		for (i = 0 ; i < testSuite->count ; ++i)
  		{
  			CuTest* testCase = testSuite->list[i];
  			if (testCase->notimpl)
  			{
  			        failCount++;
  			        CuStringAppendFormat(details, "%d) %s: %s\n",
  			                failCount, testCase->name, testCase->message);
  			}
  		}
  	}
  }
  
  /*-------------------------------------------------------------------------*
   * CuSuiteList
   *-------------------------------------------------------------------------*/
  
  CuSuiteList* CuSuiteListNew(char *name)
  {
  	CuSuiteList* testSuite = CU_ALLOC(CuSuiteList);
  	testSuite->name = strdup(name);
  	testSuite->count = 0;
  	return testSuite;
  }
  
  void CuSuiteListAdd(CuSuiteList *suites, CuSuite *origsuite)
  {
  	assert(suites->count < MAX_TEST_CASES);
  	suites->list[suites->count] = origsuite;
  	suites->count++;
  }
  
  void CuSuiteListRun(CuSuiteList* testSuite)
  {
  	int i;
  	for (i = 0 ; i < testSuite->count ; ++i)
  	{
  		CuSuite* testCase = testSuite->list[i];
  		CuSuiteRun(testCase);
  	}
  }
  
  void CuSuiteListSummary(CuSuiteList* testSuite, CuString* summary)
  {
  	int i;
  	CuStringAppendFormat(summary, "%s:\n", testSuite->name);
  	for (i = 0 ; i < testSuite->count ; ++i)
  	{
  		CuSuite* testCase = testSuite->list[i];
  		CuString *str = CuStringNew();
  		CuSuiteSummary(testCase, str);
  		CuStringAppend(summary, "    ");
  		CuStringAppend(summary, str->buffer);
  	}
  	CuStringAppend(summary, "\n");
  }
  
  void CuSuiteListDetails(CuSuiteList* testSuite, CuString* details)
  {
  	int i;
  	int failCount = 0;
  	int notImplCount = 0;
  	int passCount = 0;
  	int count = 0;
  	char *testWord = passCount == 1 ? "test" : "tests";
  
  	for (i = 0 ; i < testSuite->count ; ++i)
  	{
  		failCount += testSuite->list[i]->failCount;
  		notImplCount += testSuite->list[i]->notimplCount;
                  count += testSuite->list[i]->count;
  	}
  	CuStringAppendFormat(details, "%d %s run:  %d passed, %d failed, "
  			     "%d not implemented.\n",
  			     count, 
  			     count == 1 ? "test" : "tests",
     			     count - failCount - notImplCount,
  			     failCount, notImplCount);
  
  	if (failCount != 0 && verbose)
  	{
  		for (i = 0 ; i < testSuite->count ; ++i)
  		{
  			CuString *str = CuStringNew();
  			CuSuite* testCase = testSuite->list[i];
  			if (testCase->failCount)
  			{
  				CuSuiteDetails(testCase, str);
  				CuStringAppend(details, str->buffer);
  			}
  		}
  	}
  	if (notImplCount != 0 && verbose)
  	{
  		CuStringAppendFormat(details, "\nNot Implemented tests:\n");
  		for (i = 0 ; i < testSuite->count ; ++i)
  		{
  			CuString *str = CuStringNew();
  			CuSuite* testCase = testSuite->list[i];
  			if (testCase->notimplCount)
  			{
  				CuSuiteDetails(testCase, str);
  				CuStringAppend(details, str->buffer);
  			}
  		}
  	} 
  }
  
  
  
  1.1                  apr/test/CuTest.h
  
  Index: CuTest.h
  ===================================================================
  /*
   * Copyright (c) 2002-2006 Asim Jalis
   *
   * This library is released under the zlib/libpng license as described at
   *
   * http://www.opensource.org/licenses/zlib-license.html
   *
   * Here is the statement of the license:
   *
   * This software is provided 'as-is', without any express or implied warranty.
   * In no event will the authors be held liable for any damages arising from
   * the use of this software.
   *
   * Permission is granted to anyone to use this software for any purpose,
   * including commercial applications, and to alter it and redistribute it
   * freely, subject to the following restrictions:
   *
   * 1. The origin of this software must not be misrepresented; you must not
   * claim that you wrote the original software. If you use this software in a
   * product, an acknowledgment in the product documentation would be
   * appreciated but is not required.
   *
   * 2. Altered source versions must be plainly marked as such, and must not be
   * misrepresented as being the original software.
   *
   * 3. This notice may not be removed or altered from any source distribution.
   */
  /*
   * This file has been modified from the original distribution.
   */
  
  #ifndef CU_TEST_H
  #define CU_TEST_H
  
  #include <setjmp.h>
  #include <stdarg.h>
  
  /* CuString */
  
  char* CuStrAlloc(int size);
  char* CuStrCopy(char* old);
  
  #define CU_ALLOC(TYPE)		((TYPE*) malloc(sizeof(TYPE)))
  
  #define HUGE_STRING_LEN	8192
  #define STRING_MAX		256
  #define STRING_INC		256
  
  typedef struct
  {
  	int length;
  	int size;
  	char* buffer;
  } CuString;
  
  void CuStringInit(CuString* str);
  CuString* CuStringNew(void);
  void CuStringRead(CuString* str, char* path);
  void CuStringAppend(CuString* str, char* text);
  void CuStringAppendChar(CuString* str, char ch);
  void CuStringAppendFormat(CuString* str, char* format, ...);
  void CuStringResize(CuString* str, int newSize);
  
  /* CuTest */
  
  typedef struct CuTest CuTest;
  
  typedef void (*TestFunction)(CuTest *);
  
  struct CuTest
  {
  	char* name;
  	TestFunction function;
          int notimpl;
  	int failed;
  	int ran;
  	char* message;
  	jmp_buf *jumpBuf;
  };
  
  void CuInit(int argc, char *argv[]);
  void CuTestInit(CuTest* t, char* name, TestFunction function);
  CuTest* CuTestNew(char* name, TestFunction function);
  void CuFail(CuTest* tc, char* message);
  void CuAssert(CuTest* tc, char* message, int condition);
  void CuAssertTrue(CuTest* tc, int condition);
  void CuAssertStrEquals(CuTest* tc, char* expected, char* actual);
  void CuAssertIntEquals(CuTest* tc, int expected, int actual);
  void CuAssertPtrEquals(CuTest* tc, void* expected, void* actual);
  void CuAssertPtrNotNull(CuTest* tc, void* pointer);
  void CuTestRun(CuTest* tc);
  
  /* CuSuite */
  
  #define MAX_TEST_CASES	1024	
  
  #define SUITE_ADD_TEST(SUITE,TEST)	CuSuiteAdd(SUITE, CuTestNew(#TEST, TEST))
  
  typedef struct
  {
  	char *name;
  	int count;
  	CuTest* list[MAX_TEST_CASES]; 
  	int failCount;
  	int notimplCount;
  
  } CuSuite;
  
  
  void CuSuiteInit(CuSuite* testSuite, char* name);
  CuSuite* CuSuiteNew(char* name);
  void CuSuiteAdd(CuSuite* testSuite, CuTest *testCase);
  void CuSuiteAddSuite(CuSuite* testSuite, CuSuite* testSuite2);
  void CuSuiteRun(CuSuite* testSuite);
  void CuSuiteSummary(CuSuite* testSuite, CuString* summary);
  void CuSuiteOverView(CuSuite* testSuite, CuString* details);
  void CuSuiteDetails(CuSuite* testSuite, CuString* details);
  
  typedef struct
  {
  	char *name;
  	int count;
  	CuSuite* list[MAX_TEST_CASES]; 
  } CuSuiteList;
  
  
  CuSuiteList* CuSuiteListNew(char* name);
  void CuSuiteListAdd(CuSuiteList* testSuite, CuSuite *testCase);
  void CuSuiteListRun(CuSuiteList* testSuite);
  void CuSuiteListSummary(CuSuiteList* testSuite, CuString* summary);
  void CuSuiteListDetails(CuSuiteList* testSuite, CuString* details);
  #endif /* CU_TEST_H */
  
  
  
  1.1                  apr/test/testall.c
  
  Index: testall.c
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2000-2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  #include "test_apr.h"
  
  #define NUM_TESTS 2
  
  apr_pool_t *p;
  
  typedef CuSuite *(testfunc)(void);
  
  testfunc *tests[NUM_TESTS] = {
      teststr,
      testtime
  };
  
  int main(int argc, char *argv[])
  {
      CuSuiteList *alltests = CuSuiteListNew("All APR Tests");
      CuString *output = CuStringNew();
      int i;
  
      apr_initialize();
      atexit(apr_terminate);
  
      CuInit(argc, argv);
  
      apr_pool_create(&p, NULL);
  
      for (i = 0; i < NUM_TESTS; i++) {
          CuSuiteListAdd(alltests, tests[i]());
      }
  
      CuSuiteListRun(alltests);
      CuSuiteListSummary(alltests, output);
      CuSuiteListDetails(alltests, output);
      printf("%s\n", output->buffer);
  
  }
  
  
  
  
  1.1                  apr/test/testapr.c
  
  Index: testapr.c
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2000-2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  #include "test_apr.h"
  
  apr_pool_t *p;
  
  int main(int argc, char *argv[])
  {
      CuSuite *suite;
      CuString *output = CuStringNew();
  
      apr_initialize();
      atexit(apr_terminate);
  
      CuInit(argc, argv);
  
      apr_pool_create(&p, NULL);
  
      suite = getsuite();
  
      CuSuiteRun(suite);
      CuSuiteSummary(suite, output);
      CuStringAppend(output, "\n");
      CuSuiteOverView(suite, output);
      printf("%s", output->buffer);
      CuStringInit(output);
      CuSuiteDetails(suite, output);
      if (strcmp(output->buffer, "")) {
          printf("%s\n", output->buffer);
      }
      return 0;
  }
  
  
  
  

Mime
View raw message