Don't generate buildtest_*err.c
[openssl.git] / test / d2i_test.c
index 58fbe4af2f4c5fd7cdd36ab3d3d59925febb7505..afea2dcb9f3dde163ddbb8f2c5daba116e7ff5de 100644 (file)
@@ -20,7 +20,7 @@
 #include <openssl/err.h>
 #include <openssl/x509.h>
 #include <openssl/x509v3.h>
-#include "e_os.h"
+#include "internal/nelem.h"
 
 static const ASN1_ITEM *item_type;
 static const char *test_file;
@@ -41,7 +41,7 @@ typedef struct {
 
 static expected_error_t expected_error = ASN1_UNKNOWN;
 
-static int test_bad_asn1()
+static int test_bad_asn1(void)
 {
     BIO *bio = NULL;
     ASN1_VALUE *value = NULL;
@@ -67,7 +67,7 @@ static int test_bad_asn1()
      * performs sanity checks on the input and can reject it before the
      * decoder is called.
      */
-    len = BIO_read(bio, buf, sizeof buf);
+    len = BIO_read(bio, buf, sizeof(buf));
     if (!TEST_int_ge(len, 0))
         goto err;
 
@@ -107,10 +107,10 @@ static int test_bad_asn1()
 }
 
 /*
- * Usage: d2i_test <type> <file>, e.g.
+ * Usage: d2i_test <name> <type> <file>, e.g.
  * d2i_test generalname bad_generalname.der
  */
-int test_main(int argc, char *argv[])
+int setup_tests(void)
 {
     const char *test_type_name;
     const char *expected_error_string;
@@ -125,15 +125,13 @@ int test_main(int argc, char *argv[])
         {"compare", ASN1_COMPARE}
     };
 
-    if (!TEST_int_eq(argc, 4)) {
-        fprintf(stderr, "Usage: d2i_test item_name expected_error file.der\n");
-        return 1;
+    if (!TEST_ptr(test_type_name = test_get_argument(0))
+            || !TEST_ptr(expected_error_string = test_get_argument(1))
+            || !TEST_ptr(test_file = test_get_argument(2))) {
+        TEST_note("Usage: d2i_test item_name expected_error file.der");
+        return 0;
     }
 
-    test_type_name = argv[1];
-    expected_error_string = argv[2];
-    test_file = argv[3];
-
     item_type = ASN1_ITEM_lookup(test_type_name);
 
     if (item_type == NULL) {
@@ -146,7 +144,7 @@ int test_main(int argc, char *argv[])
                 break;
             TEST_note("\t%s", it->sname);
         }
-        return 1;
+        return 0;
     }
 
     for (i = 0; i < OSSL_NELEM(expected_errors); i++) {
@@ -158,10 +156,9 @@ int test_main(int argc, char *argv[])
 
     if (expected_error == ASN1_UNKNOWN) {
         TEST_error("Unknown expected error %s\n", expected_error_string);
-        return 1;
+        return 0;
     }
 
     ADD_TEST(test_bad_asn1);
-
-    return run_tests(argv[0]);
+    return 1;
 }