diff options
author | Rich Salz <rsalz@openssl.org> | 2017-04-11 22:16:33 +0200 |
---|---|---|
committer | Rich Salz <rsalz@openssl.org> | 2017-04-12 16:01:26 +0200 |
commit | e2a29ad6c5f6b42ce71400595cb504cbf8f3646a (patch) | |
tree | b1128c9a46d235febb87326391d7e7b12e604c39 /test/x509aux.c | |
parent | OpenSSL::Test: supported filtered command output (diff) | |
download | openssl-e2a29ad6c5f6b42ce71400595cb504cbf8f3646a.tar.xz openssl-e2a29ad6c5f6b42ce71400595cb504cbf8f3646a.zip |
Convert x509aux, cipherlist, casttest
To new test framework
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/3189)
Diffstat (limited to 'test/x509aux.c')
-rw-r--r-- | test/x509aux.c | 77 |
1 files changed, 13 insertions, 64 deletions
diff --git a/test/x509aux.c b/test/x509aux.c index 2c20d6d743..2ad7b6d1cd 100644 --- a/test/x509aux.c +++ b/test/x509aux.c @@ -16,33 +16,10 @@ #include <openssl/pem.h> #include <openssl/conf.h> #include <openssl/err.h> - -#include "../e_os.h" - -static const char *progname; - -static void test_usage(void) -{ - fprintf(stderr, "usage: %s certfile\n", progname); -} - -static void print_errors(void) -{ - unsigned long err; - char buffer[1024]; - const char *file; - const char *data; - int line; - int flags; - - while ((err = ERR_get_error_line_data(&file, &line, &data, &flags)) != 0) { - ERR_error_string_n(err, buffer, sizeof(buffer)); - if (flags & ERR_TXT_STRING) - fprintf(stderr, "Error: %s:%s:%d:%s\n", buffer, file, line, data); - else - fprintf(stderr, "Error: %s:%s:%d\n", buffer, file, line); - } -} +#include "e_os.h" +#include "test_main.h" +#include "test_main_custom.h" +#include "testutil.h" static int test_certs(BIO *fp) { @@ -173,59 +150,31 @@ static int test_certs(BIO *fp) } /* Some other PEM read error */ - print_errors(); return 0; } -int main(int argc, char *argv[]) +int test_main(int argc, char *argv[]) { BIO *bio_err; - const char *p; int ret = 1; - progname = argv[0]; - if (argc < 2) { - test_usage(); - EXIT(ret); - } + if (argc < 2) + TEST_error("usage: %s certfile...", argv[0]); bio_err = BIO_new_fp(stderr, BIO_NOCLOSE | BIO_FP_TEXT); - p = getenv("OPENSSL_DEBUG_MEMORY"); - if (p != NULL && strcmp(p, "on") == 0) - CRYPTO_set_mem_debug(1); - CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON); - - argc--; - argv++; - - while (argc >= 1) { + for (argv++; *argv; argv++) { BIO *f = BIO_new_file(*argv, "r"); int ok; - if (f == NULL) { - fprintf(stderr, "%s: Error opening cert file: '%s': %s\n", - progname, *argv, strerror(errno)); - EXIT(ret); - } - ret = !(ok = test_certs(f)); + TEST_check(f != NULL); + ok = test_certs(f); BIO_free(f); - if (!ok) { - printf("%s ERROR\n", *argv); - ret = 1; + if (!TEST_int_eq(ok, 1)) break; - } - printf("%s OK\n", *argv); - - argc--; - argv++; + ret = 0; } - -#ifndef OPENSSL_NO_CRYPTO_MDEBUG - if (CRYPTO_mem_leaks(bio_err) <= 0) - ret = 1; -#endif BIO_free(bio_err); - EXIT(ret); + return ret; } |