From b99fe5f4927b305bae88daac2484c284fe749329 Mon Sep 17 00:00:00 2001 From: Pauli Date: Fri, 18 Aug 2017 09:50:25 +1000 Subject: [PATCH] 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) --- e_os.h | 6 +++--- include/internal/nelem.h | 14 ++++++++++++++ test/asn1_internal_test.c | 2 +- test/asn1_time_test.c | 2 +- test/bad_dtls_test.c | 2 +- test/bftest.c | 2 +- test/bntest.c | 2 +- test/casttest.c | 2 +- test/cipher_overhead_test.c | 2 +- test/cipherbytes_test.c | 2 +- test/cipherlist_test.c | 2 +- test/ciphername_test.c | 2 +- test/constant_time_test.c | 2 +- test/crltest.c | 2 +- test/d2i_test.c | 2 +- test/danetest.c | 2 +- test/dhtest.c | 2 +- test/drbgtest.c | 2 +- test/dsatest.c | 2 +- test/dtlsv1listentest.c | 2 +- test/ecstresstest.c | 2 +- test/ectest.c | 2 +- test/evp_extra_test.c | 2 +- test/exptest.c | 2 +- test/handshake_helper.c | 2 +- test/hmactest.c | 2 +- test/ideatest.c | 2 +- test/igetest.c | 2 +- test/lhash_test.c | 2 +- test/md2test.c | 2 +- test/mdc2_internal_test.c | 2 +- test/mdc2test.c | 2 +- test/modes_internal_test.c | 2 +- test/poly1305_internal_test.c | 2 +- test/rc2test.c | 2 +- test/rc4test.c | 2 +- test/rc5test.c | 2 +- test/rsa_test.c | 2 +- test/servername_test.c | 2 +- test/siphash_internal_test.c | 2 +- test/ssl_cert_table_internal_test.c | 2 +- test/ssl_test_ctx.c | 2 +- test/ssl_test_ctx_test.c | 2 +- test/sslapitest.c | 2 +- test/ssltest_old.c | 2 ++ test/ssltestlib.c | 2 +- test/stack_test.c | 2 +- test/test_test.c | 2 +- test/testutil/driver.c | 2 +- test/testutil/format_output.c | 2 +- test/testutil/main.c | 2 +- test/testutil/stanza.c | 2 +- test/testutil/tests.c | 2 +- test/time_offset_test.c | 2 +- test/v3nametest.c | 2 +- test/x509_internal_test.c | 2 +- test/x509_time_test.c | 2 +- test/x509aux.c | 2 +- 58 files changed, 74 insertions(+), 58 deletions(-) create mode 100644 include/internal/nelem.h diff --git a/e_os.h b/e_os.h index 4e01f9b815..87d98c24be 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 0000000000..d65a21a9fb --- /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 194a073788..06e324b5b7 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 184a18a5ad..897436c3f4 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 2c10a1cc5b..932cb0eb1d 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 cc509f2dfc..0639ec888d 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 f32b308d0c..cb292c6aba 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 0fdcb100cc..417a4cba2e 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 e93bf33e4c..a07ac7e86b 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 6601f7b5d6..13d6b23aaa 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 829042748a..6ec963110e 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 f010a3b8bc..0eac902ca9 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 8575194e90..24cbaf3660 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 720c13b3a2..f5af4b1e4f 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 e5ebcfa027..48edba4946 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 d21f554c7e..de51c83f56 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 595732c673..ac09c445fa 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 62d2dbde64..28d0d905c3 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 7c58731df8..d25a1d701f 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 e401ccffdd..00120cc0ab 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 e16ccd59f6..7c76f02108 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 80e10013a8..85847e0870 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 acccfe5449..5ca95e4fd6 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 b357a2349d..62a2377dfd 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 d200332771..b33cdd5640 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 efe21e0609..abd1193d81 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 32fea47ab7..5b715fe1c9 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 a5c890e346..8a1db67704 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 704b1807b4..6deea8d992 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 cda84697af..df55932f82 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 2c8d22d990..c5e74ea5ef 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 4f29953480..5dfe60e8bf 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 e2eb3b65d0..3fd0498b8b 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 592f4b6e83..55b76440ea 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 6323d81beb..fc00076b17 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 b2032fdd34..e3f41b6208 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 16a0364630..9aa214f814 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 55339f9053..13dcde1890 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 e0fe4d5eb5..f1b66ee510 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 ca24339ee7..60a2d8dd01 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 9d6d2b5759..9f52015214 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 b581cdfb94..9dc33951fe 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 f7ffe40197..2376ce178f 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 1c43686d2c..dfcbf11c90 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 3a8d9b2637..9e3bb7a83d 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 64acea3f7d..410d323a9a 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 ba2ceaf415..922dfdd41c 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 ae16d8285c..742cd61a6f 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 274d3cde72..1859706996 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 ae3bf0ef77..13123d5c6a 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 34abcb2ce7..2f4eeb6798 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 8a8f0cc8f4..35967528f8 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 b2d95db859..cea81ca2ec 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 b7f1e87367..8814ccb47a 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 0f89260c05..36f8df646c 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 17517cd7c8..930c01ce7b 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 7790b821e7..e8cec0cfea 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 13a2ffc6a5..d38aeb0263 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) -- 2.25.1