From: Nikos Mavrogiannopoulos Date: Sat, 30 Nov 2013 18:24:24 +0000 (+0100) Subject: fix self tests when used from slow/cipher-test X-Git-Tag: gnutls_3_3_0pre0~511 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=20ecbe306642a0d2bfe3052ccd15a1c68d642c56;p=thirdparty%2Fgnutls.git fix self tests when used from slow/cipher-test --- diff --git a/lib/crypto-selftests-pk.c b/lib/crypto-selftests-pk.c index 4845cd3741..143ba16399 100644 --- a/lib/crypto-selftests-pk.c +++ b/lib/crypto-selftests-pk.c @@ -417,6 +417,9 @@ static int test_known_sig(gnutls_pk_algorithm_t pk, unsigned bits, return 0 +/* This file is also included by the test app in tests/slow/cipher-test, so in that + * case we cannot depend on gnutls internals */ +#ifndef AVOID_INTERNALS /* Known answer tests for DH */ static int test_dh(void) { @@ -605,6 +608,7 @@ cleanup: return ret; } +#endif /** * gnutls_pk_self_test: @@ -628,6 +632,7 @@ int gnutls_pk_self_test(unsigned all, gnutls_pk_algorithm_t pk) case GNUTLS_PK_UNKNOWN: case GNUTLS_PK_DH: +#ifndef AVOID_INTERNALS ret = test_dh(); if (ret < 0) { gnutls_assert(); @@ -636,7 +641,7 @@ int gnutls_pk_self_test(unsigned all, gnutls_pk_algorithm_t pk) if (all == 0) return 0; - +#endif case GNUTLS_PK_RSA: PK_KNOWN_TEST(GNUTLS_PK_RSA, 1, 512, GNUTLS_DIG_SHA1, rsa_privkey, rsa_sig); @@ -648,6 +653,7 @@ int gnutls_pk_self_test(unsigned all, gnutls_pk_algorithm_t pk) PK_TEST(GNUTLS_PK_DSA, test_sig, 1024, GNUTLS_DIG_SHA1); case GNUTLS_PK_EC: /* Testing ECDSA */ /* Test ECDH */ +#ifndef AVOID_INTERNALS ret = test_ecdh(); if (ret < 0) { gnutls_assert(); @@ -656,6 +662,7 @@ int gnutls_pk_self_test(unsigned all, gnutls_pk_algorithm_t pk) if (all == 0) return 0; +#endif /* Test ECDSA */ #ifdef ENABLE_NON_SUITEB_CURVES diff --git a/tests/slow/cipher-test.c b/tests/slow/cipher-test.c index 129a7b129b..898a05ab94 100644 --- a/tests/slow/cipher-test.c +++ b/tests/slow/cipher-test.c @@ -18,8 +18,9 @@ static void tls_log_func(int level, const char *str) } #ifndef ENABLE_SELF_CHECKS -#include "../../lib/crypto-selftests.c" -#include "../../lib/crypto-selftests-pk.c" +# define AVOID_INTERNALS +# include "../../lib/crypto-selftests.c" +# include "../../lib/crypto-selftests-pk.c" #endif int main(int argc, char **argv)