forked from wolfSSL/wolfssl
add enable-valgrind
This commit is contained in:
@ -53,6 +53,10 @@ include tests/include.am
|
|||||||
include sslSniffer/sslSnifferTest/include.am
|
include sslSniffer/sslSnifferTest/include.am
|
||||||
include rpm/include.am
|
include rpm/include.am
|
||||||
|
|
||||||
|
if USE_VALGRIND
|
||||||
|
TESTS_ENVIRONMENT=./valgrind-error.sh
|
||||||
|
endif
|
||||||
|
|
||||||
TESTS += $(check_PROGRAMS)
|
TESTS += $(check_PROGRAMS)
|
||||||
test: check
|
test: check
|
||||||
|
|
||||||
|
20
configure.ac
20
configure.ac
@ -649,6 +649,26 @@ then
|
|||||||
fi
|
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
|
# Test certs, use internal cert functions for extra testing
|
||||||
AC_ARG_ENABLE(testcert,
|
AC_ARG_ENABLE(testcert,
|
||||||
[ --enable-testcert Enable Test Cert (default: disabled)],
|
[ --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 dynamic = 0;
|
||||||
int ret;
|
int ret;
|
||||||
long sz = 0;
|
long sz = 0;
|
||||||
XFILE file = XFOPEN(fname, "rb");
|
XFILE file;
|
||||||
|
void* heapHint = ctx ? ctx->heap : NULL;
|
||||||
|
|
||||||
(void)crl;
|
(void)crl;
|
||||||
|
(void)heapHint;
|
||||||
|
|
||||||
|
if (fname == NULL) return SSL_BAD_FILE;
|
||||||
|
|
||||||
|
file = XFOPEN(fname, "rb");
|
||||||
if (file == XBADFILE) return SSL_BAD_FILE;
|
if (file == XBADFILE) return SSL_BAD_FILE;
|
||||||
XFSEEK(file, 0, XSEEK_END);
|
XFSEEK(file, 0, XSEEK_END);
|
||||||
sz = XFTELL(file);
|
sz = XFTELL(file);
|
||||||
@ -1492,7 +1497,7 @@ int ProcessFile(CYASSL_CTX* ctx, const char* fname, int format, int type,
|
|||||||
|
|
||||||
if (sz > (long)sizeof(staticBuffer)) {
|
if (sz > (long)sizeof(staticBuffer)) {
|
||||||
CYASSL_MSG("Getting dynamic buffer");
|
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) {
|
if (myBuffer == NULL) {
|
||||||
XFCLOSE(file);
|
XFCLOSE(file);
|
||||||
return SSL_BAD_FILE;
|
return SSL_BAD_FILE;
|
||||||
@ -1515,7 +1520,7 @@ int ProcessFile(CYASSL_CTX* ctx, const char* fname, int format, int type,
|
|||||||
}
|
}
|
||||||
|
|
||||||
XFCLOSE(file);
|
XFCLOSE(file);
|
||||||
if (dynamic) XFREE(myBuffer, ctx->heap, DYNAMIC_TYPE_FILE);
|
if (dynamic) XFREE(myBuffer, heapHint, DYNAMIC_TYPE_FILE);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -744,6 +744,10 @@ void test_client_nofail(void* args)
|
|||||||
printf("Server response: %s\n", reply);
|
printf("Server response: %s\n", reply);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CyaSSL_free(ssl);
|
||||||
|
CyaSSL_CTX_free(ctx);
|
||||||
|
|
||||||
|
CloseSocket(sockfd);
|
||||||
((func_args*)args)->return_code = TEST_SUCCESS;
|
((func_args*)args)->return_code = TEST_SUCCESS;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
22
valgrind-error.sh
Executable file
22
valgrind-error.sh
Executable file
@ -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
|
||||||
|
|
Reference in New Issue
Block a user