diff options
author | Marc Mutz <marc.mutz@qt.io> | 2023-03-22 15:07:46 +0100 |
---|---|---|
committer | Marc Mutz <marc.mutz@qt.io> | 2023-03-31 10:32:45 +0100 |
commit | f1b264f9ac05205f6134d984c221af5ad8b3ba81 (patch) | |
tree | 0a36721ca564d35051c28d94cf540e523e1b13f6 | |
parent | 3aaae083f7cbe3fbe7260081bbdccb544b60d7ba (diff) |
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 <fabian.kosmale@qt.io>
-rw-r--r-- | tests/benchmarks/corelib/tools/qcryptographichash/tst_bench_qcryptographichash.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/benchmarks/corelib/tools/qcryptographichash/tst_bench_qcryptographichash.cpp b/tests/benchmarks/corelib/tools/qcryptographichash/tst_bench_qcryptographichash.cpp index 571e805ceb..350474aa90 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) |