]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
crypto: validate an error is reported in test expected fails
authorDaniel P. Berrangé <berrange@redhat.com>
Mon, 20 Oct 2025 14:04:39 +0000 (15:04 +0100)
committerDaniel P. Berrangé <berrange@redhat.com>
Fri, 24 Oct 2025 12:06:05 +0000 (13:06 +0100)
There was a bug where TLS x509 credentials validation failed
to fill out the Error object. Validate this in the failure
scenarios.

Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
tests/unit/test-crypto-tlscredsx509.c

index a7ea5f422d535e644e0ef9a0b7562d6c9d92fb1b..85f51aee1b517e06fb18c1133e163142b120a928 100644 (file)
@@ -73,6 +73,7 @@ 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/"
     g_mkdir_with_parents(CERT_DIR, 0700);
@@ -111,10 +112,12 @@ static void test_tls_creds(const void *opaque)
          QCRYPTO_TLS_CREDS_ENDPOINT_SERVER :
          QCRYPTO_TLS_CREDS_ENDPOINT_CLIENT),
         CERT_DIR,
-        data->expectFail ? NULL : &error_abort);
+        data->expectFail ? &err : &error_abort);
 
     if (data->expectFail) {
         g_assert(creds == NULL);
+        g_assert(err != NULL);
+        error_free(err);
     } else {
         g_assert(creds != NULL);
     }