changeset 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 810983b27a53
children 48d7b956bd98
files ui/tests/nsstest.cpp ui/tests/nsstest.h
diffstat 2 files changed, 37 insertions(+), 1 deletions(-) [+]
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);
--- a/ui/tests/nsstest.h	Thu Apr 24 15:47:22 2014 +0000
+++ b/ui/tests/nsstest.h	Thu Apr 24 16:06:00 2014 +0000
@@ -34,6 +34,7 @@
 private Q_SLOTS:
     void initTestCase();
     void testInstRemove();
+    void benchmarkInstall();
 };
 
 #endif // NSSTEST_H

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