Modify test/afalgtest to fail if the afalg engine couldn't be loaded
[openssl.git] / test / afalgtest.c
index ec25d58ddcef4fbbc1ea79a86f28f6dc747b4b8d..bf9054554ae8fc627ca8d67fb82b92feabc83982 100644 (file)
@@ -62,7 +62,7 @@ static int test_afalg_aes_cbc(int keysize_idx)
                                     "\xb1\x9e\xe0\xdf\x61\xb9\xc2\x55\xeb";
     unsigned char encresult_256[] = "\xa0\x76\x85\xfd\xc1\x65\x71\x9d"
                                     "\xc7\xe9\x13\x6e\xae\x55\x49\xb4\x13";
                                     "\xb1\x9e\xe0\xdf\x61\xb9\xc2\x55\xeb";
     unsigned char encresult_256[] = "\xa0\x76\x85\xfd\xc1\x65\x71\x9d"
                                     "\xc7\xe9\x13\x6e\xae\x55\x49\xb4\x13";
-    unsigned char *enc_result;
+    unsigned char *enc_result = NULL;
 
     int encl, encf, decl, decf;
     int ret = 0;
 
     int encl, encf, decl, decf;
     int ret = 0;
@@ -128,14 +128,14 @@ int global_init(void)
 int setup_tests(void)
 {
 #ifndef OPENSSL_NO_ENGINE
 int setup_tests(void)
 {
 #ifndef OPENSSL_NO_ENGINE
-    if ((e = ENGINE_by_id("afalg")) == NULL) {
+    if (!TEST_ptr(e = ENGINE_by_id("afalg"))) {
         /* Probably a platform env issue, not a test failure. */
         /* Probably a platform env issue, not a test failure. */
-        TEST_info("Can't load AFALG engine");
-    } else {
+        TEST_info("Can't load AFALG engine, you might want to check $OPENSSL_ENGINES");
+        return 0;
+    }
 # ifndef OPENSSL_NO_AFALGENG
 # ifndef OPENSSL_NO_AFALGENG
-        ADD_ALL_TESTS(test_afalg_aes_cbc, 3);
+    ADD_ALL_TESTS(test_afalg_aes_cbc, 3);
 # endif
 # endif
-    }
 #endif
 
     return 1;
 #endif
 
     return 1;