changeset 1327:562d66614b5c

(issue169) Fix handling of exclusive locks.
author Andre Heinecke <andre.heinecke@intevation.de>
date Wed, 15 Oct 2014 13:06:19 +0200
parents dd3eefda8503
children 18211dce3106
files ui/tests/windowsstoretest.cpp
diffstat 1 files changed, 12 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/ui/tests/windowsstoretest.cpp	Wed Oct 15 10:03:48 2014 +0200
+++ b/ui/tests/windowsstoretest.cpp	Wed Oct 15 13:06:19 2014 +0200
@@ -8,6 +8,7 @@
 #include "windowsstoretest.h"
 #include "certificatelist.h"
 #include "strhelp.h"
+#include "logging.h"
 #include "certificate.h"
 #include "../cinst/windowsstore.h"
 
@@ -38,13 +39,16 @@
       0,                         // No flags
       NULL);                     // Not needed
     QVERIFY (testStore);
-    QFile res(":/list-valid-signed.txt");
-    res.open(QIODevice::ReadOnly);
-    tmpFile.open();
-    tmpFile.write(res.readAll());
+    tmpFile.open(); // get the file name
+    /* This is not really a secure way to open a temporay file but it's ok
+     * for a unit test. The Problem is that qtemporaryfile prohibits obtaining
+     * an exclusive lock on the created file. */
+    QVERIFY(QFile::copy(":/list-valid-signed.txt", tmpFile.fileName() + "_exclusive"));
     tmpFile.close();
 
-    validList = CertificateList(tmpFile.fileName().toLocal8Bit().data());
+    validList = CertificateList((tmpFile.fileName() + "_exclusive").toLocal8Bit().data());
+    QVERIFY(validList.isValid());
+    QVERIFY(validList.getCertificates().size() > 0);
 }
 
 void WindowsStoreTest::testInstRemove() {
@@ -68,6 +72,7 @@
 
     /* Just a quick check for str_append_str functionality */
     QVERIFY((size_t) instList.size() == strv_length(to_install));
+    QVERIFY(strv_length(to_install) > 0);
     for (i = 0; i < strv_length(to_install); i++) {
         QVERIFY (instList[i].base64Line().right(
                     instList[i].base64Line().size() - 2) ==
@@ -94,6 +99,7 @@
     QVERIFY ((size_t)instList.size() == i);
 
     /* Remove all except one */
+    QVERIFY(strv_length(to_install));
     for (i = 0; i < strv_length(to_install) - 1; i++) {
         strv_append(&to_remove, to_install[i], qstrlen(to_install[i]));
     }
@@ -156,6 +162,7 @@
 }
 
 void WindowsStoreTest::cleanupTestCase() {
+    QFile::remove(tmpFile.fileName() + "_exclusive");
     CertCloseStore(testStore, 0);
 }
 

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