summaryrefslogtreecommitdiffstats
path: root/src/crypto/err/err_test.cc
diff options
context:
space:
mode:
authorKenny Root <kroot@google.com>2015-09-25 00:44:37 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2015-09-25 00:44:37 +0000
commite246de8f184e644debf965ecdca552f006b56881 (patch)
treedc62c249d595198e0d99e43890019d21e901fbec /src/crypto/err/err_test.cc
parentc737bc23bc868fff21e5c1b95940813f709ea550 (diff)
parent00bc53f6f4436972b7a8dcf2c1e5fd0ad7515872 (diff)
downloadexternal_boringssl-e246de8f184e644debf965ecdca552f006b56881.zip
external_boringssl-e246de8f184e644debf965ecdca552f006b56881.tar.gz
external_boringssl-e246de8f184e644debf965ecdca552f006b56881.tar.bz2
am 00bc53f6: am a04d78d3: Revert "external/boringssl: sync with upstream."
* commit '00bc53f6f4436972b7a8dcf2c1e5fd0ad7515872': Revert "external/boringssl: sync with upstream."
Diffstat (limited to 'src/crypto/err/err_test.cc')
-rw-r--r--src/crypto/err/err_test.cc50
1 files changed, 9 insertions, 41 deletions
diff --git a/src/crypto/err/err_test.cc b/src/crypto/err/err_test.cc
index 6643c68..98dfb85 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, i+1, "function", "test", 1);
+ ERR_put_error(1, 2, i+1, "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, "function", "test", 4);
+ ERR_put_error(1, 2, 3, "test", 4);
ERR_add_error_data(1, "testing");
int peeked_line, line, peeked_flags, flags;
@@ -58,7 +58,6 @@ 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 ||
@@ -69,12 +68,12 @@ static bool TestPutError() {
return false;
}
- if (strcmp(function, "function") != 0 ||
- strcmp(file, "test") != 0 ||
+ if (strcmp(file, "test") != 0 ||
line != 4 ||
(flags & ERR_FLAG_STRING) == 0 ||
ERR_GET_LIB(packed_error) != 1 ||
- ERR_GET_REASON(packed_error) != 2 ||
+ ERR_GET_FUNC(packed_error) != 2 ||
+ ERR_GET_REASON(packed_error) != 3 ||
strcmp(data, "testing") != 0) {
fprintf(stderr, "Bad error data returned.\n");
return false;
@@ -89,7 +88,7 @@ static bool TestClearError() {
return false;
}
- ERR_put_error(1, 2, "function", "test", 4);
+ ERR_put_error(1, 2, 3, "test", 4);
ERR_clear_error();
if (ERR_get_error() != 0) {
@@ -101,7 +100,7 @@ static bool TestClearError() {
}
static bool TestPrint() {
- ERR_put_error(1, 2, "function", "test", 4);
+ ERR_put_error(1, 2, 3, "test", 4);
ERR_add_error_data(1, "testing");
uint32_t packed_error = ERR_get_error();
@@ -114,41 +113,11 @@ static bool TestPrint() {
}
static bool TestRelease() {
- ERR_put_error(1, 2, "function", "test", 4);
+ ERR_put_error(1, 2, 3, "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();
@@ -156,8 +125,7 @@ int main() {
!TestPutError() ||
!TestClearError() ||
!TestPrint() ||
- !TestRelease() ||
- !TestPutMacro()) {
+ !TestRelease()) {
return 1;
}