Make the verify_extra test location agnostic
authorRichard Levitte <levitte@openssl.org>
Fri, 4 Sep 2015 15:04:33 +0000 (17:04 +0200)
committerRichard Levitte <levitte@openssl.org>
Sat, 5 Sep 2015 23:28:40 +0000 (01:28 +0200)
Depending on platform, verify_extra_test may fail because it relies on
test/ being the current working directory.  Make it get all the required
files on the command line instead to solve that issue.

Reviewed-by: Tim Hudson <tjh@openssl.org>
test/Makefile
test/verify_extra_test.c

index c85e8d80b629e461294f8432c3688e2b8136115c..0900a92ce3d7a0cd3e5de066781f14de4e16348d 100644 (file)
@@ -432,7 +432,8 @@ test_constant_time: $(CONSTTIMETEST)$(EXE_EXT)
 
 test_verify_extra: $(VERIFYEXTRATEST)$(EXE_EXT)
        @echo $(START) $@
-       ../util/shlib_wrap.sh ./$(VERIFYEXTRATEST)
+       ../util/shlib_wrap.sh ./$(VERIFYEXTRATEST) \
+                certs/roots.pem certs/untrusted.pem certs/bad.pem
 
 test_clienthello: $(CLIENTHELLOTEST)$(EXE_EXT)
        @echo $(START) $@
index 08509f0131945264b81c8d00b365b68719744057..7cc673929ccf04e51605f3782cdaa900a52fa5ba 100644 (file)
@@ -130,7 +130,9 @@ static STACK_OF(X509) *load_certs_from_file(const char *filename)
  * CA=FALSE, and will therefore incorrectly verify bad
  *
  */
-static int test_alt_chains_cert_forgery(void)
+static int test_alt_chains_cert_forgery(const char *roots_f,
+                                        const char *untrusted_f,
+                                        const char *bad_f)
 {
     int ret = 0;
     int i;
@@ -148,12 +150,12 @@ static int test_alt_chains_cert_forgery(void)
     lookup = X509_STORE_add_lookup(store, X509_LOOKUP_file());
     if (lookup == NULL)
         goto err;
-    if(!X509_LOOKUP_load_file(lookup, "certs/roots.pem", X509_FILETYPE_PEM))
+    if(!X509_LOOKUP_load_file(lookup, roots_f, X509_FILETYPE_PEM))
         goto err;
 
-    untrusted = load_certs_from_file("certs/untrusted.pem");
+    untrusted = load_certs_from_file(untrusted_f);
 
-    if ((bio = BIO_new_file("certs/bad.pem", "r")) == NULL)
+    if ((bio = BIO_new_file(bad_f, "r")) == NULL)
         goto err;
 
     if((x = PEM_read_bio_X509(bio, NULL, 0, NULL)) == NULL)
@@ -183,7 +185,7 @@ static int test_alt_chains_cert_forgery(void)
     return ret;
 }
 
-int main(void)
+int main(int argc, char **argv)
 {
     CRYPTO_malloc_debug_init();
     CRYPTO_set_mem_debug_options(V_CRYPTO_MDEBUG_ALL);
@@ -192,7 +194,12 @@ int main(void)
     ERR_load_crypto_strings();
     OpenSSL_add_all_digests();
 
-    if (!test_alt_chains_cert_forgery()) {
+    if (argc != 4) {
+        fprintf(stderr, "usage: verify_extra_test roots.pem untrusted.pem bad.pem\n");
+        return 1;
+    }
+
+    if (!test_alt_chains_cert_forgery(argv[1], argv[2], argv[3])) {
         fprintf(stderr, "Test alt chains cert forgery failed\n");
         return 1;
     }