diff options
Diffstat (limited to 'tests/auto/corelib/io/qfile/tst_qfile.cpp')
-rw-r--r-- | tests/auto/corelib/io/qfile/tst_qfile.cpp | 28 |
1 files changed, 13 insertions, 15 deletions
diff --git a/tests/auto/corelib/io/qfile/tst_qfile.cpp b/tests/auto/corelib/io/qfile/tst_qfile.cpp index 90cd1aedb9..300f30e133 100644 --- a/tests/auto/corelib/io/qfile/tst_qfile.cpp +++ b/tests/auto/corelib/io/qfile/tst_qfile.cpp @@ -199,7 +199,8 @@ private slots: void mapOpenMode_data(); void mapOpenMode(); - void openStandardStreams(); + void openStandardStreamsFileDescriptors(); + void openStandardStreamsBufferedStreams(); void resize_data(); void resize(); @@ -228,9 +229,6 @@ private: NumberOfFileTypes }; - void openStandardStreamsFileDescriptors(); - void openStandardStreamsBufferedStreams(); - bool openFd(QFile &file, QIODevice::OpenMode mode, QFile::FileHandleFlags handleFlags) { int fdMode = QT_OPEN_LARGEFILE | QT_OPEN_BINARY; @@ -2971,29 +2969,35 @@ void tst_QFile::openStandardStreamsFileDescriptors() //it does not have functions to simply open them like below . QSKIP("Opening standard streams on Windows CE via descriptor not implemented"); #endif - // Using file descriptors + /* in/out/err.isSequential() are only true when run in a console (CI); + * it is false when they are redirected from/to files. + * Prevent failures in case someone runs tests with stdout/stderr redirected. */ + { QFile in; in.open(STDIN_FILENO, QIODevice::ReadOnly); + if (!in.isSequential()) + QSKIP("Standard input redirected."); QCOMPARE( in.pos(), (qint64)0 ); QCOMPARE( in.size(), (qint64)0 ); - QVERIFY( in.isSequential() ); } { QFile out; - out.open(STDOUT_FILENO, QIODevice::WriteOnly); + QVERIFY(out.open(STDOUT_FILENO, QIODevice::WriteOnly)); + if (!out.isSequential()) + QSKIP("Standard output redirected."); QCOMPARE( out.pos(), (qint64)0 ); QCOMPARE( out.size(), (qint64)0 ); - QVERIFY( out.isSequential() ); } { QFile err; err.open(STDERR_FILENO, QIODevice::WriteOnly); + if (!err.isSequential()) + QSKIP("Standard error redirected."); QCOMPARE( err.pos(), (qint64)0 ); QCOMPARE( err.size(), (qint64)0 ); - QVERIFY( err.isSequential() ); } } @@ -3028,12 +3032,6 @@ void tst_QFile::openStandardStreamsBufferedStreams() } } -void tst_QFile::openStandardStreams() -{ - openStandardStreamsFileDescriptors(); - openStandardStreamsBufferedStreams(); -} - void tst_QFile::writeNothing() { for (int i = 0; i < NumberOfFileTypes; ++i) { |