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 Makefile.in test_apr.h testall.c testpools.c
Date Tue, 22 Oct 2002 23:22:06 GMT
rbb         2002/10/22 16:22:06

  Modified:    test     Makefile.in test_apr.h testall.c testpools.c
  Log:
  Port testpools to the new test suite.
  
  Revision  Changes    Path
  1.97      +2 -2      apr/test/Makefile.in
  
  Index: Makefile.in
  ===================================================================
  RCS file: /home/cvs/apr/test/Makefile.in,v
  retrieving revision 1.96
  retrieving revision 1.97
  diff -u -r1.96 -r1.97
  --- Makefile.in	22 Oct 2002 18:10:26 -0000	1.96
  +++ Makefile.in	22 Oct 2002 23:22:06 -0000	1.97
  @@ -209,8 +209,8 @@
   testtable@EXEEXT@: testtable.lo $(LOCAL_LIBS)
   	$(LINK) testtable.lo $(LOCAL_LIBS) $(ALL_LIBS)
   
  -testall: testall.lo testtime.lo teststr.lo testvsn.lo testipsub.lo testmmap.lo testud.lo
testtable.lo testsleep.lo CuTest.lo $(LOCAL_LIBS)
  -	$(LINK) testall.lo testtime.lo teststr.lo testvsn.lo testipsub.lo testmmap.lo testud.lo
testtable.lo testsleep.lo CuTest.lo $(LOCAL_LIBS) $(ALL_LIBS)
  +testall: testall.lo testtime.lo teststr.lo testvsn.lo testipsub.lo testmmap.lo testud.lo
testtable.lo testsleep.lo testpools.lo CuTest.lo $(LOCAL_LIBS)
  +	$(LINK) testall.lo testtime.lo teststr.lo testvsn.lo testipsub.lo testmmap.lo testud.lo
