summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2023-10-12 14:10:49 -0700
committerThiago Macieira <thiago.macieira@intel.com>2023-10-21 15:21:19 -0700
commit9df2b7ffa4fd99c39e73263c0ee07c203053096b (patch)
tree959909aeef7761dc5b7932242b5f6972cc604ef2
parent70d7c6a937fec04401a3c0bc6380731d9f4478e9 (diff)
tst_QStorageInfo: make storageList() test table-driven
Otherwise we have no way of knowing which QStorageInfo entry was being tested. Previous: FAIL! : tst_QStorageInfo::storageList() 'other.isValid()' returned FALSE. () Now: FAIL! : tst_QStorageInfo::storageList(/run/user/0/gvfs) 'other.isValid()' returned FALSE. () Change-Id: I8f3ce163ccc5408cac39fffd178d786e596ece81 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
-rw-r--r--tests/auto/corelib/io/qstorageinfo/tst_qstorageinfo.cpp22
1 files changed, 20 insertions, 2 deletions
diff --git a/tests/auto/corelib/io/qstorageinfo/tst_qstorageinfo.cpp b/tests/auto/corelib/io/qstorageinfo/tst_qstorageinfo.cpp
index 59143738dd..6acc4fbcdc 100644
--- a/tests/auto/corelib/io/qstorageinfo/tst_qstorageinfo.cpp
+++ b/tests/auto/corelib/io/qstorageinfo/tst_qstorageinfo.cpp
@@ -2,6 +2,7 @@
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include <QTest>
+#include <QSet>
#include <QStandardPaths>
#include <QStorageInfo>
#include <QTemporaryFile>
@@ -24,6 +25,7 @@ private slots:
void operatorNotEqual();
void root();
void currentStorage();
+ void storageList_data();
void storageList();
void tempFile();
void caching();
@@ -144,7 +146,7 @@ void tst_QStorageInfo::currentStorage()
QCOMPARE_GE(storage.bytesAvailable(), 0);
}
-void tst_QStorageInfo::storageList()
+void tst_QStorageInfo::storageList_data()
{
QStorageInfo root = QStorageInfo::root();
@@ -155,9 +157,26 @@ void tst_QStorageInfo::storageList()
volumes.removeOne(root);
QVERIFY(!volumes.contains(root));
+ if (volumes.isEmpty())
+ QSKIP("Only the root volume was mounted on this system");
+
+ QTest::addColumn<QStorageInfo>("storage");
+ QSet<QString> seenRoots;
for (const QStorageInfo &storage : std::as_const(volumes)) {
if (!storage.isReady())
continue;
+ QString rootPath = storage.rootPath();
+ if (seenRoots.contains(rootPath))
+ qInfo() << rootPath << "is mounted over; QStorageInfo may be unpredictable";
+ else
+ QTest::newRow(qUtf8Printable(rootPath)) << storage;
+ seenRoots.insert(rootPath);
+ }
+}
+
+void tst_QStorageInfo::storageList()
+{
+ QFETCH(QStorageInfo, storage);
QVERIFY(storage.isValid());
QVERIFY(!storage.isRoot());
@@ -165,7 +184,6 @@ void tst_QStorageInfo::storageList()
QVERIFY(!storage.device().isEmpty());
QVERIFY(!storage.fileSystemType().isEmpty());
#endif
- }
}
static bool checkFilesystemGoodForWriting(QTemporaryFile &file, QStorageInfo &storage)