summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/installer/libarchivearchive/tst_libarchivearchive.cpp56
1 files changed, 56 insertions, 0 deletions
diff --git a/tests/auto/installer/libarchivearchive/tst_libarchivearchive.cpp b/tests/auto/installer/libarchivearchive/tst_libarchivearchive.cpp
index 8034f9556..a1f5a1994 100644
--- a/tests/auto/installer/libarchivearchive/tst_libarchivearchive.cpp
+++ b/tests/auto/installer/libarchivearchive/tst_libarchivearchive.cpp
@@ -26,6 +26,8 @@
**
**************************************************************************/
+#include "../shared/verifyinstaller.h"
+
#include <libarchivearchive.h>
#include <fileutils.h>
@@ -149,6 +151,60 @@ private slots:
QVERIFY(QFile(QDir::tempPath() + QString("/valid")).remove());
}
+ void testCreateExtractWithSymlink_data()
+ {
+ archiveSuffixesTestData();
+ }
+
+ void testCreateExtractWithSymlink()
+ {
+ QFETCH(QString, suffix);
+
+ const QString workingDir = generateTemporaryFileName() + "/";
+ const QString archiveName = workingDir + "archive" + suffix;
+ const QString targetName = workingDir + "target/";
+#ifdef Q_OS_WIN
+ const QString linkName = workingDir + "link.lnk";
+#else
+ const QString linkName = workingDir + "link";
+#endif
+
+ QVERIFY(QDir().mkpath(targetName));
+
+ QFile source(workingDir + "file");
+ QVERIFY(source.open(QIODevice::ReadWrite));
+ QVERIFY(source.write("Source File"));
+
+ // Creates a shortcut on Windows, a symbolic link on Unix
+ QVERIFY(QFile::link(source.fileName(), linkName));
+
+ LibArchiveArchive archive(archiveName);
+ QVERIFY(archive.open(QIODevice::ReadWrite));
+ QVERIFY(archive.create(QStringList() << source.fileName() << linkName));
+ QVERIFY(QFileInfo::exists(archiveName));
+
+ QVERIFY(archive.extract(targetName));
+ const QString sourceFilename = QFileInfo(source.fileName()).fileName();
+ const QString linkFilename = QFileInfo(linkName).fileName();
+ QVERIFY(QFileInfo::exists(targetName + sourceFilename));
+ QVERIFY(QFileInfo::exists(targetName + linkFilename));
+
+ VerifyInstaller::verifyFileContent(targetName + sourceFilename, source.readAll());
+ const QString sourceFilePath = workingDir + sourceFilename;
+ QCOMPARE(QFile::symLinkTarget(targetName + linkFilename), sourceFilePath);
+
+ archive.close();
+
+ QVERIFY(source.remove());
+ QVERIFY(QFile::remove(archiveName));
+ QVERIFY(QFile::remove(linkName));
+ QVERIFY(QFile::remove(targetName + sourceFilename));
+ QVERIFY(QFile::remove(targetName + linkFilename));
+
+ removeDirectory(targetName, true);
+ removeDirectory(workingDir, true);
+ }
+
private:
void archiveFilenamesTestData()
{