rbb         2002/11/23 08:04:51

  Modified:    test     Makefile.in test_apr.h testall.c testrand.c
  Log:
  Migrate testrand to the new test suite.
  
  Revision  Changes    Path
  1.106     +2 -9      apr/test/Makefile.in
  
  Index: Makefile.in
  ===================================================================
  RCS file: /home/cvs/apr/test/Makefile.in,v
  retrieving revision 1.105
  retrieving revision 1.106
  diff -u -r1.105 -r1.106
  --- Makefile.in       22 Nov 2002 06:19:24 -0000      1.105
  +++ Makefile.in       23 Nov 2002 16:04:51 -0000      1.106
  @@ -28,7 +28,6 @@
        [EMAIL PROTECTED]@ \
        [EMAIL PROTECTED]@ \
        [EMAIL PROTECTED]@ \
  -     [EMAIL PROTECTED]@ \
        [EMAIL PROTECTED]@ \
        [EMAIL PROTECTED]@ \
        [EMAIL PROTECTED]@ \
  @@ -58,9 +57,6 @@
                fi \
        done
   
  [EMAIL PROTECTED]@: testfile.lo $(LOCAL_LIBS)
  -     $(LINK) testfile.lo $(LOCAL_LIBS) $(ALL_LIBS)
  -
   [EMAIL PROTECTED]@: testdir.lo $(LOCAL_LIBS)
        $(LINK) testdir.lo $(LOCAL_LIBS) $(ALL_LIBS)
   
  @@ -155,14 +151,11 @@
   [EMAIL PROTECTED]@: testdup.lo $(LOCAL_LIBS)
        $(LINK) testdup.lo $(LOCAL_LIBS) $(ALL_LIBS)
   
  [EMAIL PROTECTED]@: testrand.lo $(LOCAL_LIBS)
  -     $(LINK) testrand.lo $(LOCAL_LIBS) $(ALL_LIBS)
  -
   [EMAIL PROTECTED]@: testmutexscope.lo $(LOCAL_LIBS)
        $(LINK) testmutexscope.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 testfmt.lo 
testfile.lo testdir.lo testfileinfo.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 testfmt.lo 
testfile.lo testdir.lo testfileinfo.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 testfmt.lo 
testfile.lo testdir.lo testfileinfo.lo testrand.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 testfmt.lo 
testfile.lo testdir.lo testfileinfo.lo testrand.lo CuTest.lo $(LOCAL_LIBS) 
$(ALL_LIBS)
   
   
   # DO NOT REMOVE
  
  
  
  1.22      +1 -0      apr/test/test_apr.h
  
  Index: test_apr.h
  ===================================================================
  RCS file: /home/cvs/apr/test/test_apr.h,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- test_apr.h        22 Nov 2002 06:19:24 -0000      1.21
  +++ test_apr.h        23 Nov 2002 16:04:51 -0000      1.22
  @@ -79,6 +79,7 @@
   CuSuite *testfile(void);
   CuSuite *testdir(void);
   CuSuite *testfileinfo(void);
  +CuSuite *testrand(void);
   
   
   
  
  
  
  1.17      +1 -0      apr/test/testall.c
  
  Index: testall.c
  ===================================================================
  RCS file: /home/cvs/apr/test/testall.c,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- testall.c 22 Nov 2002 06:19:24 -0000      1.16
  +++ testall.c 23 Nov 2002 16:04:51 -0000      1.17
  @@ -78,6 +78,7 @@
       testfile,
       testdir,
       testfileinfo,
  +    testrand,
       NULL
   };
   
  
  
  
  1.4       +25 -24    apr/test/testrand.c
  
  Index: testrand.c
  ===================================================================
  RCS file: /home/cvs/apr/test/testrand.c,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- testrand.c        21 Jun 2002 16:36:24 -0000      1.3
  +++ testrand.c        23 Nov 2002 16:04:51 -0000      1.4
  @@ -58,38 +58,39 @@
   #include <stdlib.h>
   #include "test_apr.h"
   
  -#if !APR_HAS_RANDOM
  -#error Random support is not available.  Go punt.
  -#endif
  -
  -int main(void)
  +static void rand_exists(CuTest *tc)
   {
  +#if !APR_HAS_RANDOM
  +    CuNotImpl(tc, "apr_generate_random_bytes");
  +#else
       apr_pool_t *p;
       apr_status_t rv;
       unsigned char c[2048];
       int i;
   
  -    apr_initialize();
  -
  -    printf("Testing apr_generate_random_bytes()\n===================\n\n");
  -
  -    if (apr_pool_create(&p, NULL) != APR_SUCCESS) {
  -        exit(-1);
  -    }
  -
  +    /* There must be a better way to test random-ness, but I don't know
  +     * what it is right now.
  +     */
       for (i = 1; i <= 8; i++) {
  -        printf("%-5d %-55s", i * 255, "bytes");
           rv = apr_generate_random_bytes(c, i * 255);
  -        if (rv != APR_SUCCESS) {
  -            char msgbuf[120];
  -
  -            printf("Failed: %d %s\n", rv, apr_strerror(rv, msgbuf, sizeof 
msgbuf));
  -        }
  -        else {
  -            printf("OK\n");
  -        }
  +        CuAssertIntEquals(tc, APR_SUCCESS, rv);
       }
  -
  -    return 0;
  +#endif
   }    
  +
  +CuSuite *testrand(void)
  +{
  +    CuSuite *suite = CuSuiteNew("Test Random");
  +
  +    SUITE_ADD_TEST(suite, rand_exists);
  +
  +    return suite;
  +}
  +
  +#ifdef SINGLE_PROG
  +CuSuite *getsuite(void)
  +{
  +    return testrand();
  +}
  +#endif
   
  
  
  

Reply via email to