diff options
author | Adam Langley <agl@google.com> | 2015-09-24 10:57:52 -0700 |
---|---|---|
committer | Adam Langley <agl@google.com> | 2015-09-24 11:04:03 -0700 |
commit | 1e4884f615b20946411a74e41eb9c6aa65e2d5f3 (patch) | |
tree | dd743d9d64af3145fe96b8d5fc2f3427544794bd /src/crypto/err/err_test.cc | |
parent | 08656b61d075740bfb24ddcce65223146259fc02 (diff) | |
download | external_boringssl-1e4884f615b20946411a74e41eb9c6aa65e2d5f3.zip external_boringssl-1e4884f615b20946411a74e41eb9c6aa65e2d5f3.tar.gz external_boringssl-1e4884f615b20946411a74e41eb9c6aa65e2d5f3.tar.bz2 |
external/boringssl: sync with upstream.
This change imports the current version of BoringSSL. The only local
change now is that |BORINGSSL_201509| is defined in base.h. This allows
this change to be made without (hopefully) breaking the build.
This change will need https://android-review.googlesource.com/172744 to
be landed afterwards to update a test.
Change-Id: I6d1f463f7785a2423bd846305af91c973c326104
Diffstat (limited to 'src/crypto/err/err_test.cc')
-rw-r--r-- | src/crypto/err/err_test.cc | 50 |
1 files changed, 41 insertions, 9 deletions
diff --git a/src/crypto/err/err_test.cc b/src/crypto/err/err_test.cc index 98dfb85..6643c68 100644 --- a/src/crypto/err/err_test.cc +++ b/src/crypto/err/err_test.cc @@ -22,7 +22,7 @@ static bool TestOverflow() { for (unsigned i = 0; i < ERR_NUM_ERRORS*2; i++) { - ERR_put_error(1, 2, i+1, "test", 1); + ERR_put_error(1, i+1, "function", "test", 1); } for (unsigned i = 0; i < ERR_NUM_ERRORS - 1; i++) { @@ -50,7 +50,7 @@ static bool TestPutError() { return false; } - ERR_put_error(1, 2, 3, "test", 4); + ERR_put_error(1, 2, "function", "test", 4); ERR_add_error_data(1, "testing"); int peeked_line, line, peeked_flags, flags; @@ -58,6 +58,7 @@ static bool TestPutError() { uint32_t peeked_packed_error = ERR_peek_error_line_data(&peeked_file, &peeked_line, &peeked_data, &peeked_flags); + const char *function = ERR_peek_function(); uint32_t packed_error = ERR_get_error_line_data(&file, &line, &data, &flags); if (peeked_packed_error != packed_error || @@ -68,12 +69,12 @@ static bool TestPutError() { return false; } - if (strcmp(file, "test") != 0 || + if (strcmp(function, "function") != 0 || + strcmp(file, "test") != 0 || line != 4 || (flags & ERR_FLAG_STRING) == 0 || ERR_GET_LIB(packed_error) != 1 || - ERR_GET_FUNC(packed_error) != 2 || - ERR_GET_REASON(packed_error) != 3 || + ERR_GET_REASON(packed_error) != 2 || strcmp(data, "testing") != 0) { fprintf(stderr, "Bad error data returned.\n"); return false; @@ -88,7 +89,7 @@ static bool TestClearError() { return false; } - ERR_put_error(1, 2, 3, "test", 4); + ERR_put_error(1, 2, "function", "test", 4); ERR_clear_error(); if (ERR_get_error() != 0) { @@ -100,7 +101,7 @@ static bool TestClearError() { } static bool TestPrint() { - ERR_put_error(1, 2, 3, "test", 4); + ERR_put_error(1, 2, "function", "test", 4); ERR_add_error_data(1, "testing"); uint32_t packed_error = ERR_get_error(); @@ -113,11 +114,41 @@ static bool TestPrint() { } static bool TestRelease() { - ERR_put_error(1, 2, 3, "test", 4); + ERR_put_error(1, 2, "function", "test", 4); ERR_remove_thread_state(NULL); return true; } +static bool HasSuffix(const char *str, const char *suffix) { + size_t suffix_len = strlen(suffix); + size_t str_len = strlen(str); + if (str_len < suffix_len) { + return false; + } + return strcmp(str + str_len - suffix_len, suffix) == 0; +} + +static bool TestPutMacro() { + int expected_line = __LINE__ + 1; + OPENSSL_PUT_ERROR(USER, ERR_R_INTERNAL_ERROR); + + int line; + const char *file; + const char *function = ERR_peek_function(); + uint32_t error = ERR_get_error_line(&file, &line); + + if (strcmp(function, "TestPutMacro") != 0 || + !HasSuffix(file, "err_test.cc") || + line != expected_line || + ERR_GET_LIB(error) != ERR_LIB_USER || + ERR_GET_REASON(error) != ERR_R_INTERNAL_ERROR) { + fprintf(stderr, "Bad error data returned.\n"); + return false; + } + + return true; +} + int main() { CRYPTO_library_init(); @@ -125,7 +156,8 @@ int main() { !TestPutError() || !TestClearError() || !TestPrint() || - !TestRelease()) { + !TestRelease() || + !TestPutMacro()) { return 1; } |