From 928b51704a14d038f940759830579e82899ae8e5 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 18 Nov 2019 16:33:29 +0100 Subject: [PATCH] tst_QFile: add a couple more sequential Unix device files /dev/zero and /dev/null are expected to always be present in any system (even containers). Unlike /dev/null, you *can* read from /dev/zero so test that QIODevice doesn't think it is random-access because of that. /dev/tty is also always present but has an interesting semantic. Could also try /dev/full, /dev/random and /dev/urandom. Change-Id: Ia2aa807ffa8a4c798425fffd15d84b60573f2c26 Reviewed-by: Lars Knoll Reviewed-by: Oswald Buddenhagen --- tests/auto/corelib/io/qfile/tst_qfile.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tests/auto/corelib/io/qfile/tst_qfile.cpp b/tests/auto/corelib/io/qfile/tst_qfile.cpp index e408cd3e488..a0c1078d0c3 100644 --- a/tests/auto/corelib/io/qfile/tst_qfile.cpp +++ b/tests/auto/corelib/io/qfile/tst_qfile.cpp @@ -1825,9 +1825,18 @@ void tst_QFile::bufferedRead() #ifdef Q_OS_UNIX void tst_QFile::isSequential() { - QFile zero("/dev/null"); + QFile zero("/dev/zero"); QVERIFY2(zero.open(QFile::ReadOnly), msgOpenFailed(zero).constData()); QVERIFY(zero.isSequential()); + + QFile null("/dev/null"); + QVERIFY(null.open(QFile::ReadOnly)); + QVERIFY(null.isSequential()); + + // /dev/tty will fail to open if we don't have a controlling TTY + QFile tty("/dev/tty"); + if (tty.open(QFile::ReadOnly)) + QVERIFY(tty.isSequential()); } #endif