Mercurial > trustbridge
comparison ui/tests/nsstest.cpp @ 524:a097dd86cb4d
merged.
author | Raimund Renkert <rrenkert@intevation.de> |
---|---|
date | Tue, 29 Apr 2014 15:26:43 +0200 |
parents | dcb014e7d32f |
children | c262ee333c56 |
comparison
equal
deleted
inserted
replaced
523:ca583ffe728a | 524:a097dd86cb4d |
---|---|
87 QVERIFY(validList.isValid()); | 87 QVERIFY(validList.isValid()); |
88 | 88 |
89 /* Create the profiles.ini `s set environment variables*/ | 89 /* Create the profiles.ini `s set environment variables*/ |
90 // fakeHome.setAutoRemove(false); | 90 // fakeHome.setAutoRemove(false); |
91 #ifndef WIN32 | 91 #ifndef WIN32 |
92 QVERIFY(!setenv ("HOME", fakeHome.path().toLocal8Bit().constData(), 1)); | |
93 fakeFirefoxDir = QDir(fakeHome.path() + "/.mozilla/firefox"); | 92 fakeFirefoxDir = QDir(fakeHome.path() + "/.mozilla/firefox"); |
94 fakeThunderbirdDir = QDir(fakeHome.path() + "/.thunderbird"); | 93 fakeThunderbirdDir = QDir(fakeHome.path() + "/.thunderbird"); |
94 | |
95 /* Copy the current systems NSSSHARED db in the fake home for benchmark tests */ | |
96 QDir fakeNSSSharedDir = fakeHome.path() + "/.pki/nssdb"; | |
97 QVERIFY(fakeNSSSharedDir.mkpath(fakeNSSSharedDir.path())); | |
98 qDebug() << "Copying: " << QDir::homePath() + "/.pki/nssdb/cert9.db" << | |
99 " to " << fakeNSSSharedDir.path() + "cert9.db"; | |
100 QVERIFY(QFile::copy(QDir::homePath() + "/.pki/nssdb/cert9.db", | |
101 fakeNSSSharedDir.path() + "cert9.db")); | |
102 QVERIFY(QFile::copy(QDir::homePath() + "/.pki/nssdb/key4.db", | |
103 fakeNSSSharedDir.path() + "key4.db")); | |
104 QVERIFY(QFile::copy(QDir::homePath() + "/.pki/nssdb/pkcs11.txt", | |
105 fakeNSSSharedDir.path() + "pkcs11.txt")); | |
106 | |
107 QVERIFY(!setenv ("HOME", fakeHome.path().toLocal8Bit().constData(), 1)); | |
95 #else | 108 #else |
96 { | 109 { |
97 char buf[fakeHome.path().toLocal8Bit().size() + 9]; | 110 char buf[fakeHome.path().toLocal8Bit().size() + 9]; |
98 snprintf(buf, fakeHome.path().toLocal8Bit().size() + 9, | 111 snprintf(buf, fakeHome.path().toLocal8Bit().size() + 9, |
99 "APPDATA=%s",fakeHome.path().toLocal8Bit().constData()); | 112 "APPDATA=%s",fakeHome.path().toLocal8Bit().constData()); |
223 | 236 |
224 QVERIFY(installedCertsTB.size() == 0); | 237 QVERIFY(installedCertsTB.size() == 0); |
225 } | 238 } |
226 } | 239 } |
227 | 240 |
241 void NSSTest::benchmarkInstall() | |
242 { | |
243 char ** to_install = NULL, | |
244 ** to_remove = NULL; | |
245 | |
246 QList<Certificate> instList; | |
247 | |
248 /* Install all certificates */ | |
249 foreach (const Certificate &cert, validList.getCertificates()) { | |
250 if (!cert.isInstallCert()) | |
251 continue; | |
252 instList << cert; | |
253 strv_append (&to_install, cert.base64Line().toLatin1().constData() + 2, | |
254 cert.base64Line().size() - 2); | |
255 } | |
256 QVERIFY((size_t) instList.size() == strv_length(to_install)); | |
257 QVERIFY(strv_length(to_install) != 0); | |
258 | |
259 QBENCHMARK { | |
260 write_stores_nss(to_install, to_remove); | |
261 } | |
262 } | |
228 QTEST_GUILESS_MAIN (NSSTest); | 263 QTEST_GUILESS_MAIN (NSSTest); |