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)