diff 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
line wrap: on
line diff
--- a/ui/tests/nsstest.cpp	Tue Apr 29 15:26:02 2014 +0200
+++ b/ui/tests/nsstest.cpp	Tue Apr 29 15:26:43 2014 +0200
@@ -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);

http://wald.intevation.org/projects/trustbridge/