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 <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/4186)
This commit is contained in:
Pauli 2017-08-18 09:50:25 +10:00
parent 524fdd5155
commit b99fe5f492
58 changed files with 74 additions and 58 deletions

6
e_os.h
View File

@ -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 * Licensed under the OpenSSL license (the "License"). You may not use
* this file except in compliance with the License. You can obtain a copy * this file except in compliance with the License. You can obtain a copy
@ -14,6 +14,8 @@
# include <openssl/e_os2.h> # include <openssl/e_os2.h>
# include <openssl/crypto.h> # include <openssl/crypto.h>
# include <internal/nelem.h>
/* /*
* <openssl/e_os2.h> contains what we can justify to make visible to the * <openssl/e_os2.h> contains what we can justify to make visible to the
* outside; this file e_os.h is not part of the exported interface. * 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 # endif
/* end vxworks */ /* end vxworks */
#define OSSL_NELEM(x) (sizeof(x)/sizeof((x)[0]))
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION #ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
# define CRYPTO_memcmp memcmp # define CRYPTO_memcmp memcmp
#endif #endif

14
include/internal/nelem.h Normal file
View File

@ -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

View File

@ -16,7 +16,7 @@
#include <openssl/evp.h> #include <openssl/evp.h>
#include <openssl/objects.h> #include <openssl/objects.h>
#include "testutil.h" #include "testutil.h"
#include "e_os.h" #include <internal/nelem.h>
/********************************************************************** /**********************************************************************
* *

View File

@ -16,7 +16,7 @@
#include <openssl/evp.h> #include <openssl/evp.h>
#include <openssl/objects.h> #include <openssl/objects.h>
#include "testutil.h" #include "testutil.h"
#include "e_os.h" #include <internal/nelem.h>
struct testdata { struct testdata {
char *data; /* TIME string value */ char *data; /* TIME string value */

View File

@ -39,7 +39,7 @@
#include <openssl/kdf.h> #include <openssl/kdf.h>
#include "../ssl/packet_locl.h" #include "../ssl/packet_locl.h"
#include "../e_os.h" /* for OSSL_NELEM() */ #include <internal/nelem.h>
#include "testutil.h" #include "testutil.h"

View File

@ -19,7 +19,7 @@
#include "testutil.h" #include "testutil.h"
#include "../e_os.h" #include <internal/nelem.h>
#ifndef OPENSSL_NO_BF #ifndef OPENSSL_NO_BF
# include <openssl/blowfish.h> # include <openssl/blowfish.h>

View File

@ -12,7 +12,7 @@
#include <string.h> #include <string.h>
#include <ctype.h> #include <ctype.h>
#include "e_os.h" #include <internal/nelem.h>
#include <internal/numbers.h> #include <internal/numbers.h>
#include <openssl/bn.h> #include <openssl/bn.h>
#include <openssl/crypto.h> #include <openssl/crypto.h>

View File

@ -12,7 +12,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <openssl/opensslconf.h> /* To see if OPENSSL_NO_CAST is defined */ #include <openssl/opensslconf.h> /* To see if OPENSSL_NO_CAST is defined */
#include "e_os.h" #include <internal/nelem.h>
#include "testutil.h" #include "testutil.h"
#ifndef OPENSSL_NO_CAST #ifndef OPENSSL_NO_CAST

View File

@ -7,7 +7,7 @@
* https://www.openssl.org/source/license.html * https://www.openssl.org/source/license.html
*/ */
#include "e_os.h" #include <internal/nelem.h>
#include "testutil.h" #include "testutil.h"
#ifdef __VMS #ifdef __VMS

View File

@ -18,7 +18,7 @@
#include <openssl/ssl3.h> #include <openssl/ssl3.h>
#include <openssl/tls1.h> #include <openssl/tls1.h>
#include "e_os.h" #include <internal/nelem.h>
#include "testutil.h" #include "testutil.h"
static SSL_CTX *ctx; static SSL_CTX *ctx;

