SyncEngineTestUtils: Do don't allocate a buffer for the whole file
authorOlivier Goffart <ogoffart@woboq.com>
Tue, 15 Nov 2016 10:39:40 +0000 (11:39 +0100)
committerOlivier Goffart <ogoffart@woboq.com>
Tue, 15 Nov 2016 10:39:40 +0000 (11:39 +0100)
As the file can be some hunreds of megabytes, allocating such big arrays may
cause problems.

Also make the timeout a bit bigger so the test can rununder valgrind.

test/syncenginetestutils.h

index cbcb5fab213cd077fadd64f37c336f814bf9505b..0f4249c387a2f04b7a5f150c7fe5e7e5c210221c 100644 (file)
@@ -82,10 +82,15 @@ public:
         QFile file{_rootDir.filePath(relativePath)};
         QVERIFY(!file.exists());
         file.open(QFile::WriteOnly);
-        file.write(QByteArray{}.fill(contentChar, size));
+        QByteArray buf(1024, contentChar);
+        for (int x = 0; x < size/buf.size(); ++x) {
+            file.write(buf);
+        }
+        file.write(buf.data(), size % buf.size());
         file.close();
         // Set the mtime 30 seconds in the past, for some tests that need to make sure that the mtime differs.
         OCC::FileSystem::setModTime(file.fileName(), OCC::Utility::qDateTimeToTime_t(QDateTime::currentDateTime().addSecs(-30)));
+        QCOMPARE(file.size(), size);
     }
     void setContents(const QString &relativePath, char contentChar) override {
         QFile file{_rootDir.filePath(relativePath)};
@@ -792,7 +797,7 @@ public:
 
     bool execUntilFinished() {
         QSignalSpy spy(_syncEngine.get(), SIGNAL(finished(bool)));
-        bool ok = spy.wait();
+        bool ok = spy.wait(60000);
         Q_ASSERT(ok && "Sync timed out");
         return spy[0][0].toBool();
     }