diff --git a/lang/qt/tests/t-addexistingsubkey.cpp b/lang/qt/tests/t-addexistingsubkey.cpp index 87eadf43..c0eee57b 100644 --- a/lang/qt/tests/t-addexistingsubkey.cpp +++ b/lang/qt/tests/t-addexistingsubkey.cpp @@ -213,24 +213,30 @@ private Q_SLOTS: const auto result = job->exec(key, sourceSubkey); - QCOMPARE(result.code(), static_cast(GPG_ERR_NO_ERROR)); - key.update(); - QCOMPARE(key.numSubkeys(), 3u); + if (sourceSubkey.expirationTime() > 0) { + QCOMPARE(result.code(), static_cast(GPG_ERR_NO_ERROR)); + key.update(); + QCOMPARE(key.numSubkeys(), 3u); - // allow 1 second different expiration because gpg calculates with - // expiration as difference to current time and takes current time - // several times - const auto allowedDeltaTSeconds = 1; - const auto expectedExpirationRange = std::make_pair( - uint_least32_t(sourceSubkey.expirationTime()) - allowedDeltaTSeconds, - uint_least32_t(sourceSubkey.expirationTime()) + allowedDeltaTSeconds); - const auto actualExpiration = uint_least32_t(key.subkey(2).expirationTime()); - QVERIFY2(actualExpiration >= expectedExpirationRange.first, - ("actual: " + std::to_string(actualExpiration) + - "; expected: " + std::to_string(expectedExpirationRange.first)).c_str()); - QVERIFY2(actualExpiration <= expectedExpirationRange.second, - ("actual: " + std::to_string(actualExpiration) + - "; expected: " + std::to_string(expectedExpirationRange.second)).c_str()); + // allow 1 second different expiration because gpg calculates with + // expiration as difference to current time and takes current time + // several times + const auto allowedDeltaTSeconds = 1; + const auto expectedExpirationRange = std::make_pair( + uint_least32_t(sourceSubkey.expirationTime()) - allowedDeltaTSeconds, + uint_least32_t(sourceSubkey.expirationTime()) + allowedDeltaTSeconds); + const auto actualExpiration = uint_least32_t(key.subkey(2).expirationTime()); + QVERIFY2(actualExpiration >= expectedExpirationRange.first, + ("actual: " + std::to_string(actualExpiration) + + "; expected: " + std::to_string(expectedExpirationRange.first)).c_str()); + QVERIFY2(actualExpiration <= expectedExpirationRange.second, + ("actual: " + std::to_string(actualExpiration) + + "; expected: " + std::to_string(expectedExpirationRange.second)).c_str()); + } else { + // on 32-bit systems the expiration date of the test key overflows; + // in this case we expect an appropriate error code + QCOMPARE(result.code(), static_cast(GPG_ERR_INV_TIME)); + } } private: