Skip to contentSkip to conversation

tests/qtest/aspeed-hace-utils: Replace g_printerr() with g_test_skip()

PATCH In review Jamin Lin 3 participants 3 messages Aug 31 Arm/Aspeed machine support

lore
Share & tools
lore

Jamin Lin

author
#0 lore raw

PATCH 1/1 tests/qtest/aspeed-hace-utils: Replace g_printerr() with g_test_skip()

Skip a cipher unsupported by the crypto backend with g_test_skip() from the test, instead of not registering it and printing a TAP "# skip" line, so the qtest does not assume TAP output.

---
 tests/qtest/aspeed-hace-utils.c | 24 ++++++++++++++++--------
 1 file changed, 16 insertions(+), 8 deletions(-)
tests/qtest/aspeed-hace-utils.c +16 -8
index 260eec043c..d20562fac9 100644
@@ -1248,11 +1248,18 @@ static void aspeed_test_crypto(const void *data)
 {
     const AspeedCryptoTest *c = data;
     const CryptTest *t = &crypt_tests[c->index];
-    QTestState *s = qtest_init(c->machine);
+    QTestState *s;
     uint8_t out[64];
     uint8_t iv[16];
     size_t iv_off;
 
+    if (!qcrypto_cipher_supports(t->alg, t->mode)) {
+        g_test_skip("cipher not supported by the crypto backend");
+        return;
+    }
+
+    s = qtest_init(c->machine);
+
     g_assert_cmpuint(t->len, <=, sizeof(out));
 
     /* Encrypt: ptext -> ctext */
@@ -1284,10 +1291,17 @@ static void aspeed_test_crypto_gcm(const void *data)
 {
     const AspeedCryptoTest *c = data;
     const CryptTest *t = &crypt_tests[c->index];
-    QTestState *s = qtest_init(c->machine);
+    QTestState *s;
     uint8_t out[64];
     uint8_t tag[16];
 
+    if (!qcrypto_cipher_supports(t->alg, t->mode)) {
+        g_test_skip("cipher not supported by the crypto backend");
+        return;
+    }
+
+    s = qtest_init(c->machine);
+
     g_assert_cmpuint(t->len, <=, sizeof(out));
 
     /* Encrypt: ptext -> ctext, then check the authentication tag. */
@@ -1318,12 +1332,6 @@ void aspeed_add_crypto_tests(const char *prefix, const char *machine,
             continue;
         }
 
-        if (!qcrypto_cipher_supports(crypt_tests[i].alg,
-                                     crypt_tests[i].mode)) {
-            g_printerr("# skip unsupported %s\n", crypt_tests[i].name);
-            continue;
-        }
-
         path = g_strdup_printf("%s/hace/crypto/%s", prefix,
                                crypt_tests[i].name);
         t = g_new0(AspeedCryptoTest, 1);
Signature · 1 line
2.53.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines · Jamin Lin

Skip a cipher unsupported by the crypto backend with g_test_skip() from the test, instead of not registering it and printing a TAP "# skip" line, so the qtest does not assume TAP output.

---
  tests/qtest/aspeed-hace-utils.c | 24 ++++++++++++++++--------
  1 file changed, 16 insertions(+), 8 deletions(-)
#2 lore raw
In reply to Jamin Lin
Quoted 55 lines · Jamin Lin

Skip a cipher unsupported by the crypto backend with g_test_skip() from the test, instead of not registering it and printing a TAP "# skip" line, so the qtest does not assume TAP output.

---
  tests/qtest/aspeed-hace-utils.c | 24 ++++++++++++++++--------
  1 file changed, 16 insertions(+), 8 deletions(-)
tests/qtest/aspeed-hace-utils.c +16 -2
index 260eec043c..d20562fac9 100644
@@ -1248,11 +1248,18 @@ static void aspeed_test_crypto(const void *data)
  {
      const AspeedCryptoTest *c = data;
      const CryptTest *t = &crypt_tests[c->index];
-    QTestState *s = qtest_init(c->machine);
+    QTestState *s;
      uint8_t out[64];
      uint8_t iv[16];
      size_t iv_off;
 
+    if (!qcrypto_cipher_supports(t->alg, t->mode)) {
+        g_test_skip("cipher not supported by the crypto backend");
+        return;
+    }
+
+    s = qtest_init(c->machine);
+
      g_assert_cmpuint(t->len, <=, sizeof(out));
 
      /* Encrypt: ptext -> ctext */
@@ -1284,10 +1291,17 @@ static void aspeed_test_crypto_gcm(const void *data)
  {
      const AspeedCryptoTest *c = data;
      const CryptTest *t = &crypt_tests[c->index];
-    QTestState *s = qtest_init(c->machine);
+    QTestState *s;
      uint8_t out[64];
      uint8_t tag[16];
 
+    if (!qcrypto_cipher_supports(t->alg, t->mode)) {
+        g_test_skip("cipher not supported by the crypto backend");
+        return;
+    }
+
+    s = qtest_init(c->machine);
+
      g_assert_cmpuint(t->len, <=, sizeof(out));
 
      /* Encrypt: ptext -> ctext, then check the authentication tag. */
@@ -1318,12 +1332,6 @@ void aspeed_add_crypto_tests(const char *prefix, const char *machine,
              continue;
          }

tests/qtest/aspeed-hace-utils.c void aspeed_add_crypto_tests(const char *prefix, const char *machine, · line 1337

Quoted 10 lines
tests/qtest/aspeed-hace-utils.c +0 -6
 
-        if (!qcrypto_cipher_supports(crypt_tests[i].alg,
-                                     crypt_tests[i].mode)) {
-            g_printerr("# skip unsupported %s\n", crypt_tests[i].name);
-            continue;
-        }
-
          path = g_strdup_printf("%s/hace/crypto/%s", prefix,
                                 crypt_tests[i].name);
          t = g_new0(AspeedCryptoTest, 1);

Applied to

https://github.com/legoater/qemu aspeed-next

Thanks,

C.