From: Pauli Date: Thu, 17 Aug 2017 23:50:25 +0000 (+1000) Subject: Remove tests dependence on e_os.h X-Git-Tag: OpenSSL_1_1_1-pre1~827 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b99fe5f4927b305bae88daac2484c284fe749329;p=thirdparty%2Fopenssl.git Remove tests dependence on e_os.h Apart from ssltest_old.c, the test suite relied on e_os.h for the OSSL_NELEM macro and nothing else. The ssltest_old.c also requires EXIT and some socket macros. Create a new header to define the OSSL_NELEM macro and use that instead. Reviewed-by: Rich Salz (Merged from https://github.com/openssl/openssl/pull/4186) --- diff --git a/e_os.h b/e_os.h index 4e01f9b815d..87d98c24be2 100644 --- a/e_os.h +++ b/e_os.h @@ -1,5 +1,5 @@ /* - * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 1995-2017 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the OpenSSL license (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -14,6 +14,8 @@ # include # include +# include + /* * contains what we can justify to make visible to the * outside; this file e_os.h is not part of the exported interface. @@ -540,8 +542,6 @@ struct servent *getservbyname(const char *name, const char *proto); # endif /* end vxworks */ -#define OSSL_NELEM(x) (sizeof(x)/sizeof((x)[0])) - #ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION # define CRYPTO_memcmp memcmp #endif diff --git a/include/internal/nelem.h b/include/internal/nelem.h new file mode 100644 index 00000000000..d65a21a9fbe --- /dev/null +++ b/include/internal/nelem.h @@ -0,0 +1,14 @@ +/* + * Copyright 2017 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the OpenSSL license (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef HEADER_NELEM_H +# define HEADER_NELEM_H + +# define OSSL_NELEM(x) (sizeof(x)/sizeof((x)[0])) +#endif diff --git a/test/asn1_internal_test.c b/test/asn1_internal_test.c index 194a0737886..06e324b5b7b 100644 --- a/test/asn1_internal_test.c +++ b/test/asn1_internal_test.c @@ -16,7 +16,7 @@ #include #include #include "testutil.h" -#include "e_os.h" +#include /********************************************************************** * diff --git a/test/asn1_time_test.c b/test/asn1_time_test.c index 184a18a5ad1..897436c3f4c 100644 --- a/test/asn1_time_test.c +++ b/test/asn1_time_test.c @@ -16,7 +16,7 @@ #include #include #include "testutil.h" -#include "e_os.h" +#include struct testdata { char *data; /* TIME string value */ diff --git a/test/bad_dtls_test.c b/test/bad_dtls_test.c index 2c10a1cc5b2..932cb0eb1da 100644 --- a/test/bad_dtls_test.c +++ b/test/bad_dtls_test.c @@ -39,7 +39,7 @@ #include #include "../ssl/packet_locl.h" -#include "../e_os.h" /* for OSSL_NELEM() */ +#include #include "testutil.h" diff --git a/test/bftest.c b/test/bftest.c index cc509f2dfcc..0639ec888d3 100644 --- a/test/bftest.c +++ b/test/bftest.c @@ -19,7 +19,7 @@ #include "testutil.h" -#include "../e_os.h" +#include #ifndef OPENSSL_NO_BF # include diff --git a/test/bntest.c b/test/bntest.c index f32b308d0c8..cb292c6abad 100644 --- a/test/bntest.c +++ b/test/bntest.c @@ -12,7 +12,7 @@ #include #include -#include "e_os.h" +#include #include #include #include diff --git a/test/casttest.c b/test/casttest.c index 0fdcb100cc7..417a4cba2e8 100644 --- a/test/casttest.c +++ b/test/casttest.c @@ -12,7 +12,7 @@ #include #include /* To see if OPENSSL_NO_CAST is defined */ -#include "e_os.h" +#include #include "testutil.h" #ifndef OPENSSL_NO_CAST diff --git a/test/cipher_overhead_test.c b/test/cipher_overhead_test.c index e93bf33e4ca..a07ac7e86b6 100644 --- a/test/cipher_overhead_test.c +++ b/test/cipher_overhead_test.c @@ -7,7 +7,7 @@ * https://www.openssl.org/source/license.html */ -#include "e_os.h" +#include #include "testutil.h" #ifdef __VMS diff --git a/test/cipherbytes_test.c b/test/cipherbytes_test.c index 6601f7b5d65..13d6b23aaac 100644 --- a/test/cipherbytes_test.c +++ b/test/cipherbytes_test.c @@ -18,7 +18,7 @@ #include #include -#include "e_os.h" +#include #include "testutil.h" static SSL_CTX *ctx; diff --git a/test/cipherlist_test.c b/test/cipherlist_test.c index 829042748a4..6ec963110e4 100644 --- a/test/cipherlist_test.c +++ b/test/cipherlist_test.c @@ -18,7 +18,7 @@ #include #include -#include "e_os.h" +#include #include "testutil.h" typedef struct cipherlist_test_fixture { diff --git a/test/ciphername_test.c b/test/ciphername_test.c index f010a3b8bc7..0eac902ca9f 100644 --- a/test/ciphername_test.c +++ b/test/ciphername_test.c @@ -19,7 +19,7 @@ #include #include -#include "e_os.h" +#include #include "testutil.h" typedef struct cipher_id_name { diff --git a/test/constant_time_test.c b/test/constant_time_test.c index 8575194e90a..24cbaf3660d 100644 --- a/test/constant_time_test.c +++ b/test/constant_time_test.c @@ -10,7 +10,7 @@ #include #include -#include "e_os.h" +#include #include "internal/constant_time_locl.h" #include "testutil.h" #include "internal/numbers.h" diff --git a/test/crltest.c b/test/crltest.c index 720c13b3a2d..f5af4b1e4f9 100644 --- a/test/crltest.c +++ b/test/crltest.c @@ -7,7 +7,7 @@ * https://www.openssl.org/source/license.html */ -#include "../e_os.h" +#include #include #include #include diff --git a/test/d2i_test.c b/test/d2i_test.c index e5ebcfa0276..48edba49466 100644 --- a/test/d2i_test.c +++ b/test/d2i_test.c @@ -20,7 +20,7 @@ #include #include #include -#include "e_os.h" +#include static const ASN1_ITEM *item_type; static const char *test_file; diff --git a/test/danetest.c b/test/danetest.c index d21f554c7e8..de51c83f561 100644 --- a/test/danetest.c +++ b/test/danetest.c @@ -24,7 +24,7 @@ #endif #include "testutil.h" -#include "e_os.h" +#include #define _UC(c) ((unsigned char)(c)) diff --git a/test/dhtest.c b/test/dhtest.c index 595732c6732..ac09c445fa4 100644 --- a/test/dhtest.c +++ b/test/dhtest.c @@ -11,7 +11,7 @@ #include #include -#include "e_os.h" +#include #include #include #include diff --git a/test/drbgtest.c b/test/drbgtest.c index 62d2dbde647..28d0d905c35 100644 --- a/test/drbgtest.c +++ b/test/drbgtest.c @@ -8,7 +8,7 @@ */ #include -#include "e_os.h" +#include #include #include #include diff --git a/test/dsatest.c b/test/dsatest.c index 7c58731df8d..d25a1d701f7 100644 --- a/test/dsatest.c +++ b/test/dsatest.c @@ -19,7 +19,7 @@ #include #include "testutil.h" -#include "e_os.h" +#include #ifndef OPENSSL_NO_DSA static int dsa_cb(int p, int n, BN_GENCB *arg); diff --git a/test/dtlsv1listentest.c b/test/dtlsv1listentest.c index e401ccffddf..00120cc0ab0 100644 --- a/test/dtlsv1listentest.c +++ b/test/dtlsv1listentest.c @@ -12,7 +12,7 @@ #include #include #include -#include "e_os.h" +#include #include "testutil.h" #ifndef OPENSSL_NO_SOCK diff --git a/test/ecstresstest.c b/test/ecstresstest.c index e16ccd59f6b..7c76f02108b 100644 --- a/test/ecstresstest.c +++ b/test/ecstresstest.c @@ -8,7 +8,7 @@ * or in the file LICENSE in the source distribution. */ -#include "e_os.h" +#include #include "testutil.h" #include diff --git a/test/ectest.c b/test/ectest.c index 80e10013a82..85847e08703 100644 --- a/test/ectest.c +++ b/test/ectest.c @@ -8,7 +8,7 @@ * https://www.openssl.org/source/license.html */ -#include "e_os.h" +#include #include "testutil.h" #ifndef OPENSSL_NO_EC diff --git a/test/evp_extra_test.c b/test/evp_extra_test.c index acccfe54490..5ca95e4fd64 100644 --- a/test/evp_extra_test.c +++ b/test/evp_extra_test.c @@ -16,7 +16,7 @@ #include #include #include "testutil.h" -#include "e_os.h" +#include /* * kExampleRSAKeyDER is an RSA private key in ASN.1, DER format. Of course, you diff --git a/test/exptest.c b/test/exptest.c index b357a2349d4..62a2377dfd9 100644 --- a/test/exptest.c +++ b/test/exptest.c @@ -11,7 +11,7 @@ #include #include -#include "../e_os.h" +#include #include #include diff --git a/test/handshake_helper.c b/test/handshake_helper.c index d200332771f..b33cdd5640f 100644 --- a/test/handshake_helper.c +++ b/test/handshake_helper.c @@ -18,7 +18,7 @@ #ifndef OPENSSL_NO_SOCK # define USE_SOCKETS -# include "e_os.h" +# include #endif #include "handshake_helper.h" diff --git a/test/hmactest.c b/test/hmactest.c index efe21e0609b..abd1193d819 100644 --- a/test/hmactest.c +++ b/test/hmactest.c @@ -11,7 +11,7 @@ #include #include -#include "../e_os.h" +#include # include # include diff --git a/test/ideatest.c b/test/ideatest.c index 32fea47ab76..5b715fe1c91 100644 --- a/test/ideatest.c +++ b/test/ideatest.c @@ -9,7 +9,7 @@ #include -#include "../e_os.h" +#include #include "testutil.h" #ifndef OPENSSL_NO_IDEA diff --git a/test/igetest.c b/test/igetest.c index a5c890e3462..8a1db677047 100644 --- a/test/igetest.c +++ b/test/igetest.c @@ -12,7 +12,7 @@ #include #include #include -#include "e_os.h" +#include #include "testutil.h" #define TEST_SIZE 128 diff --git a/test/lhash_test.c b/test/lhash_test.c index 704b1807b44..6deea8d9921 100644 --- a/test/lhash_test.c +++ b/test/lhash_test.c @@ -16,7 +16,7 @@ #include #include -#include "e_os.h" +#include #include "testutil.h" /* diff --git a/test/md2test.c b/test/md2test.c index cda84697afc..df55932f82d 100644 --- a/test/md2test.c +++ b/test/md2test.c @@ -9,7 +9,7 @@ #include -#include "../e_os.h" +#include #include "testutil.h" #ifndef OPENSSL_NO_MD2 diff --git a/test/mdc2_internal_test.c b/test/mdc2_internal_test.c index 2c8d22d9909..c5e74ea5ef5 100644 --- a/test/mdc2_internal_test.c +++ b/test/mdc2_internal_test.c @@ -14,7 +14,7 @@ #include #include "testutil.h" -#include "e_os.h" +#include typedef struct { const char *input; diff --git a/test/mdc2test.c b/test/mdc2test.c index 4f299534809..5dfe60e8bfe 100644 --- a/test/mdc2test.c +++ b/test/mdc2test.c @@ -9,7 +9,7 @@ #include -#include "../e_os.h" +#include #include "testutil.h" #if defined(OPENSSL_NO_DES) && !defined(OPENSSL_NO_MDC2) diff --git a/test/modes_internal_test.c b/test/modes_internal_test.c index e2eb3b65d0a..3fd0498b8b7 100644 --- a/test/modes_internal_test.c +++ b/test/modes_internal_test.c @@ -16,7 +16,7 @@ #include #include "../crypto/modes/modes_lcl.h" #include "testutil.h" -#include "e_os.h" +#include typedef struct { size_t size; diff --git a/test/poly1305_internal_test.c b/test/poly1305_internal_test.c index 592f4b6e83d..55b76440eae 100644 --- a/test/poly1305_internal_test.c +++ b/test/poly1305_internal_test.c @@ -15,7 +15,7 @@ #include "testutil.h" #include "internal/poly1305.h" #include "../crypto/poly1305/poly1305_local.h" -#include "e_os.h" +#include typedef struct { size_t size; diff --git a/test/rc2test.c b/test/rc2test.c index 6323d81beb1..fc00076b170 100644 --- a/test/rc2test.c +++ b/test/rc2test.c @@ -7,7 +7,7 @@ * https://www.openssl.org/source/license.html */ -#include "../e_os.h" +#include #include "testutil.h" #ifndef OPENSSL_NO_RC2 diff --git a/test/rc4test.c b/test/rc4test.c index b2032fdd340..e3f41b62089 100644 --- a/test/rc4test.c +++ b/test/rc4test.c @@ -9,7 +9,7 @@ #include -#include "../e_os.h" +#include #include "testutil.h" #ifndef OPENSSL_NO_RC4 diff --git a/test/rc5test.c b/test/rc5test.c index 16a03646305..9aa214f814c 100644 --- a/test/rc5test.c +++ b/test/rc5test.c @@ -9,7 +9,7 @@ #include -#include "../e_os.h" +#include #include "testutil.h" #ifndef OPENSSL_NO_RC5 diff --git a/test/rsa_test.c b/test/rsa_test.c index 55339f90535..13dcde18902 100644 --- a/test/rsa_test.c +++ b/test/rsa_test.c @@ -12,7 +12,7 @@ #include #include -#include "e_os.h" +#include #include #include diff --git a/test/servername_test.c b/test/servername_test.c index e0fe4d5eb55..f1b66ee510c 100644 --- a/test/servername_test.c +++ b/test/servername_test.c @@ -21,7 +21,7 @@ #include "../ssl/packet_locl.h" #include "testutil.h" -#include "e_os.h" +#include #define CLIENT_VERSION_LEN 2 diff --git a/test/siphash_internal_test.c b/test/siphash_internal_test.c index ca24339ee7e..60a2d8dd019 100644 --- a/test/siphash_internal_test.c +++ b/test/siphash_internal_test.c @@ -16,7 +16,7 @@ #include "testutil.h" #include "internal/siphash.h" #include "../crypto/siphash/siphash_local.h" -#include "e_os.h" +#include static BIO* b_stderr = NULL; static BIO* b_stdout = NULL; diff --git a/test/ssl_cert_table_internal_test.c b/test/ssl_cert_table_internal_test.c index 9d6d2b57596..9f520152146 100644 --- a/test/ssl_cert_table_internal_test.c +++ b/test/ssl_cert_table_internal_test.c @@ -14,7 +14,7 @@ #include #include "testutil.h" -#include "e_os.h" +#include #ifdef __VMS # pragma names save diff --git a/test/ssl_test_ctx.c b/test/ssl_test_ctx.c index b581cdfb944..9dc33951feb 100644 --- a/test/ssl_test_ctx.c +++ b/test/ssl_test_ctx.c @@ -12,7 +12,7 @@ #include #include -#include "e_os.h" +#include #include "ssl_test_ctx.h" #include "testutil.h" diff --git a/test/ssl_test_ctx_test.c b/test/ssl_test_ctx_test.c index f7ffe40197c..2376ce178f8 100644 --- a/test/ssl_test_ctx_test.c +++ b/test/ssl_test_ctx_test.c @@ -15,7 +15,7 @@ #include #include -#include "e_os.h" +#include #include "ssl_test_ctx.h" #include "testutil.h" #include diff --git a/test/sslapitest.c b/test/sslapitest.c index 1c43686d2c1..dfcbf11c902 100644 --- a/test/sslapitest.c +++ b/test/sslapitest.c @@ -17,7 +17,7 @@ #include "ssltestlib.h" #include "testutil.h" -#include "e_os.h" +#include #include "../ssl/ssl_locl.h" static char *cert = NULL; diff --git a/test/ssltest_old.c b/test/ssltest_old.c index 3a8d9b26375..9e3bb7a83d4 100644 --- a/test/ssltest_old.c +++ b/test/ssltest_old.c @@ -25,6 +25,8 @@ #include #include +#include + #define USE_SOCKETS #include "e_os.h" diff --git a/test/ssltestlib.c b/test/ssltestlib.c index 64acea3f7dc..410d323a9ab 100644 --- a/test/ssltestlib.c +++ b/test/ssltestlib.c @@ -9,7 +9,7 @@ #include -#include "e_os.h" +#include #include "ssltestlib.h" #include "testutil.h" diff --git a/test/stack_test.c b/test/stack_test.c index ba2ceaf415d..922dfdd41c8 100644 --- a/test/stack_test.c +++ b/test/stack_test.c @@ -16,7 +16,7 @@ #include #include -#include "e_os.h" +#include #include "testutil.h" /* The macros below generate unused functions which error out one of the clang diff --git a/test/test_test.c b/test/test_test.c index ae16d8285c2..742cd61a6fb 100644 --- a/test/test_test.c +++ b/test/test_test.c @@ -16,7 +16,7 @@ #include #include -#include "e_os.h" +#include #include "testutil.h" #define TEST(expected, test) test_case((expected), #test, (test)) diff --git a/test/testutil/driver.c b/test/testutil/driver.c index 274d3cde721..1859706996c 100644 --- a/test/testutil/driver.c +++ b/test/testutil/driver.c @@ -14,7 +14,7 @@ #include #include -#include "../../e_os.h" +#include #include /* diff --git a/test/testutil/format_output.c b/test/testutil/format_output.c index ae3bf0ef770..13123d5c6a6 100644 --- a/test/testutil/format_output.c +++ b/test/testutil/format_output.c @@ -13,7 +13,7 @@ #include #include -#include "../../e_os.h" +#include /* The size of memory buffers to display on failure */ #define MEM_BUFFER_SIZE (2000) diff --git a/test/testutil/main.c b/test/testutil/main.c index 34abcb2ce7d..2f4eeb6798f 100644 --- a/test/testutil/main.c +++ b/test/testutil/main.c @@ -8,7 +8,7 @@ */ #include "../testutil.h" -#include "../../e_os.h" +#include #include "output.h" #include "tu_local.h" diff --git a/test/testutil/stanza.c b/test/testutil/stanza.c index 8a8f0cc8f4f..35967528f83 100644 --- a/test/testutil/stanza.c +++ b/test/testutil/stanza.c @@ -12,7 +12,7 @@ #include #include -#include "e_os.h" +#include "internal/nelem.h" #include "../testutil.h" #include "tu_local.h" diff --git a/test/testutil/tests.c b/test/testutil/tests.c index b2d95db8593..cea81ca2ec6 100644 --- a/test/testutil/tests.c +++ b/test/testutil/tests.c @@ -14,7 +14,7 @@ #include #include #include -#include "../../e_os.h" +#include /* * Output a failed test first line. diff --git a/test/time_offset_test.c b/test/time_offset_test.c index b7f1e87367a..8814ccb47ab 100644 --- a/test/time_offset_test.c +++ b/test/time_offset_test.c @@ -16,7 +16,7 @@ #include #include #include "testutil.h" -#include "e_os.h" +#include typedef struct { const char *data; diff --git a/test/v3nametest.c b/test/v3nametest.c index 0f89260c05c..36f8df646c2 100644 --- a/test/v3nametest.c +++ b/test/v3nametest.c @@ -8,7 +8,7 @@ */ #include -#include "e_os.h" +#include #include #include #include "testutil.h" diff --git a/test/x509_internal_test.c b/test/x509_internal_test.c index 17517cd7c81..930c01ce7bb 100644 --- a/test/x509_internal_test.c +++ b/test/x509_internal_test.c @@ -15,7 +15,7 @@ #include #include #include "testutil.h" -#include "e_os.h" +#include /********************************************************************** * diff --git a/test/x509_time_test.c b/test/x509_time_test.c index 7790b821e74..e8cec0cfeaa 100644 --- a/test/x509_time_test.c +++ b/test/x509_time_test.c @@ -15,7 +15,7 @@ #include #include #include "testutil.h" -#include "e_os.h" +#include typedef struct { const char *data; diff --git a/test/x509aux.c b/test/x509aux.c index 13a2ffc6a5e..d38aeb02638 100644 --- a/test/x509aux.c +++ b/test/x509aux.c @@ -16,7 +16,7 @@ #include #include #include -#include "e_os.h" +#include #include "testutil.h" static int test_certs(int num)