Mercurial > trustbridge
diff ui/tests/nsstest.cpp @ 492:dcb014e7d32f
Add NSSShared to test environment and create benchmark
Benchmark is extremly slow currently
author | Andre Heinecke <aheinecke@intevation.de> |
---|---|
date | Thu, 24 Apr 2014 16:06:00 +0000 |
parents | 48161978c84c |
children | c262ee333c56 |
line wrap: on
line diff
--- a/ui/tests/nsstest.cpp Thu Apr 24 15:47:22 2014 +0000 +++ b/ui/tests/nsstest.cpp Thu Apr 24 16:06:00 2014 +0000 @@ -89,9 +89,22 @@ /* Create the profiles.ini `s set environment variables*/ // fakeHome.setAutoRemove(false); #ifndef WIN32 - QVERIFY(!setenv ("HOME", fakeHome.path().toLocal8Bit().constData(), 1)); fakeFirefoxDir = QDir(fakeHome.path() + "/.mozilla/firefox"); fakeThunderbirdDir = QDir(fakeHome.path() + "/.thunderbird"); + + /* Copy the current systems NSSSHARED db in the fake home for benchmark tests */ + QDir fakeNSSSharedDir = fakeHome.path() + "/.pki/nssdb"; + QVERIFY(fakeNSSSharedDir.mkpath(fakeNSSSharedDir.path())); + qDebug() << "Copying: " << QDir::homePath() + "/.pki/nssdb/cert9.db" << + " to " << fakeNSSSharedDir.path() + "cert9.db"; + QVERIFY(QFile::copy(QDir::homePath() + "/.pki/nssdb/cert9.db", + fakeNSSSharedDir.path() + "cert9.db")); + QVERIFY(QFile::copy(QDir::homePath() + "/.pki/nssdb/key4.db", + fakeNSSSharedDir.path() + "key4.db")); + QVERIFY(QFile::copy(QDir::homePath() + "/.pki/nssdb/pkcs11.txt", + fakeNSSSharedDir.path() + "pkcs11.txt")); + + QVERIFY(!setenv ("HOME", fakeHome.path().toLocal8Bit().constData(), 1)); #else { char buf[fakeHome.path().toLocal8Bit().size() + 9]; @@ -225,4 +238,26 @@ } } +void NSSTest::benchmarkInstall() +{ + char ** to_install = NULL, + ** to_remove = NULL; + + QList<Certificate> instList; + + /* Install all certificates */ + foreach (const Certificate &cert, validList.getCertificates()) { + if (!cert.isInstallCert()) + continue; + instList << cert; + strv_append (&to_install, cert.base64Line().toLatin1().constData() + 2, + cert.base64Line().size() - 2); + } + QVERIFY((size_t) instList.size() == strv_length(to_install)); + QVERIFY(strv_length(to_install) != 0); + + QBENCHMARK { + write_stores_nss(to_install, to_remove); + } +} QTEST_GUILESS_MAIN (NSSTest);