test/enginetest.c: Make sure no config file is loaded
authorRichard Levitte <levitte@openssl.org>
Tue, 16 Jul 2019 10:21:47 +0000 (12:21 +0200)
committerRichard Levitte <levitte@openssl.org>
Fri, 19 Jul 2019 18:20:02 +0000 (20:20 +0200)
If a config file gets loaded, the tests get disturbed.

Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/9393)

(cherry picked from commit 5800ba761052894145abe7a74a1159df007b6875)

test/enginetest.c

index be57f1618305c4ec2b6ca9c2045aa348146c5340..a837b09c6c78be426d7fa0c200a084b4d2903a75 100644 (file)
@@ -120,8 +120,12 @@ static int test_engines(void)
     display_engine_list();
 
     /*
-     * Depending on whether there's any hardware support compiled in, this
-     * remove may be destined to fail.
+     * At this point, we should have an empty list, unless some hardware
+     * support engine got added.  However, since we don't allow the config
+     * file to be loaded and don't otherwise load any built in engines,
+     * that is unlikely.  Still, we check, if for nothing else, then to
+     * notify that something is a little off (and might mean that |new_h1|
+     * wasn't unloaded when it should have)
      */
     if ((ptr = ENGINE_get_first()) != NULL) {
         if (!ENGINE_remove(ptr))
@@ -346,6 +350,15 @@ static int test_redirect(void)
 }
 #endif
 
+int global_init(void)
+{
+    /*
+     * If the config file gets loaded, the dynamic engine will be loaded,
+     * and that interferes with our test above.
+     */
+    return OPENSSL_init_crypto(OPENSSL_INIT_NO_LOAD_CONFIG, NULL);
+}
+
 int setup_tests(void)
 {
 #ifdef OPENSSL_NO_ENGINE