- test_file = argv[2];
-
- if (strcmp(test_type_name, "generalname") == 0) {
- item_type = ASN1_ITEM_rptr(GENERAL_NAME);
- } else if (strcmp(test_type_name, "x509") == 0) {
- item_type = ASN1_ITEM_rptr(X509);
- } else {
- fprintf(stderr, "Bad type %s\n", test_type_name);
+ expected_error_string = argv[2];
+ test_file = argv[3];
+
+ for (i = 0; i < OSSL_NELEM(items); i++) {
+ const ASN1_ITEM *it = ASN1_ITEM_ptr(items[i]);
+ if (strcmp(test_type_name, it->sname) == 0) {
+ item_type = it;
+ break;
+ }
+ }
+ if (item_type == NULL) {
+ fprintf(stderr, "Unknown type %s\n", test_type_name);
+ fprintf(stderr, "Supported types:\n");
+ for (i = 0; i < OSSL_NELEM(items); i++) {
+ const ASN1_ITEM *it = ASN1_ITEM_ptr(items[i]);
+ fprintf(stderr, "\t%s\n", it->sname);
+ }
+ return 1;
+ }
+
+ for (i = 0; i < OSSL_NELEM(expected_errors); i++) {
+ if (strcmp(expected_errors[i].str, expected_error_string) == 0) {
+ expected_error = expected_errors[i].code;
+ break;
+ }
+ }
+
+ if (expected_error == ASN1_UNKNOWN) {
+ fprintf(stderr, "Unknown expected error %s\n", expected_error_string);