aboutsummaryrefslogtreecommitdiff
path: root/tests/test-crypto-tlscredsx509.c
diff options
context:
space:
mode:
authorDaniel P. Berrangé <berrange@redhat.com>2018-07-18 10:06:43 +0100
committerDaniel P. Berrangé <berrange@redhat.com>2018-07-24 17:35:57 +0100
commit68db13183f2d3193476f5d5457c47fa10ba0f9e3 (patch)
tree06e568c5182064e52ceac4f2b44370876e240085 /tests/test-crypto-tlscredsx509.c
parent977a7204ab69a3591c4c6ed698abb8a6ee673679 (diff)
tests: use error_abort in places expecting errors
Most of the TLS related tests are passing an in a "Error" object to methods that are expected to fail, but then ignoring any error that is set and instead asserting on a return value. This means that when an error is unexpectedly raised, no information about it is printed out, making failures hard to diagnose. Changing these tests to pass in &error_abort will make unexpected failures print messages to stderr. Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Diffstat (limited to 'tests/test-crypto-tlscredsx509.c')
-rw-r--r--tests/test-crypto-tlscredsx509.c11
1 files changed, 2 insertions, 9 deletions
diff --git a/tests/test-crypto-tlscredsx509.c b/tests/test-crypto-tlscredsx509.c
index af2f80e89c..30f9ac4bbf 100644
--- a/tests/test-crypto-tlscredsx509.c
+++ b/tests/test-crypto-tlscredsx509.c
@@ -54,7 +54,7 @@ static QCryptoTLSCreds *test_tls_creds_create(QCryptoTLSCredsEndpoint endpoint,
"sanity-check", "yes",
NULL);
- if (*errp) {
+ if (!creds) {
return NULL;
}
return QCRYPTO_TLS_CREDS(creds);
@@ -74,7 +74,6 @@ static void test_tls_creds(const void *opaque)
struct QCryptoTLSCredsTestData *data =
(struct QCryptoTLSCredsTestData *)opaque;
QCryptoTLSCreds *creds;
- Error *err = NULL;
#define CERT_DIR "tests/test-crypto-tlscredsx509-certs/"
mkdir(CERT_DIR, 0700);
@@ -113,17 +112,11 @@ static void test_tls_creds(const void *opaque)
QCRYPTO_TLS_CREDS_ENDPOINT_SERVER :
QCRYPTO_TLS_CREDS_ENDPOINT_CLIENT),
CERT_DIR,
- &err);
+ data->expectFail ? NULL : &error_abort);
if (data->expectFail) {
- error_free(err);
g_assert(creds == NULL);
} else {
- if (err) {
- g_printerr("Failed to generate creds: %s\n",
- error_get_pretty(err));
- error_free(err);
- }
g_assert(creds != NULL);
}