From f1b264f9ac05205f6134d984c221af5ad8b3ba81 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Wed, 22 Mar 2023 15:07:46 +0100 Subject: [PATCH] tst_bench_QCryptographicHash: QSKIP unsupported algorithms With the OpenSSL 3 backend, some algorithms may not be available. Skip benchmarking them. Pick-to: 6.5 Change-Id: I1275332993fe15c007410e25acf59f5e3ec27894 Reviewed-by: Fabian Kosmale --- .../tst_bench_qcryptographichash.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tests/benchmarks/corelib/tools/qcryptographichash/tst_bench_qcryptographichash.cpp b/tests/benchmarks/corelib/tools/qcryptographichash/tst_bench_qcryptographichash.cpp index 571e805cebf..350474aa90d 100644 --- a/tests/benchmarks/corelib/tools/qcryptographichash/tst_bench_qcryptographichash.cpp +++ b/tests/benchmarks/corelib/tools/qcryptographichash/tst_bench_qcryptographichash.cpp @@ -87,11 +87,19 @@ void tst_QCryptographicHash::hash_data() } } +#define SKIP_IF_NOT_SUPPORTED(algo) do { \ + if (!QCryptographicHash::supportsAlgorithm(algo)) \ + QSKIP("This algorithm is not supported in this configuration"); \ + } while (false) \ + /* end */ + void tst_QCryptographicHash::hash() { QFETCH(const Algorithm, algo); QFETCH(QByteArray, data); + SKIP_IF_NOT_SUPPORTED(algo); + QBENCHMARK { [[maybe_unused]] auto r = QCryptographicHash::hash(data, algo); @@ -103,6 +111,8 @@ void tst_QCryptographicHash::addData() QFETCH(const Algorithm, algo); QFETCH(QByteArray, data); + SKIP_IF_NOT_SUPPORTED(algo); + QCryptographicHash hash(algo); QBENCHMARK { hash.reset(); @@ -117,6 +127,8 @@ void tst_QCryptographicHash::addDataChunked() QFETCH(const Algorithm, algo); QFETCH(QByteArray, data); + SKIP_IF_NOT_SUPPORTED(algo); + QCryptographicHash hash(algo); QBENCHMARK { hash.reset(); @@ -145,6 +157,8 @@ void tst_QCryptographicHash::hmac_hash() QFETCH(const Algorithm, algo); QFETCH(const QByteArray, data); + SKIP_IF_NOT_SUPPORTED(algo); + const auto key = hmacKey(); QBENCHMARK { [[maybe_unused]] @@ -157,6 +171,8 @@ void tst_QCryptographicHash::hmac_addData() QFETCH(const Algorithm, algo); QFETCH(const QByteArray, data); + SKIP_IF_NOT_SUPPORTED(algo); + const auto key = hmacKey(); QMessageAuthenticationCode mac(algo, key); QBENCHMARK { @@ -181,6 +197,8 @@ void tst_QCryptographicHash::hmac_setKey() { QFETCH(const Algorithm, algo); + SKIP_IF_NOT_SUPPORTED(algo); + const QByteArrayList keys = [] { QByteArrayList result; const auto fullKey = hmacKey(); @@ -199,6 +217,7 @@ void tst_QCryptographicHash::hmac_setKey() } } +#undef SKIP_IF_NOT_SUPPORTED QTEST_APPLESS_MAIN(tst_QCryptographicHash)