From d1f144d6fe28914b1dbb7a24009a10f6ed04e61e Mon Sep 17 00:00:00 2001 From: Eric Blake Date: Fri, 22 Jul 2011 14:10:39 -0600 Subject: [PATCH] tests: detect gnutls errors * tests/virnettlscontexttest.c (testTLSLoadKey): Report errors. --- tests/virnettlscontexttest.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tests/virnettlscontexttest.c b/tests/virnettlscontexttest.c index e70cd8be1d..043ccc29c8 100644 --- a/tests/virnettlscontexttest.c +++ b/tests/virnettlscontexttest.c @@ -410,10 +410,18 @@ static gnutls_x509_privkey_t testTLSLoadKey(void) { gnutls_x509_privkey_t key; const gnutls_datum_t data = { (unsigned char *)PRIVATE_KEY, strlen(PRIVATE_KEY) }; + int err; - gnutls_x509_privkey_init(&key); + if ((err = gnutls_x509_privkey_init(&key)) < 0) { + VIR_WARN("Failed to init key %s", gnutls_strerror(err)); + abort(); + } - gnutls_x509_privkey_import(key, &data, GNUTLS_X509_FMT_PEM); + if ((err = gnutls_x509_privkey_import(key, &data, + GNUTLS_X509_FMT_PEM)) < 0) { + VIR_WARN("Failed to init key %s", gnutls_strerror(err)); + abort(); + } return key; } -- GitLab