summaryrefslogtreecommitdiffstats
path: root/src/crypto/test
diff options
context:
space:
mode:
Diffstat (limited to 'src/crypto/test')
-rw-r--r--src/crypto/test/CMakeLists.txt1
-rw-r--r--src/crypto/test/file_test.cc1
-rw-r--r--src/crypto/test/file_test.h8
-rw-r--r--src/crypto/test/malloc.cc17
-rw-r--r--src/crypto/test/scoped_types.h5
-rw-r--r--src/crypto/test/test_util.cc30
-rw-r--r--src/crypto/test/test_util.h35
7 files changed, 6 insertions, 91 deletions
diff --git a/src/crypto/test/CMakeLists.txt b/src/crypto/test/CMakeLists.txt
index 8c75314..84a6174 100644
--- a/src/crypto/test/CMakeLists.txt
+++ b/src/crypto/test/CMakeLists.txt
@@ -5,5 +5,4 @@ add_library(
file_test.cc
malloc.cc
- test_util.cc
)
diff --git a/src/crypto/test/file_test.cc b/src/crypto/test/file_test.cc
index 6723350..8df6f9a 100644
--- a/src/crypto/test/file_test.cc
+++ b/src/crypto/test/file_test.cc
@@ -128,7 +128,6 @@ FileTest::ReadResult FileTest::ReadNext() {
const char *delimiter = FindDelimiter(buf);
if (delimiter == nullptr) {
fprintf(stderr, "Line %u: Could not parse attribute.\n", line_);
- return kReadError;
}
std::string key = StripSpace(buf, delimiter - buf);
std::string value = StripSpace(delimiter + 1,
diff --git a/src/crypto/test/file_test.h b/src/crypto/test/file_test.h
index 24651ab..7303d8a 100644
--- a/src/crypto/test/file_test.h
+++ b/src/crypto/test/file_test.h
@@ -18,19 +18,11 @@
#include <stdint.h>
#include <stdio.h>
-#if defined(_MSC_VER)
-#pragma warning(push)
-#pragma warning(disable: 4702)
-#endif
-
#include <string>
#include <map>
#include <set>
#include <vector>
-#if defined(_MSC_VER)
-#pragma warning(pop)
-#endif
// File-based test framework.
//
diff --git a/src/crypto/test/malloc.cc b/src/crypto/test/malloc.cc
index 898f2a7..9ffdf01 100644
--- a/src/crypto/test/malloc.cc
+++ b/src/crypto/test/malloc.cc
@@ -34,8 +34,6 @@
#if defined(__linux__) && defined(OPENSSL_GLIBC) && !defined(OPENSSL_ARM) && \
!defined(OPENSSL_AARCH64) && !defined(OPENSSL_ASAN)
-#include <errno.h>
-#include <signal.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
@@ -47,14 +45,14 @@
/* This file defines overrides for the standard allocation functions that allow
* a given allocation to be made to fail for testing. If the program is run
* with MALLOC_NUMBER_TO_FAIL set to a base-10 number then that allocation will
- * return NULL. If MALLOC_BREAK_ON_FAIL is also defined then the allocation
- * will signal SIGTRAP rather than return NULL.
+ * return NULL. If MALLOC_ABORT_ON_FAIL is also defined then the allocation
+ * will abort() rather than return NULL.
*
* This code is not thread safe. */
static uint64_t current_malloc_count = 0;
static uint64_t malloc_number_to_fail = 0;
-static char failure_enabled = 0, break_on_fail = 0;
+static char failure_enabled = 0, abort_on_fail = 0;
static int in_call = 0;
extern "C" {
@@ -97,7 +95,7 @@ static int should_fail_allocation() {
std::set_new_handler(cpp_new_handler);
}
}
- break_on_fail = (NULL != getenv("MALLOC_BREAK_ON_FAIL"));
+ abort_on_fail = (NULL != getenv("MALLOC_ABORT_ON_FAIL"));
init = 1;
}
@@ -110,8 +108,8 @@ static int should_fail_allocation() {
should_fail = (current_malloc_count == malloc_number_to_fail);
current_malloc_count++;
- if (should_fail && break_on_fail) {
- raise(SIGTRAP);
+ if (should_fail && abort_on_fail) {
+ abort();
}
return should_fail;
}
@@ -120,7 +118,6 @@ extern "C" {
void *malloc(size_t size) {
if (should_fail_allocation()) {
- errno = ENOMEM;
return NULL;
}
@@ -129,7 +126,6 @@ void *malloc(size_t size) {
void *calloc(size_t num_elems, size_t size) {
if (should_fail_allocation()) {
- errno = ENOMEM;
return NULL;
}
@@ -138,7 +134,6 @@ void *calloc(size_t num_elems, size_t size) {
void *realloc(void *ptr, size_t size) {
if (should_fail_allocation()) {
- errno = ENOMEM;
return NULL;
}
diff --git a/src/crypto/test/scoped_types.h b/src/crypto/test/scoped_types.h
index e44c6ed..c5c8cfe 100644
--- a/src/crypto/test/scoped_types.h
+++ b/src/crypto/test/scoped_types.h
@@ -18,7 +18,6 @@
#include <stdint.h>
#include <stdio.h>
-#include <openssl/aead.h>
#include <openssl/bio.h>
#include <openssl/bn.h>
#include <openssl/cmac.h>
@@ -113,13 +112,9 @@ using ScopedPKCS12 = ScopedOpenSSLType<PKCS12, PKCS12_free>;
using ScopedRSA = ScopedOpenSSLType<RSA, RSA_free>;
using ScopedX509 = ScopedOpenSSLType<X509, X509_free>;
using ScopedX509_ALGOR = ScopedOpenSSLType<X509_ALGOR, X509_ALGOR_free>;
-using ScopedX509_SIG = ScopedOpenSSLType<X509_SIG, X509_SIG_free>;
using ScopedX509Stack = ScopedOpenSSLStack<STACK_OF(X509), X509, X509_free>;
-using ScopedEVP_AEAD_CTX = ScopedOpenSSLContext<EVP_AEAD_CTX, void,
- EVP_AEAD_CTX_zero,
- EVP_AEAD_CTX_cleanup>;
using ScopedEVP_CIPHER_CTX = ScopedOpenSSLContext<EVP_CIPHER_CTX, int,
EVP_CIPHER_CTX_init,
EVP_CIPHER_CTX_cleanup>;
diff --git a/src/crypto/test/test_util.cc b/src/crypto/test/test_util.cc
deleted file mode 100644
index 8021aaa..0000000
--- a/src/crypto/test/test_util.cc
+++ /dev/null
@@ -1,30 +0,0 @@
-/* Copyright (c) 2015, Google Inc.
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
- * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
- * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
- * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
-
-#include <stdint.h>
-#include <stdio.h>
-
-#include "test_util.h"
-
-
-void hexdump(FILE *fp, const char *msg, const void *in, size_t len) {
- const uint8_t *data = reinterpret_cast<const uint8_t*>(in);
- size_t i;
-
- fputs(msg, fp);
- for (i = 0; i < len; i++) {
- fprintf(fp, "%02x", data[i]);
- }
- fputs("\n", fp);
-}
diff --git a/src/crypto/test/test_util.h b/src/crypto/test/test_util.h
deleted file mode 100644
index 972e206..0000000
--- a/src/crypto/test/test_util.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/* Copyright (c) 2015, Google Inc.
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
- * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
- * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
- * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
-
-#ifndef OPENSSL_HEADER_CRYPTO_TEST_TEST_UTIL_H
-#define OPENSSL_HEADER_CRYPTO_TEST_TEST_UTIL_H
-
-#include <stddef.h>
-#include <stdio.h>
-
-#if defined(__cplusplus)
-extern "C" {
-#endif
-
-
-/* hexdump writes |msg| to |fp| followed by the hex encoding of |len| bytes
- * from |in|. */
-void hexdump(FILE *fp, const char *msg, const void *in, size_t len);
-
-
-#if defined(__cplusplus)
-}
-#endif
-
-#endif /* OPENSSL_HEADER_CRYPTO_TEST_TEST_UTIL_H */