qt: Handle if gpg does not support tofu in test

* lang/qt/src/t-tofuinfo.cpp (TestTofuInfo::testSupported): Treat
it as unsupported if secret keylisting already fails.

--
The likely cause of this is that the agent can't be started
because the trust model is unsupported. Other tests check
that keylisting actually works.
This commit is contained in:
Andre Heinecke 2017-03-30 14:36:49 +02:00
parent 9786e3a96e
commit 2c063a8d60
No known key found for this signature in database
GPG Key ID: 2978E9D40CBABA5C

View File

@ -118,7 +118,24 @@ Q_SIGNALS:
private: private:
bool testSupported() bool testSupported()
{ {
return !(GpgME::engineInfo(GpgME::GpgEngine).engineVersion() < "2.1.16"); static bool initialized, supported;
if (initialized) {
return supported;
}
initialized = true;
if (GpgME::engineInfo(GpgME::GpgEngine).engineVersion() < "2.1.16") {
return false;
}
// If the keylist fails here this means that gnupg does not
// support tofu at all. It can be disabled at compile time. So no
// tests.
auto *job = openpgp()->keyListJob(false, false, false);
job->addMode(GpgME::WithTofu);
std::vector<GpgME::Key> keys;
job->exec(QStringList() << QStringLiteral("zulu@example.net"), true, keys);
delete job;
supported = !keys.empty();
return supported;
} }
void testTofuCopy(TofuInfo other, const TofuInfo &orig) void testTofuCopy(TofuInfo other, const TofuInfo &orig)
@ -402,6 +419,10 @@ private Q_SLOTS:
void testTofuConflict() void testTofuConflict()
{ {
if (!testSupported()) {
return;
}
if (GpgME::engineInfo(GpgME::GpgEngine).engineVersion() < "2.1.19") { if (GpgME::engineInfo(GpgME::GpgEngine).engineVersion() < "2.1.19") {
return; return;
} }