diff options
author | Richard Levitte <levitte@openssl.org> | 2002-11-28 18:54:30 +0000 |
---|---|---|
committer | Richard Levitte <levitte@openssl.org> | 2002-11-28 18:54:30 +0000 |
commit | 55f78baf32f213301a0e8d6c6e7f40bd3b9857b1 (patch) | |
tree | 1daf577fe941ef129c8657f231b060b786a03d4b /crypto/evp | |
parent | 6c359479d7755e6f228196e17fcdc98a05724d78 (diff) |
Have all tests use EXIT() to exit rather than exit(), since the latter doesn't
always give the expected result on some platforms.
Diffstat (limited to 'crypto/evp')
-rw-r--r-- | crypto/evp/evp_test.c | 43 |
1 files changed, 23 insertions, 20 deletions
diff --git a/crypto/evp/evp_test.c b/crypto/evp/evp_test.c index 90294ef686..447a431a04 100644 --- a/crypto/evp/evp_test.c +++ b/crypto/evp/evp_test.c @@ -49,6 +49,9 @@ #include <stdio.h> #include <string.h> + +#include "../e_os.h" + #include <openssl/evp.h> #include <openssl/engine.h> #include <openssl/conf.h> @@ -78,7 +81,7 @@ static int convert(unsigned char *s) if(!s[1]) { fprintf(stderr,"Odd number of hex digits!"); - exit(4); + EXIT(4); } sscanf((char *)s,"%2x",&n); *d=(unsigned char)n; @@ -142,7 +145,7 @@ static void test1(const EVP_CIPHER *c,const unsigned char *key,int kn, { fprintf(stderr,"Key length doesn't match, got %d expected %d\n",kn, c->key_len); - exit(5); + EXIT(5); } EVP_CIPHER_CTX_init(&ctx); if (encdec != 0) @@ -150,26 +153,26 @@ static void test1(const EVP_CIPHER *c,const unsigned char *key,int kn, if(!EVP_EncryptInit_ex(&ctx,c,NULL,key,iv)) { fprintf(stderr,"EncryptInit failed\n"); - exit(10); + EXIT(10); } EVP_CIPHER_CTX_set_padding(&ctx,0); if(!EVP_EncryptUpdate(&ctx,out,&outl,plaintext,pn)) { fprintf(stderr,"Encrypt failed\n"); - exit(6); + EXIT(6); } if(!EVP_EncryptFinal_ex(&ctx,out+outl,&outl2)) { fprintf(stderr,"EncryptFinal failed\n"); - exit(7); + EXIT(7); } if(outl+outl2 != cn) { fprintf(stderr,"Ciphertext length mismatch got %d expected %d\n", outl+outl2,cn); - exit(8); + EXIT(8); } if(memcmp(out,ciphertext,cn)) @@ -177,7 +180,7 @@ static void test1(const EVP_CIPHER *c,const unsigned char *key,int kn, fprintf(stderr,"Ciphertext mismatch\n"); hexdump(stderr,"Got",out,cn); hexdump(stderr,"Expected",ciphertext,cn); - exit(9); + EXIT(9); } } @@ -186,26 +189,26 @@ static void test1(const EVP_CIPHER *c,const unsigned char *key,int kn, if(!EVP_DecryptInit_ex(&ctx,c,NULL,key,iv)) { fprintf(stderr,"DecryptInit failed\n"); - exit(11); + EXIT(11); } EVP_CIPHER_CTX_set_padding(&ctx,0); if(!EVP_DecryptUpdate(&ctx,out,&outl,ciphertext,cn)) { fprintf(stderr,"Decrypt failed\n"); - exit(6); + EXIT(6); } if(!EVP_DecryptFinal_ex(&ctx,out+outl,&outl2)) { fprintf(stderr,"DecryptFinal failed\n"); - exit(7); + EXIT(7); } if(outl+outl2 != cn) { fprintf(stderr,"Plaintext length mismatch got %d expected %d\n", outl+outl2,cn); - exit(8); + EXIT(8); } if(memcmp(out,plaintext,cn)) @@ -213,7 +216,7 @@ static void test1(const EVP_CIPHER *c,const unsigned char *key,int kn, fprintf(stderr,"Plaintext mismatch\n"); hexdump(stderr,"Got",out,cn); hexdump(stderr,"Expected",plaintext,cn); - exit(9); + EXIT(9); } } @@ -260,24 +263,24 @@ static int test_digest(const char *digest, if(!EVP_DigestInit_ex(&ctx,d, NULL)) { fprintf(stderr,"DigestInit failed\n"); - exit(100); + EXIT(100); } if(!EVP_DigestUpdate(&ctx,plaintext,pn)) { fprintf(stderr,"DigestUpdate failed\n"); - exit(101); + EXIT(101); } if(!EVP_DigestFinal_ex(&ctx,md,&mdn)) { fprintf(stderr,"DigestFinal failed\n"); - exit(101); + EXIT(101); } EVP_MD_CTX_cleanup(&ctx); if(mdn != cn) { fprintf(stderr,"Digest length mismatch, got %d expected %d\n",mdn,cn); - exit(102); + EXIT(102); } if(memcmp(md,ciphertext,cn)) @@ -285,7 +288,7 @@ static int test_digest(const char *digest, fprintf(stderr,"Digest mismatch\n"); hexdump(stderr,"Got",md,cn); hexdump(stderr,"Expected",ciphertext,cn); - exit(103); + EXIT(103); } printf("\n"); @@ -303,7 +306,7 @@ int main(int argc,char **argv) if(argc != 2) { fprintf(stderr,"%s <test file>\n",argv[0]); - exit(1); + EXIT(1); } CRYPTO_malloc_debug_init(); CRYPTO_set_mem_debug_options(V_CRYPTO_MDEBUG_ALL); @@ -315,7 +318,7 @@ int main(int argc,char **argv) if(!f) { perror(szTestFile); - exit(2); + EXIT(2); } /* Load up the software EVP_CIPHER and EVP_MD definitions */ @@ -371,7 +374,7 @@ int main(int argc,char **argv) && !test_digest(cipher,plaintext,pn,ciphertext,cn)) { fprintf(stderr,"Can't find %s\n",cipher); - exit(3); + EXIT(3); } } |