View File

@ -18,7 +18,7 @@
#include <openssl/ssl3.h> #include <openssl/ssl3.h>
#include <openssl/tls1.h> #include <openssl/tls1.h>
#include "e_os.h" #include <internal/nelem.h>
#include "testutil.h" #include "testutil.h"
typedef struct cipherlist_test_fixture { typedef struct cipherlist_test_fixture {

View File

@ -19,7 +19,7 @@
#include <openssl/ssl3.h> #include <openssl/ssl3.h>
#include <openssl/tls1.h> #include <openssl/tls1.h>
#include "e_os.h" #include <internal/nelem.h>
#include "testutil.h" #include "testutil.h"
typedef struct cipher_id_name { typedef struct cipher_id_name {

View File

@ -10,7 +10,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include "e_os.h" #include <internal/nelem.h>
#include "internal/constant_time_locl.h" #include "internal/constant_time_locl.h"
#include "testutil.h" #include "testutil.h"
#include "internal/numbers.h" #include "internal/numbers.h"

View File

@ -7,7 +7,7 @@
* https://www.openssl.org/source/license.html * https://www.openssl.org/source/license.html
*/ */
#include "../e_os.h" #include <internal/nelem.h>
#include <string.h> #include <string.h>
#include <openssl/bio.h> #include <openssl/bio.h>
#include <openssl/crypto.h> #include <openssl/crypto.h>

View File

@ -20,7 +20,7 @@
#include <openssl/err.h> #include <openssl/err.h>
#include <openssl/x509.h> #include <openssl/x509.h>
#include <openssl/x509v3.h> #include <openssl/x509v3.h>
#include "e_os.h" #include <internal/nelem.h>
static const ASN1_ITEM *item_type; static const ASN1_ITEM *item_type;
static const char *test_file; static const char *test_file;

View File

@ -24,7 +24,7 @@
#endif #endif
#include "testutil.h" #include "testutil.h"
#include "e_os.h" #include <internal/nelem.h>
#define _UC(c) ((unsigned char)(c)) #define _UC(c) ((unsigned char)(c))

View File

@ -11,7 +11,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include "e_os.h" #include <internal/nelem.h>
#include <openssl/crypto.h> #include <openssl/crypto.h>
#include <openssl/bio.h> #include <openssl/bio.h>
#include <openssl/bn.h> #include <openssl/bn.h>

View File

@ -8,7 +8,7 @@
*/ */
#include <string.h> #include <string.h>
#include "e_os.h" #include <internal/nelem.h>
#include <openssl/crypto.h> #include <openssl/crypto.h>
#include <openssl/err.h> #include <openssl/err.h>
#include <openssl/rand.h> #include <openssl/rand.h>

View File

@ -19,7 +19,7 @@
#include <openssl/dsa.h> #include <openssl/dsa.h>
#include "testutil.h" #include "testutil.h"
#include "e_os.h" #include <internal/nelem.h>
#ifndef OPENSSL_NO_DSA #ifndef OPENSSL_NO_DSA
static int dsa_cb(int p, int n, BN_GENCB *arg); static int dsa_cb(int p, int n, BN_GENCB *arg);

View File

@ -12,7 +12,7 @@
#include <openssl/bio.h> #include <openssl/bio.h>
#include <openssl/err.h> #include <openssl/err.h>
#include <openssl/conf.h> #include <openssl/conf.h>
#include "e_os.h" #include <internal/nelem.h>
#include "testutil.h" #include "testutil.h"
#ifndef OPENSSL_NO_SOCK #ifndef OPENSSL_NO_SOCK

View File

@ -8,7 +8,7 @@
* or in the file LICENSE in the source distribution. * or in the file LICENSE in the source distribution.
*/ */
#include "e_os.h" #include <internal/nelem.h>
#include "testutil.h" #include "testutil.h"
#include <stdio.h> #include <stdio.h>

View File

@ -8,7 +8,7 @@
* https://www.openssl.org/source/license.html * https://www.openssl.org/source/license.html
*/ */
#include "e_os.h" #include <internal/nelem.h>
#include "testutil.h" #include "testutil.h"
#ifndef OPENSSL_NO_EC #ifndef OPENSSL_NO_EC

View File

@ -16,7 +16,7 @@
#include <openssl/rsa.h> #include <openssl/rsa.h>
#include <openssl/x509.h> #include <openssl/x509.h>
#include "testutil.h" #include "testutil.h"
#include "e_os.h" #include <internal/nelem.h>
/* /*
* kExampleRSAKeyDER is an RSA private key in ASN.1, DER format. Of course, you * kExampleRSAKeyDER is an RSA private key in ASN.1, DER format. Of course, you

View File

@ -11,7 +11,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include "../e_os.h" #include <internal/nelem.h>
#include <openssl/bio.h> #include <openssl/bio.h>
#include <openssl/bn.h> #include <openssl/bn.h>

View File

@ -18,7 +18,7 @@
#ifndef OPENSSL_NO_SOCK #ifndef OPENSSL_NO_SOCK
# define USE_SOCKETS # define USE_SOCKETS
# include "e_os.h" # include <internal/nelem.h>
#endif #endif
#include "handshake_helper.h" #include "handshake_helper.h"

View File

@ -11,7 +11,7 @@
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include "../e_os.h" #include <internal/nelem.h>
# include <openssl/hmac.h> # include <openssl/hmac.h>
# include <openssl/sha.h> # include <openssl/sha.h>

View File

@ -9,7 +9,7 @@
#include <string.h> #include <string.h>
#include "../e_os.h" #include <internal/nelem.h>
#include "testutil.h" #include "testutil.h"
#ifndef OPENSSL_NO_IDEA #ifndef OPENSSL_NO_IDEA

View File

@ -12,7 +12,7 @@
#include <openssl/rand.h> #include <openssl/rand.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include "e_os.h" #include <internal/nelem.h>
#include "testutil.h" #include "testutil.h"
#define TEST_SIZE 128 #define TEST_SIZE 128

View File

@ -16,7 +16,7 @@
#include <openssl/err.h> #include <openssl/err.h>
#include <openssl/crypto.h> #include <openssl/crypto.h>
#include "e_os.h" #include <internal/nelem.h>
#include "testutil.h" #include "testutil.h"
/* /*

View File

@ -9,7 +9,7 @@
#include <string.h> #include <string.h>
#include "../e_os.h" #include <internal/nelem.h>
#include "testutil.h" #include "testutil.h"
#ifndef OPENSSL_NO_MD2 #ifndef OPENSSL_NO_MD2

View File

@ -14,7 +14,7 @@
#include <openssl/mdc2.h> #include <openssl/mdc2.h>
#include "testutil.h" #include "testutil.h"
#include "e_os.h" #include <internal/nelem.h>
typedef struct { typedef struct {
const char *input; const char *input;

View File

@ -9,7 +9,7 @@
#include <string.h> #include <string.h>
#include "../e_os.h" #include <internal/nelem.h>
#include "testutil.h" #include "testutil.h"
#if defined(OPENSSL_NO_DES) && !defined(OPENSSL_NO_MDC2) #if defined(OPENSSL_NO_DES) && !defined(OPENSSL_NO_MDC2)

View File

@ -16,7 +16,7 @@
#include <openssl/modes.h> #include <openssl/modes.h>
#include "../crypto/modes/modes_lcl.h" #include "../crypto/modes/modes_lcl.h"
#include "testutil.h" #include "testutil.h"
#include "e_os.h" #include <internal/nelem.h>
typedef struct { typedef struct {
size_t size; size_t size;

View File

@ -15,7 +15,7 @@
#include "testutil.h" #include "testutil.h"
#include "internal/poly1305.h" #include "internal/poly1305.h"
#include "../crypto/poly1305/poly1305_local.h" #include "../crypto/poly1305/poly1305_local.h"
#include "e_os.h" #include <internal/nelem.h>
typedef struct { typedef struct {
size_t size; size_t size;

View File

@ -7,7 +7,7 @@
* https://www.openssl.org/source/license.html * https://www.openssl.org/source/license.html
*/ */
#include "../e_os.h" #include <internal/nelem.h>
#include "testutil.h" #include "testutil.h"
#ifndef OPENSSL_NO_RC2 #ifndef OPENSSL_NO_RC2

View File

@ -9,7 +9,7 @@
#include <string.h> #include <string.h>
#include "../e_os.h" #include <internal/nelem.h>
#include "testutil.h" #include "testutil.h"
#ifndef OPENSSL_NO_RC4 #ifndef OPENSSL_NO_RC4

View File

@ -9,7 +9,7 @@
#include <string.h> #include <string.h>
#include "../e_os.h" #include <internal/nelem.h>
#include "testutil.h" #include "testutil.h"
#ifndef OPENSSL_NO_RC5 #ifndef OPENSSL_NO_RC5

View File

@ -12,7 +12,7 @@
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include "e_os.h" #include <internal/nelem.h>
#include <openssl/crypto.h> #include <openssl/crypto.h>
#include <openssl/err.h> #include <openssl/err.h>

View File

@ -21,7 +21,7 @@
#include "../ssl/packet_locl.h" #include "../ssl/packet_locl.h"
#include "testutil.h" #include "testutil.h"
#include "e_os.h" #include <internal/nelem.h>
#define CLIENT_VERSION_LEN 2 #define CLIENT_VERSION_LEN 2

View File

@ -16,7 +16,7 @@
#include "testutil.h" #include "testutil.h"
#include "internal/siphash.h" #include "internal/siphash.h"
#include "../crypto/siphash/siphash_local.h" #include "../crypto/siphash/siphash_local.h"
#include "e_os.h" #include <internal/nelem.h>
static BIO* b_stderr = NULL; static BIO* b_stderr = NULL;
static BIO* b_stdout = NULL; static BIO* b_stdout = NULL;

View File

@ -14,7 +14,7 @@
#include <openssl/ssl.h> #include <openssl/ssl.h>
#include "testutil.h" #include "testutil.h"
#include "e_os.h" #include <internal/nelem.h>
#ifdef __VMS #ifdef __VMS
# pragma names save # pragma names save

View File

@ -12,7 +12,7 @@
#include <openssl/e_os2.h> #include <openssl/e_os2.h>
#include <openssl/crypto.h> #include <openssl/crypto.h>
#include "e_os.h" #include <internal/nelem.h>
#include "ssl_test_ctx.h" #include "ssl_test_ctx.h"
#include "testutil.h" #include "testutil.h"

View File

@ -15,7 +15,7 @@
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include "e_os.h" #include <internal/nelem.h>
#include "ssl_test_ctx.h" #include "ssl_test_ctx.h"
#include "testutil.h" #include "testutil.h"
#include <openssl/e_os2.h> #include <openssl/e_os2.h>

View File

@ -17,7 +17,7 @@
#include "ssltestlib.h" #include "ssltestlib.h"
#include "testutil.h" #include "testutil.h"
#include "e_os.h" #include <internal/nelem.h>
#include "../ssl/ssl_locl.h" #include "../ssl/ssl_locl.h"
static char *cert = NULL; static char *cert = NULL;

View File

@ -25,6 +25,8 @@
#include <string.h> #include <string.h>
#include <time.h> #include <time.h>
#include <internal/nelem.h>
#define USE_SOCKETS #define USE_SOCKETS
#include "e_os.h" #include "e_os.h"

View File

@ -9,7 +9,7 @@
#include <string.h> #include <string.h>
#include "e_os.h" #include <internal/nelem.h>
#include "ssltestlib.h" #include "ssltestlib.h"
#include "testutil.h" #include "testutil.h"

View File

@ -16,7 +16,7 @@
#include <openssl/err.h> #include <openssl/err.h>
#include <openssl/crypto.h> #include <openssl/crypto.h>
#include "e_os.h" #include <internal/nelem.h>
#include "testutil.h" #include "testutil.h"
/* The macros below generate unused functions which error out one of the clang /* The macros below generate unused functions which error out one of the clang

View File

@ -16,7 +16,7 @@
#include <openssl/crypto.h> #include <openssl/crypto.h>
#include <openssl/bn.h> #include <openssl/bn.h>
#include "e_os.h" #include <internal/nelem.h>
#include "testutil.h" #include "testutil.h"
#define TEST(expected, test) test_case((expected), #test, (test)) #define TEST(expected, test) test_case((expected), #test, (test))

View File

@ -14,7 +14,7 @@
#include <string.h> #include <string.h>
#include <assert.h> #include <assert.h>
#include "../../e_os.h" #include <internal/nelem.h>
#include <openssl/bio.h> #include <openssl/bio.h>
/* /*

View File

@ -13,7 +13,7 @@
#include <string.h> #include <string.h>
#include <ctype.h> #include <ctype.h>
#include "../../e_os.h" #include <internal/nelem.h>
/* The size of memory buffers to display on failure */ /* The size of memory buffers to display on failure */
#define MEM_BUFFER_SIZE (2000) #define MEM_BUFFER_SIZE (2000)

View File

@ -8,7 +8,7 @@
*/ */
#include "../testutil.h" #include "../testutil.h"
#include "../../e_os.h" #include <internal/nelem.h>
#include "output.h" #include "output.h"
#include "tu_local.h" #include "tu_local.h"

View File

@ -12,7 +12,7 @@
#include <string.h> #include <string.h>
#include <ctype.h> #include <ctype.h>
#include "e_os.h" #include "internal/nelem.h"
#include "../testutil.h" #include "../testutil.h"
#include "tu_local.h" #include "tu_local.h"

View File

@ -14,7 +14,7 @@
#include <errno.h> #include <errno.h>
#include <string.h> #include <string.h>
#include <ctype.h> #include <ctype.h>
#include "../../e_os.h" #include <internal/nelem.h>
/* /*
* Output a failed test first line. * Output a failed test first line.

View File

@ -16,7 +16,7 @@
#include <openssl/asn1.h> #include <openssl/asn1.h>
#include <openssl/x509.h> #include <openssl/x509.h>
#include "testutil.h" #include "testutil.h"
#include "e_os.h" #include <internal/nelem.h>
typedef struct { typedef struct {
const char *data; const char *data;

View File

@ -8,7 +8,7 @@
*/ */
#include <string.h> #include <string.h>
#include "e_os.h" #include <internal/nelem.h>
#include <openssl/x509.h> #include <openssl/x509.h>
#include <openssl/x509v3.h> #include <openssl/x509v3.h>
#include "testutil.h" #include "testutil.h"

View File

@ -15,7 +15,7 @@
#include <openssl/x509.h> #include <openssl/x509.h>
#include <openssl/x509v3.h> #include <openssl/x509v3.h>
#include "testutil.h" #include "testutil.h"
#include "e_os.h" #include <internal/nelem.h>
/********************************************************************** /**********************************************************************
* *

View File

@ -15,7 +15,7 @@
#include <openssl/asn1.h> #include <openssl/asn1.h>
#include <openssl/x509.h> #include <openssl/x509.h>
#include "testutil.h" #include "testutil.h"
#include "e_os.h" #include <internal/nelem.h>
typedef struct { typedef struct {
const char *data; const char *data;

View File

@ -16,7 +16,7 @@
#include <openssl/pem.h> #include <openssl/pem.h>
#include <openssl/conf.h> #include <openssl/conf.h>
#include <openssl/err.h> #include <openssl/err.h>
#include "e_os.h" #include <internal/nelem.h>
#include "testutil.h" #include "testutil.h"
static int test_certs(int num) static int test_certs(int num)