Mercurial > hg > freeDiameter
changeset 793:ada5366bca4e
allow gnutls debug in tests
author | Sebastien Decugis <sdecugis@nict.go.jp> |
---|---|
date | Sat, 14 Jul 2012 10:28:43 +0200 |
parents | 0f566e550813 |
children | 004bd7272b9f |
files | tests/tests.h |
diffstat | 1 files changed, 18 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/tests/tests.h Thu Jul 12 22:37:32 2012 +0200 +++ b/tests/tests.h Sat Jul 14 10:28:43 2012 +0200 @@ -129,10 +129,17 @@ GCRY_THREAD_OPTION_PTHREAD_IMPL; +/* gnutls debug */ +static void fd_gnutls_debug(int level, const char * str) { + fd_log_debug(" [gnutls:%d] %s", level, str); +} +static int gnutls_debug = 0; + + static inline void parse_cmdline(int argc, char * argv[]) { int c; int no_timeout = 0; - while ((c = getopt (argc, argv, "dqnf:F:")) != -1) { + while ((c = getopt (argc, argv, "dqnf:F:g:")) != -1) { switch (c) { case 'd': /* Increase verbosity of debug messages. */ test_verbo++; @@ -162,6 +169,10 @@ #endif /* DEBUG */ break; + case 'g': /* Set a debug level and function for GNU TLS calls. */ + gnutls_debug = (int)atoi(optarg); + break; + default: /* bug: option not considered. */ return; } @@ -193,6 +204,12 @@ (void) gcry_control (GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread); (void) gcry_control (GCRYCTL_ENABLE_QUICK_RANDOM, 0); CHECK( 0, gnutls_global_init()); + /* Set gnutls debug level ? */ + if (gnutls_debug) { + gnutls_global_set_log_function((gnutls_log_func)fd_gnutls_debug); + gnutls_global_set_log_level (gnutls_debug); + TRACE_DEBUG(INFO, "Enabled GNUTLS debug at level %d", gnutls_debug); + } /* Initialize the config */ CHECK( 0, fd_conf_init() );