diff options
author | Richard Levitte <levitte@openssl.org> | 2020-11-25 12:05:35 +0100 |
---|---|---|
committer | Richard Levitte <levitte@openssl.org> | 2020-11-27 12:02:56 +0100 |
commit | abcca5078fc2b5059462bf6a9c659f235c11d5d8 (patch) | |
tree | 0c24ce0dedfadd8d70129f76568b856c90724665 /test/errtest.c | |
parent | ERR: Restore the similarity of ERR_print_error_cb() and ERR_error_string_n() (diff) | |
download | openssl-abcca5078fc2b5059462bf6a9c659f235c11d5d8.tar.xz openssl-abcca5078fc2b5059462bf6a9c659f235c11d5d8.zip |
TEST: Adapt test/errtest for the 'no-err' configuration
Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org>
(Merged from https://github.com/openssl/openssl/pull/13510)
Diffstat (limited to 'test/errtest.c')
-rw-r--r-- | test/errtest.c | 35 |
1 files changed, 26 insertions, 9 deletions
diff --git a/test/errtest.c b/test/errtest.c index 247bc546a0..a5e35d6320 100644 --- a/test/errtest.c +++ b/test/errtest.c @@ -26,7 +26,12 @@ static int test_print_error_format(void) { /* Variables used to construct an error line */ + char *lib; const char *func = OPENSSL_FUNC; + char *reason; +# ifdef OPENSSL_NO_ERR + char reasonbuf[255]; +# endif # ifndef OPENSSL_NO_FILENAMES const char *file = OPENSSL_FILE; const int line = OPENSSL_LINE; @@ -35,13 +40,14 @@ static int test_print_error_format(void) const int line = 0; # endif /* The format for OpenSSL error lines */ - const char *expected_format = ":error::system library:%s:%s:%s:%d"; + const char *expected_format = ":error:%08lX:%s:%s:%s:%s:%d"; /*- - * ^^ ^^ ^^ ^^ - * function name -------------------------------------++ || || || - * reason string (system error string) ------------------++ || || - * file name -----------------------------------------------++ || - * line number ------------------------------------------------++ + * ^^ ^^ ^^ ^^ ^^ + * "library" name --------------------------++ || || || || + * function name ------------------------------++ || || || + * reason string (system error string) -----------++ || || + * file name ----------------------------------------++ || + * line number -----------------------------------------++ */ char expected[512]; @@ -49,7 +55,8 @@ static int test_print_error_format(void) int ret = 0, len; BIO *bio = NULL; const int syserr = EPERM; - int reasoncode; + unsigned long errorcode; + unsigned long reasoncode; /* * We set a mark here so we can clear the system error that we generate @@ -59,15 +66,25 @@ static int test_print_error_format(void) ERR_set_mark(); ERR_PUT_error(ERR_LIB_SYS, 0, syserr, file, line); - reasoncode = ERR_GET_REASON(ERR_peek_error()); + errorcode = ERR_peek_error(); + reasoncode = ERR_GET_REASON(errorcode); if (!TEST_int_eq(reasoncode, syserr)) { ERR_pop_to_mark(); goto err; } +# ifndef OPENSSL_NO_ERR + lib = "system library"; + reason = strerror(syserr); +# else + lib = "lib(2)"; + BIO_snprintf(reasonbuf, sizeof(reasonbuf), "reason(%lu)", reasoncode); + reason = reasonbuf; +# endif + BIO_snprintf(expected, sizeof(expected), expected_format, - func, strerror(syserr), file, line); + errorcode, lib, func, reason, file, line); if (!TEST_ptr(bio = BIO_new(BIO_s_mem()))) goto err; |