apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dr...@apache.org
Subject cvs commit: apr/test testmd5.c
Date Sun, 13 May 2001 10:53:01 GMT
dreid       01/05/13 03:53:01

  Modified:    test     testmd5.c
  Log:
  Another small update of a test program that I did yesterday afternoon.
  
  Revision  Changes    Path
  1.8       +34 -13    apr/test/testmd5.c
  
  Index: testmd5.c
  ===================================================================
  RCS file: /home/cvs/apr/test/testmd5.c,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- testmd5.c	2001/03/31 07:29:06	1.7
  +++ testmd5.c	2001/05/13 10:53:01	1.8
  @@ -95,31 +95,43 @@
       apr_status_t rv;
       apr_md5_ctx_t context;
       unsigned char hash[MD5_DIGESTSIZE];
  +    
  +    printf("Trying a translation...\n");
   
  -    rv = apr_md5_init(&context);
  -    assert(!rv);
  +    if ((rv = apr_md5_init(&context)) != APR_SUCCESS){
  +        printf("Failed to init APR's md5 routines!\n");
  +        exit(-1);
  +    }
   
       if (xlate) {
   #if APR_HAS_XLATE
  -        apr_md5_set_xlate(&context, xlate);
  +        if ((rv = apr_md5_set_xlate(&context, xlate)) != APR_SUCCESS){
  +            fprintf("Couldn't set the MD5 translation handle!\n");
  +            exit(-1);
  +        }
   #else
  -        fprintf(stderr,
  -                "A translation handle was unexpected.\n");
  +        printf("\tDidn't expect a translation handle! Not fatal.\n");
   #endif
       }
       
  -    rv = apr_md5_update(&context, buf, bufLen);
  -    assert(!rv);
  +    if ((rv = apr_md5_update(&context, buf, bufLen)) != APR_SUCCESS){
  +        printf("The call to apr_md5_update failed!\n");
  +        exit(-1);
  +    }
   
  -    rv = apr_md5_final(hash, &context);
  -    assert(!rv);
  +    if ((rv = apr_md5_final(hash, &context)) != APR_SUCCESS){
  +        printf("The call to apr_md5_final failed!\n");
  +        exit(-1);
  +    }
   
  +    printf("\t (MD5 hash : ");
       for (i = 0; i < MD5_DIGESTSIZE; i++) {
           printf("%02x",hash[i]);
       }
  -
  -    printf("\n");
  +    
  +    printf(")\n");
   
  +    printf("\tChecking hash against expected....................");
       if (memcmp(hash, digest, MD5_DIGESTSIZE)) {
           fprintf(stderr,
                   "The digest is not as expected!\n");
  @@ -131,6 +143,7 @@
                   "being in ASCII.\n");
   #endif
       }
  +    printf("OK\n");
   }
   
   int main(int argc, char **argv)
  @@ -159,8 +172,15 @@
       assert(!rv);
       atexit(closeapr);
   
  -    rv = apr_pool_create(&pool, NULL);
  +    printf("APR MD5 Test\n============\n\n");
  +    printf("Creating pool.............................................");
  +    if ((rv = apr_pool_create(&pool, NULL)) != APR_SUCCESS){
  +        printf("Failed.\n");
  +        exit(-1);
  +    }
  +    printf("OK\n");
   
  +
       if (src) {
   #if APR_HAS_XLATE
           rv = apr_xlate_open(&xlate, dst, src, pool);
  @@ -182,6 +202,7 @@
           try(testcases[cur].s, strlen(testcases[cur].s), xlate,
               testcases[cur].digest);
       }
  -    
  +
  +    printf("\nMD5 Test passed.\n");    
       return 0;
   }
  
  
  

Mime
View raw message