diff options
author | Friedemann Kleint <Friedemann.Kleint@nokia.com> | 2012-06-13 07:20:13 (GMT) |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-06-13 07:33:18 (GMT) |
commit | b22fdf72aed1d6ab5e073f6cd1eee26de59a5b4f (patch) | |
tree | 56975dfa8ed56161448b9cae7e5867c110247596 /tests/auto/qfile | |
parent | e678ed12dbbae202e61d3afd34429a1e7ddc4b9d (diff) | |
download | Qt-b22fdf72aed1d6ab5e073f6cd1eee26de59a5b4f.zip Qt-b22fdf72aed1d6ab5e073f6cd1eee26de59a5b4f.tar.gz Qt-b22fdf72aed1d6ab5e073f6cd1eee26de59a5b4f.tar.bz2 |
QFile-test: Test for redirected handles in standard streams test.
This is similar to 2509a5b5a49ea52948b434578ff29e7f9ba60b40 in
Qt 5 (qtbase). In 4.8, stdout also seems to be affected, whereas
in Qt 5, the problem occurred for stdin.
Task-number: QTQAINFRA-428
Change-Id: Ia644923bdb76d0ac3c218c843fefcf280ee729cb
Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
Diffstat (limited to 'tests/auto/qfile')
-rw-r--r-- | tests/auto/qfile/tst_qfile.cpp | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/tests/auto/qfile/tst_qfile.cpp b/tests/auto/qfile/tst_qfile.cpp index 40534d3..5bed1e7 100644 --- a/tests/auto/qfile/tst_qfile.cpp +++ b/tests/auto/qfile/tst_qfile.cpp @@ -3194,29 +3194,34 @@ 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", SkipAll); #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.", SkipSingle); QCOMPARE( in.pos(), (qint64)0 ); QCOMPARE( in.size(), (qint64)0 ); - QVERIFY( in.isSequential() ); } { QFile out; out.open(STDOUT_FILENO, QIODevice::WriteOnly); + if (!out.isSequential()) + QSKIP("Standard output redirected.", SkipSingle); 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.", SkipSingle); QCOMPARE( err.pos(), (qint64)0 ); QCOMPARE( err.size(), (qint64)0 ); - QVERIFY( err.isSequential() ); } } @@ -3227,27 +3232,33 @@ void tst_QFile::openStandardStreamsBufferedStreams() #endif // Using streams { + /* 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, QIODevice::ReadOnly); + if (!in.isSequential()) + QSKIP("Standard input redirected.", SkipSingle); QCOMPARE( in.pos(), (qint64)0 ); QCOMPARE( in.size(), (qint64)0 ); - QVERIFY( in.isSequential() ); } { QFile out; out.open(stdout, QIODevice::WriteOnly); + if (!out.isSequential()) + QSKIP("Standard output redirected.", SkipSingle); QCOMPARE( out.pos(), (qint64)0 ); QCOMPARE( out.size(), (qint64)0 ); - QVERIFY( out.isSequential() ); } { QFile err; err.open(stderr, QIODevice::WriteOnly); + if (!err.isSequential()) + QSKIP("Standard error redirected.", SkipSingle); QCOMPARE( err.pos(), (qint64)0 ); QCOMPARE( err.size(), (qint64)0 ); - QVERIFY( err.isSequential() ); } } |