test/recipes/90-test_shlibload.t: Make sure to handle library renames
[openssl.git] / test / d2i_test.c
index 19bf4a69ae468d549374130413ee7f2323c35aeb..13efba968421e668be7e735aa737e365e42f1a3c 100644 (file)
@@ -1,11 +1,10 @@
 /*
  * Copyright 2016 The OpenSSL Project Authors. All Rights Reserved.
  *
- * Licensed under the OpenSSL licenses, (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * Licensed under the OpenSSL license (the "License").  You may not use
+ * this file except in compliance with the License.  You can obtain a copy
+ * in the file LICENSE in the source distribution or at
  * https://www.openssl.org/source/license.html
- * or in the file LICENSE in the source distribution.
  */
 
 /* Regression tests for ASN.1 parsing bugs. */
@@ -21,6 +20,9 @@
 #include <openssl/err.h>
 #include <openssl/x509.h>
 #include <openssl/x509v3.h>
+#ifndef OPENSSL_NO_CMS
+# include <openssl/cms.h>
+#endif
 #include "e_os.h"
 
 static const ASN1_ITEM *item_type;
@@ -143,13 +145,17 @@ int main(int argc, char **argv)
     int result = 0;
     const char *test_type_name;
     const char *expected_error_string;
+    const char *p = getenv("OPENSSL_DEBUG_MEMORY");
 
     size_t i;
     static ASN1_ITEM_EXP *items[] = {
         ASN1_ITEM_ref(ASN1_ANY),
         ASN1_ITEM_ref(X509),
         ASN1_ITEM_ref(GENERAL_NAME),
-        ASN1_ITEM_ref(ASN1_INTEGER)
+        ASN1_ITEM_ref(ASN1_INTEGER),
+#ifndef OPENSSL_NO_CMS
+        ASN1_ITEM_ref(CMS_ContentInfo)
+#endif
     };
 
     static error_enum expected_errors[] = {
@@ -160,6 +166,10 @@ int main(int argc, char **argv)
         {"compare", ASN1_COMPARE}
     };
 
+    if (p != NULL && strcmp(p, "on") == 0)
+        CRYPTO_set_mem_debug(1);
+    CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON);
+
     if (argc != 4) {
         fprintf(stderr,
                 "Usage: d2i_test item_name expected_error file.der\n");
@@ -203,5 +213,10 @@ int main(int argc, char **argv)
 
     result = run_tests(argv[0]);
 
+#ifndef OPENSSL_NO_CRYPTO_MDEBUG
+    if (CRYPTO_mem_leaks_fp(stderr) <= 0)
+        result = 1;
+#endif
+
     return result;
 }