mirror of https://github.com/wolfSSL/wolfssl.git
add enable-valgrind
parent
9005d2b54b
commit
067f10ae8e
|
@ -53,6 +53,10 @@ include tests/include.am
|
|||
include sslSniffer/sslSnifferTest/include.am
|
||||
include rpm/include.am
|
||||
|
||||
if USE_VALGRIND
|
||||
TESTS_ENVIRONMENT=./valgrind-error.sh
|
||||
endif
|
||||
|
||||
TESTS += $(check_PROGRAMS)
|
||||
test: check
|
||||
|
||||
|
|
20
configure.ac
20
configure.ac
|
@ -649,6 +649,26 @@ then
|
|||
fi
|
||||
|
||||
|
||||
#valgrind
|
||||
AC_ARG_ENABLE(valgrind,
|
||||
[ --enable-valgrind Enable valgrind for unit tests (default: disabled)],
|
||||
[ ENABLED_VALGRIND=$enableval ],
|
||||
[ ENABLED_VALGRIND=no ]
|
||||
)
|
||||
|
||||
if test "$ENABLED_VALGRIND" = "yes"
|
||||
then
|
||||
AC_CHECK_PROG(HAVE_VALGRIND,valgrind,yes,no)
|
||||
|
||||
if [["$HAVE_VALGRIND" = "no" ]]; then
|
||||
AC_MSG_ERROR([Valgrind not found.])
|
||||
fi
|
||||
enable_shared=no
|
||||
fi
|
||||
|
||||
AM_CONDITIONAL([USE_VALGRIND], [test "x$ENABLED_VALGRIND" = "xyes"])
|
||||
|
||||
|
||||
# Test certs, use internal cert functions for extra testing
|
||||
AC_ARG_ENABLE(testcert,
|
||||
[ --enable-testcert Enable Test Cert (default: disabled)],
|
||||
|
|
11
src/ssl.c
11
src/ssl.c
|
@ -1481,10 +1481,15 @@ int ProcessFile(CYASSL_CTX* ctx, const char* fname, int format, int type,
|
|||
int dynamic = 0;
|
||||
int ret;
|
||||
long sz = 0;
|
||||
XFILE file = XFOPEN(fname, "rb");
|
||||
XFILE file;
|
||||
void* heapHint = ctx ? ctx->heap : NULL;
|
||||
|
||||
(void)crl;
|
||||
(void)heapHint;
|
||||
|
||||
if (fname == NULL) return SSL_BAD_FILE;
|
||||
|
||||
file = XFOPEN(fname, "rb");
|
||||
if (file == XBADFILE) return SSL_BAD_FILE;
|
||||
XFSEEK(file, 0, XSEEK_END);
|
||||
sz = XFTELL(file);
|
||||
|
@ -1492,7 +1497,7 @@ int ProcessFile(CYASSL_CTX* ctx, const char* fname, int format, int type,
|
|||
|
||||
if (sz > (long)sizeof(staticBuffer)) {
|
||||
CYASSL_MSG("Getting dynamic buffer");
|
||||
myBuffer = (byte*) XMALLOC(sz, ctx->heap, DYNAMIC_TYPE_FILE);
|
||||
myBuffer = (byte*)XMALLOC(sz, heapHint, DYNAMIC_TYPE_FILE);
|
||||
if (myBuffer == NULL) {
|
||||
XFCLOSE(file);
|
||||
return SSL_BAD_FILE;
|
||||
|
@ -1515,7 +1520,7 @@ int ProcessFile(CYASSL_CTX* ctx, const char* fname, int format, int type,
|
|||
}
|
||||
|
||||
XFCLOSE(file);
|
||||
if (dynamic) XFREE(myBuffer, ctx->heap, DYNAMIC_TYPE_FILE);
|
||||
if (dynamic) XFREE(myBuffer, heapHint, DYNAMIC_TYPE_FILE);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -744,6 +744,10 @@ void test_client_nofail(void* args)
|
|||
printf("Server response: %s\n", reply);
|
||||
}
|
||||
|
||||
CyaSSL_free(ssl);
|
||||
CyaSSL_CTX_free(ctx);
|
||||
|
||||
CloseSocket(sockfd);
|
||||
((func_args*)args)->return_code = TEST_SUCCESS;
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
#
|
||||
# Our valgrind "error" wrapper.
|
||||
|
||||
valgrind --leak-check=full -q "$@" 2> valgrind.tmp
|
||||
|
||||
result="$?"
|
||||
|
||||
# verify no errors
|
||||
|
||||
output="`cat valgrind.tmp`"
|
||||
|
||||
if [ "$output" != "" ]; then
|
||||
cat valgrind.tmp >&2
|
||||
result=1
|
||||
fi
|
||||
|
||||
rm valgrind.tmp
|
||||
|
||||
exit $result
|
||||
|
Loading…
Reference in New Issue