testtable.lo testsleep.lo testpools.lo CuTest.lo $(LOCAL_LIBS) $(ALL_LIBS)
   
   
   # DO NOT REMOVE
  
  
  
  1.17      +1 -0      apr/test/test_apr.h
  
  Index: test_apr.h
  ===================================================================
  RCS file: /home/cvs/apr/test/test_apr.h,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- test_apr.h	22 Oct 2002 18:10:26 -0000	1.16
  +++ test_apr.h	22 Oct 2002 23:22:06 -0000	1.17
  @@ -74,6 +74,7 @@
   CuSuite *testud(void);
   CuSuite *testtable(void);
   CuSuite *testsleep(void);
  +CuSuite *testpool(void);
   
   
   
  
  
  
  1.9       +1 -0      apr/test/testall.c
  
  Index: testall.c
  ===================================================================
  RCS file: /home/cvs/apr/test/testall.c,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- testall.c	22 Oct 2002 18:10:26 -0000	1.8
  +++ testall.c	22 Oct 2002 23:22:06 -0000	1.9
  @@ -72,6 +72,7 @@
       testud,
       testtable,
       testsleep,
  +    testpool,
       NULL
   };
   
  
  
  
  1.4       +62 -62    apr/test/testpools.c
  
  Index: testpools.c
  ===================================================================
  RCS file: /home/cvs/apr/test/testpools.c,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- testpools.c	13 Mar 2002 20:39:27 -0000	1.3
  +++ testpools.c	22 Oct 2002 23:22:06 -0000	1.4
  @@ -65,90 +65,90 @@
   #endif
   #include "test_apr.h"
   
  -static void alloc_bytes(apr_pool_t *p, int bytes)
  +#define ALLOC_BYTES 1024
  +
  +apr_pool_t *pmain = NULL;
  +apr_pool_t *pchild = NULL;
  +
  +static void alloc_bytes(CuTest *tc)
   {
       int i;
       char *alloc;
       
  -    printf("apr_palloc for %d bytes\n", bytes);
  -    printf("%-60s", "    apr_palloc");
  -    alloc = apr_palloc(p, bytes);
  -    if (!alloc) {
  -        printf("Failed\n");
  -        exit(-1);
  -    }
  -    printf("OK\n");
  -    
  -    printf("%-60s", "    Checking entire allocation is writable");
  -    for (i=0;i<bytes;i++) {
  +    alloc = apr_palloc(pmain, ALLOC_BYTES);
  +    CuAssertPtrNotNull(tc, alloc);
  +
  +    for (i=0;i<ALLOC_BYTES;i++) {
           char *ptr = alloc + i;
           *ptr = 0xa;
       }
  -    printf("OK\n");
  +    /* This is just added to get the positive.  If this test fails, the
  +     * suite will seg fault.
  +     */
  +    CuAssertTrue(tc, 1);
   }
   
  -static void calloc_bytes(apr_pool_t *p, int bytes)
  +static void calloc_bytes(CuTest *tc)
   {
       int i;
       char *alloc;
       
  -    printf("apr_pcalloc for %d bytes\n", bytes);
  -    printf("%-60s", "    apr_pcalloc");
  -    alloc = apr_pcalloc(p, bytes);
  -    if (!alloc) {
  -        printf("Failed\n");
  -        exit(-1);
  -    }
  -    printf("OK\n");
  -    
  -    printf("%-60s", "    Checking entire allocation is set to 0");
  -    for (i=0;i<bytes;i++) {
  +    alloc = apr_pcalloc(pmain, ALLOC_BYTES);
  +    CuAssertPtrNotNull(tc, alloc);
  +
  +    for (i=0;i<ALLOC_BYTES;i++) {
           char *ptr = alloc + i;
  -        if (*ptr != 0x0) {
  -            printf("Error at byte %d (%d vs 0)\n", i, (*ptr));
  -            exit (-1);
  -        }
  +        CuAssertPtrEquals(tc, NULL, *ptr);
       }
  -    printf("OK\n");
   }
   
  +static void parent_pool(CuTest *tc)
  +{
  +    apr_status_t rv;
  +
  +    rv = apr_pool_create(&pmain, NULL);
  +    CuAssertIntEquals(tc, rv, APR_SUCCESS);
  +    CuAssertPtrNotNull(tc, pmain);
  +}
   
  -int main (int argc, char ** argv)
  +static void child_pool(CuTest *tc)
   {
  -    apr_pool_t *pmain, *pchild;
  -    
  -    apr_initialize();
  -    atexit(apr_terminate);
  +    apr_status_t rv;
  +
  +    rv = apr_pool_create(&pchild, pmain);
  +    CuAssertIntEquals(tc, rv, APR_SUCCESS);
  +    CuAssertPtrNotNull(tc, pchild);
  +}
   
  -    fprintf(stdout, "APR Pools Test\n==============\n\n");
  -    STD_TEST_NEQ("Creating a top level pool (no parent)", apr_pool_create(&pmain, NULL))
  +static void test_ancestor(CuTest *tc)
  +{
  +    CuAssertIntEquals(tc, 1, apr_pool_is_ancestor(pmain, pchild));
  +}
   
  -    STD_TEST_NEQ("Create a child pool from the top level one",
  -                 apr_pool_create(&pchild, pmain))
  +static void test_notancestor(CuTest *tc)
  +{
  +    CuAssertIntEquals(tc, 0, apr_pool_is_ancestor(pchild, pmain));
  +}
   
  -    printf("\nMain Pool\n");
  -    alloc_bytes(pmain, 1024);   
  -
  -    printf("\nChild Pool\n");
  -
  -    alloc_bytes(pchild, 1024);   
  -    calloc_bytes(pchild, 1024);   
  -    alloc_bytes(pchild, 4096);   
  -       
  -    printf("\nClearing the child pool\n\n");
  -    apr_pool_clear(pchild);
  -
  -    alloc_bytes(pchild, 2048);    
  -    calloc_bytes(pchild, 1024);   
  -    alloc_bytes(pchild, 4096);   
  -    
  -    printf("\nDestroying the child pool\n");
  -    apr_pool_destroy(pchild);
  -    printf("Destroying the main pool\n");
  -    apr_pool_destroy(pmain);
  -    
  -    printf("\nAll Tests completed - OK!\n");
  +CuSuite *testpool(void)
  +{
  +    CuSuite *suite = CuSuiteNew("Test Pools");
  +
  +    SUITE_ADD_TEST(suite, parent_pool);
  +    SUITE_ADD_TEST(suite, child_pool);
  +    SUITE_ADD_TEST(suite, test_ancestor);
  +    SUITE_ADD_TEST(suite, test_notancestor);
  +    SUITE_ADD_TEST(suite, alloc_bytes);
  +    SUITE_ADD_TEST(suite, calloc_bytes);
  +
  +    return suite;
  +}
   
  -    return (0);
  +#ifdef SINGLE_PROG
  +CuSuite *getsuite(void)
  +{
  +    return testpool();
   }
  +#endif
  +
   
  
  
  

Mime
View raw message