diff options
author | Hannah von Reth <hannah.vonreth@owncloud.com> | 2021-02-12 16:44:32 +0300 |
---|---|---|
committer | Hannah von Reth <vonreth@kde.org> | 2021-02-12 17:06:19 +0300 |
commit | b4157d565410b4609f89f4c3bcfc8a529ab5c618 (patch) | |
tree | 38314efa1c0270aa332297a3d6ead2a6b918c0c3 | |
parent | a56c7286616d14ad48c614a6b6ebc91164b95993 (diff) |
Add test for csync_vio_local_stat with long path
-rw-r--r-- | test/CMakeLists.txt | 5 | ||||
-rw-r--r-- | test/testlongpath.cpp (renamed from test/testlongwinpath.cpp) | 57 |
2 files changed, 57 insertions, 5 deletions
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 327b1d8a2..4c3608fcd 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -42,10 +42,7 @@ if( UNIX AND NOT APPLE ) endif(UNIX AND NOT APPLE) -if (WIN32) - owncloud_add_test(LongWinPath) -endif() - +owncloud_add_test(LongPath) owncloud_add_benchmark(LargeSync) owncloud_add_test(FolderMan) diff --git a/test/testlongwinpath.cpp b/test/testlongpath.cpp index 16933813c..7e912ae15 100644 --- a/test/testlongwinpath.cpp +++ b/test/testlongpath.cpp @@ -18,7 +18,10 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "common/filesystembase.h" +#include "csync/csync.h" +#include "csync/vio/csync_vio_local.h" +#include <QTemporaryFile> #include <QTest> @@ -27,6 +30,7 @@ class TestLongWindowsPath : public QObject Q_OBJECT private Q_SLOTS: +#ifdef Q_OS_WIN void check_long_win_path() { { @@ -81,7 +85,58 @@ private Q_SLOTS: // printf( "YYYYYYYYYYYY %ld\n", strlen(new_long)); QCOMPARE(new_long.length(), 286); } +#endif + + + void testLongPathStat_data() + { + QTest::addColumn<QString>("name"); + + QTest::newRow("long") << QStringLiteral("/alonglonglonglong/blonglonglonglong/clonglonglonglong/dlonglonglonglong/" + "elonglonglonglong/flonglonglonglong/glonglonglonglong/hlonglonglonglong/ilonglonglonglong/" + "jlonglonglonglong/klonglonglonglong/llonglonglonglong/mlonglonglonglong/nlonglonglonglong/" + "olonglonglonglong/file.txt"); + QTest::newRow("long emoji") << QString::fromUtf8("/alonglonglonglong/blonglonglonglong/clonglonglonglong/dlonglonglonglong/" + "elonglonglonglong/flonglonglonglong/glonglonglonglong/hlonglonglonglong/ilonglonglonglong/" + "jlonglonglonglong/klonglonglonglong/llonglonglonglong/mlonglonglonglong/nlonglonglonglong/" + "olonglonglonglong/file🐷.txt"); + QTest::newRow("long russian") << QString::fromUtf8("/alonglonglonglong/blonglonglonglong/clonglonglonglong/dlonglonglonglong/" + "elonglonglonglong/flonglonglonglong/glonglonglonglong/hlonglonglonglong/ilonglonglonglong/" + "jlonglonglonglong/klonglonglonglong/llonglonglonglong/mlonglonglonglong/nlonglonglonglong/" + "olonglonglonglong/собственное.txt"); + QTest::newRow("long arabic") << QString::fromUtf8("/alonglonglonglong/blonglonglonglong/clonglonglonglong/dlonglonglonglong/" + "elonglonglonglong/flonglonglonglong/glonglonglonglong/hlonglonglonglong/ilonglonglonglong/" + "jlonglonglonglong/klonglonglonglong/llonglonglonglong/mlonglonglonglong/nlonglonglonglong/" + "olonglonglonglong/السحاب.txt"); + QTest::newRow("long chinese") << QString::fromUtf8("/alonglonglonglong/blonglonglonglong/clonglonglonglong/dlonglonglonglong/" + "elonglonglonglong/flonglonglonglong/glonglonglonglong/hlonglonglonglong/ilonglonglonglong/" + "jlonglonglonglong/klonglonglonglong/llonglonglonglong/mlonglonglonglong/nlonglonglonglong/" + "olonglonglonglong/自己的云.txt"); + } + + void testLongPathStat() + { + QTemporaryDir tmp; + QFETCH(QString, name); + const QFileInfo longPath(tmp.path() + name); + + const auto data = QByteArrayLiteral("hello"); + qDebug() << longPath; + QVERIFY(longPath.dir().mkpath(".")); + + QFile file(longPath.filePath()); + QVERIFY(file.open(QFile::WriteOnly)); + QVERIFY(file.write(data.constData()) == data.size()); + file.close(); + + csync_file_stat_t buf; + QVERIFY(csync_vio_local_stat(longPath.filePath(), &buf) != -1); + QVERIFY(buf.size == data.size()); + QVERIFY(buf.size == longPath.size()); + + QVERIFY(tmp.remove()); + } }; QTEST_GUILESS_MAIN(TestLongWindowsPath) -#include "testlongwinpath.moc" +#include "testlongpath.moc" |