[PATCH v3 3/7] crypto: validate an error is reported in test expected fails

Daniel P. Berrangé posted 7 patches 3 weeks, 4 days ago
Maintainers: "Daniel P. Berrangé" <berrange@redhat.com>
[PATCH v3 3/7] crypto: validate an error is reported in test expected fails
Posted by Daniel P. Berrangé 3 weeks, 4 days ago
There was a bug where TLS x509 credentials validation failed
to fill out the Error object. Validate this in the failure
scenarios.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
---
 tests/unit/test-crypto-tlscredsx509.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/tests/unit/test-crypto-tlscredsx509.c b/tests/unit/test-crypto-tlscredsx509.c
index a7ea5f422d..85f51aee1b 100644
--- a/tests/unit/test-crypto-tlscredsx509.c
+++ b/tests/unit/test-crypto-tlscredsx509.c
@@ -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);
     }
-- 
2.50.1


Re: [PATCH v3 3/7] crypto: validate an error is reported in test expected fails
Posted by Philippe Mathieu-Daudé 3 weeks, 3 days ago
On 20/10/25 16:12, Daniel P. Berrangé wrote:
> There was a bug where TLS x509 credentials validation failed
> to fill out the Error object. Validate this in the failure
> scenarios.
> 
> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
> ---
>   tests/unit/test-crypto-tlscredsx509.c | 5 ++++-
>   1 file changed, 4 insertions(+), 1 deletion(-)

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>


Re: [PATCH v3 3/7] crypto: validate an error is reported in test expected fails
Posted by Eric Blake 3 weeks, 3 days ago
On Mon, Oct 20, 2025 at 03:12:33PM +0100, Daniel P. Berrangé wrote:
> There was a bug where TLS x509 credentials validation failed
> to fill out the Error object. Validate this in the failure
> scenarios.
> 
> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
> ---
>  tests/unit/test-crypto-tlscredsx509.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 

Reviewed-by: Eric Blake <eblake@redhat.com>

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.
Virtualization:  qemu.org | libguestfs.org