[PATCH 1 of 2] Add NSSShared to test environment and create benchmark

Wald Commits scm-commit at wald.intevation.org
Thu Apr 24 19:05:07 CEST 2014


# HG changeset patch
# User Andre Heinecke <aheinecke at intevation.de>
# Date 1398355560 0
# Node ID dcb014e7d32fa0a3478b103a42b90617011e00d6
# Parent  810983b27a5315254a2d688ecb0f44f565fb7bfe
Add NSSShared to test environment and create benchmark

    Benchmark is extremly slow currently

diff -r 810983b27a53 -r dcb014e7d32f ui/tests/nsstest.cpp
--- 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);
diff -r 810983b27a53 -r dcb014e7d32f ui/tests/nsstest.h
--- 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


More information about the Trustbridge-commits mailing list