diff options
-rw-r--r-- | tests/auto/network/access/qftp/tst_qftp.cpp | 80 |
1 files changed, 48 insertions, 32 deletions
diff --git a/tests/auto/network/access/qftp/tst_qftp.cpp b/tests/auto/network/access/qftp/tst_qftp.cpp index ec7bcd25e2..e07588d6c6 100644 --- a/tests/auto/network/access/qftp/tst_qftp.cpp +++ b/tests/auto/network/access/qftp/tst_qftp.cpp @@ -133,8 +133,8 @@ private: bool fileExists( const QString &host, quint16 port, const QString &user, const QString &password, const QString &file, const QString &cdDir = QString() ); bool dirExists( const QString &host, quint16 port, const QString &user, const QString &password, const QString &cdDir, const QString &dirToCreate ); - void renameInit( const QString &host, const QString &user, const QString &password, const QString &createFile ); - void renameCleanup( const QString &host, const QString &user, const QString &password, const QString &fileToDelete ); + void renameInit( bool &isSuccess, const QString &host, const QString &user, const QString &password, const QString &createFile ); + void renameCleanup( bool &isSuccess, const QString &host, const QString &user, const QString &password, const QString &fileToDelete ); QFtp *ftp; #ifndef QT_NO_BEARERMANAGEMENT @@ -335,7 +335,11 @@ static QByteArray msgTimedOut(const QString &host, quint16 port = 0) result += ':'; result += QByteArray::number(port); } - return result; + + if (host == QtNetworkSettings::ftpServerName()) + return "(QTBUG-75549) Flaky results: " % result; + else + return result; } void tst_QFtp::connectToHost() @@ -350,7 +354,7 @@ void tst_QFtp::connectToHost() delete ftp; ftp = 0; if ( QTestEventLoop::instance().timeout() ) - QFAIL( msgTimedOut(host, port) ); + QSKIP( msgTimedOut(host, port) ); QTEST( connectToHost_state, "state" ); @@ -433,7 +437,7 @@ void tst_QFtp::login() delete ftp; ftp = 0; if ( QTestEventLoop::instance().timeout() ) - QFAIL( msgTimedOut(host, port) ); + QSKIP( msgTimedOut(host, port) ); ResMapIt it = resultMap.find( QFtp::Login ); QVERIFY( it != resultMap.end() ); @@ -481,7 +485,7 @@ void tst_QFtp::close() delete ftp; ftp = 0; if ( QTestEventLoop::instance().timeout() ) - QFAIL( msgTimedOut(host, port) ); + QSKIP( msgTimedOut(host, port) ); QCOMPARE( close_state, (int)QFtp::Unconnected ); @@ -549,7 +553,7 @@ void tst_QFtp::list() delete ftp; ftp = 0; if ( QTestEventLoop::instance().timeout() ) - QFAIL( msgTimedOut(host, port) ); + QSKIP( msgTimedOut(host, port) ); ResMapIt it = resultMap.find( QFtp::List ); QVERIFY( it != resultMap.end() ); @@ -610,7 +614,7 @@ void tst_QFtp::cd() delete ftp; ftp = 0; if ( QTestEventLoop::instance().timeout() ) { - QFAIL( msgTimedOut(host, port) ); + QSKIP( msgTimedOut(host, port) ); } ResMapIt it = resultMap.find( QFtp::Cd ); @@ -687,7 +691,7 @@ void tst_QFtp::get() delete ftp; ftp = 0; if ( QTestEventLoop::instance().timeout() ) - QFAIL( msgTimedOut(host, port) ); + QSKIP( msgTimedOut(host, port) ); ResMapIt it = resultMap.find( QFtp::Get ); QVERIFY( it != resultMap.end() ); @@ -814,7 +818,7 @@ void tst_QFtp::put() delete ftp; ftp = 0; if ( QTestEventLoop::instance().timeout() ) - QFAIL( msgTimedOut(host, port) ); + QSKIP( msgTimedOut(host, port) ); it = resultMap.find( QFtp::Put ); QVERIFY( it != resultMap.end() ); @@ -847,7 +851,7 @@ void tst_QFtp::put() delete ftp; ftp = 0; if ( QTestEventLoop::instance().timeout() ) - QFAIL( msgTimedOut(host, port) ); + QSKIP( msgTimedOut(host, port) ); QCOMPARE( done_success, 1 ); QTEST( buf.buffer(), "fileData" ); @@ -865,7 +869,7 @@ void tst_QFtp::put() delete ftp; ftp = 0; if ( QTestEventLoop::instance().timeout() ) - QFAIL( msgTimedOut(host, port) ); + QSKIP( msgTimedOut(host, port) ); it = resultMap.find( QFtp::Remove ); QVERIFY( it != resultMap.end() ); @@ -929,7 +933,7 @@ void tst_QFtp::mkdir() delete ftp; ftp = 0; if ( QTestEventLoop::instance().timeout() ) - QFAIL( msgTimedOut(host, port) ); + QSKIP( msgTimedOut(host, port) ); ResMapIt it = resultMap.find( QFtp::Mkdir ); QVERIFY( it != resultMap.end() ); @@ -954,7 +958,7 @@ void tst_QFtp::mkdir() delete ftp; ftp = 0; if ( QTestEventLoop::instance().timeout() ) - QFAIL( msgTimedOut(host, port) ); + QSKIP( msgTimedOut(host, port) ); it = resultMap.find( QFtp::Mkdir ); QVERIFY( it != resultMap.end() ); @@ -974,7 +978,7 @@ void tst_QFtp::mkdir() delete ftp; ftp = 0; if ( QTestEventLoop::instance().timeout() ) - QFAIL( msgTimedOut(host, port) ); + QSKIP( msgTimedOut(host, port) ); it = resultMap.find( QFtp::Rmdir ); QVERIFY( it != resultMap.end() ); @@ -1072,8 +1076,9 @@ void tst_QFtp::rename_data() << 0; } -void tst_QFtp::renameInit( const QString &host, const QString &user, const QString &password, const QString &createFile ) +void tst_QFtp::renameInit( bool &isSuccess, const QString &host, const QString &user, const QString &password, const QString &createFile ) { + isSuccess = false; if ( !createFile.isNull() ) { // upload the file init(); @@ -1087,7 +1092,7 @@ void tst_QFtp::renameInit( const QString &host, const QString &user, const QStri delete ftp; ftp = 0; if ( QTestEventLoop::instance().timeout() ) - QFAIL( msgTimedOut(host) ); + QSKIP( msgTimedOut(host) ); ResMapIt it = resultMap.find( QFtp::Put ); QVERIFY( it != resultMap.end() ); @@ -1095,10 +1100,12 @@ void tst_QFtp::renameInit( const QString &host, const QString &user, const QStri QVERIFY( fileExists( host, 21, user, password, createFile ) ); } + isSuccess = true; } -void tst_QFtp::renameCleanup( const QString &host, const QString &user, const QString &password, const QString &fileToDelete ) +void tst_QFtp::renameCleanup( bool &isSuccess, const QString &host, const QString &user, const QString &password, const QString &fileToDelete ) { + isSuccess = false; if ( !fileToDelete.isNull() ) { // cleanup (i.e. remove the file) init(); @@ -1112,7 +1119,7 @@ void tst_QFtp::renameCleanup( const QString &host, const QString &user, const QS delete ftp; ftp = 0; if ( QTestEventLoop::instance().timeout() ) - QFAIL( msgTimedOut(host) ); + QSKIP( msgTimedOut(host) ); ResMapIt it = resultMap.find( QFtp::Remove ); QVERIFY( it != resultMap.end() ); @@ -1120,6 +1127,7 @@ void tst_QFtp::renameCleanup( const QString &host, const QString &user, const QS QVERIFY( !fileExists( host, 21, user, password, fileToDelete ) ); } + isSuccess = true; } void tst_QFtp::rename() @@ -1142,7 +1150,10 @@ void tst_QFtp::rename() if(renamedFile.contains('%')) renamedFile = renamedFile.arg(uniqueExtension); - renameInit( host, user, password, createFile ); + bool isSuccess = true; + renameInit(isSuccess, host, user, password, createFile); + if (!isSuccess) + QSKIP("(QTBUG-75549) abort test when there is an error in helper functions"); init(); ftp = newFtp(); @@ -1157,7 +1168,7 @@ void tst_QFtp::rename() delete ftp; ftp = 0; if ( QTestEventLoop::instance().timeout() ) - QFAIL( msgTimedOut(host) ); + QSKIP( msgTimedOut(host) ); ResMapIt it = resultMap.find( QFtp::Rename ); QVERIFY( it != resultMap.end() ); @@ -1172,7 +1183,9 @@ void tst_QFtp::rename() QVERIFY( !fileExists( host, 21, user, password, renamedFile ) ); } - renameCleanup( host, user, password, renamedFile ); + renameCleanup(isSuccess, host, user, password, renamedFile); + if (!isSuccess) + QSKIP("(QTBUG-75549) abort test when there is an error in helper functions"); } /* @@ -1346,7 +1359,7 @@ void tst_QFtp::commandSequence() delete ftp; ftp = 0; if ( QTestEventLoop::instance().timeout() ) - QFAIL( msgTimedOut(host) ); + QSKIP( msgTimedOut(host) ); QTEST( commandSequence_success, "success" ); } @@ -1401,7 +1414,7 @@ void tst_QFtp::abort() delete ftp; ftp = 0; if ( QTestEventLoop::instance().timeout() ) - QFAIL( msgTimedOut(host, port) ); + QSKIP( msgTimedOut(host, port) ); ResMapIt it = resultMap.find( cmd ); QVERIFY( it != resultMap.end() ); @@ -1439,7 +1452,7 @@ void tst_QFtp::abort() delete ftp; ftp = 0; if ( QTestEventLoop::instance().timeout() ) - QFAIL( msgTimedOut(host, port) ); + QSKIP( msgTimedOut(host, port) ); it = resultMap.find( QFtp::Remove ); QVERIFY( it != resultMap.end() ); @@ -1477,8 +1490,11 @@ void tst_QFtp::bytesAvailable() addCommand( QFtp::Close, ftp->close() ); QTestEventLoop::instance().enterLoop( 40 ); - if ( QTestEventLoop::instance().timeout() ) - QFAIL( msgTimedOut(host) ); + if ( QTestEventLoop::instance().timeout() ) { + delete ftp; + ftp = 0; + QSKIP( msgTimedOut(host) ); + } ResMapIt it = resultMap.find( QFtp::Get ); QVERIFY( it != resultMap.end() ); @@ -1571,7 +1587,7 @@ void tst_QFtp::proxy() delete ftp; ftp = 0; if ( QTestEventLoop::instance().timeout() ) { - QFAIL( msgTimedOut(host, port) ); + QSKIP( msgTimedOut(host, port) ); } ResMapIt it = resultMap.find( QFtp::Cd ); @@ -1606,7 +1622,7 @@ void tst_QFtp::binaryAscii() delete ftp; ftp = 0; if ( QTestEventLoop::instance().timeout() ) - QFAIL( msgTimedOut(QtNetworkSettings::ftpServerName()) ); + QSKIP( msgTimedOut(QtNetworkSettings::ftpServerName()) ); ResMapIt it = resultMap.find(QFtp::Put); QVERIFY(it != resultMap.end()); @@ -1628,7 +1644,7 @@ void tst_QFtp::binaryAscii() delete ftp; ftp = 0; if ( QTestEventLoop::instance().timeout() ) - QFAIL( msgTimedOut(QtNetworkSettings::ftpServerName()) ); + QSKIP( msgTimedOut(QtNetworkSettings::ftpServerName()) ); ResMapIt it2 = resultMap.find(QFtp::Get); QVERIFY(it2 != resultMap.end()); @@ -1651,7 +1667,7 @@ void tst_QFtp::binaryAscii() delete ftp; ftp = 0; if ( QTestEventLoop::instance().timeout() ) - QFAIL( msgTimedOut(QtNetworkSettings::ftpServerName()) ); + QSKIP( msgTimedOut(QtNetworkSettings::ftpServerName()) ); it = resultMap.find( QFtp::Remove ); QVERIFY( it != resultMap.end() ); @@ -2083,7 +2099,7 @@ void tst_QFtp::doneSignal() connect(&ftp, SIGNAL(done(bool)), &(QTestEventLoop::instance()), SLOT(exitLoop())); QTestEventLoop::instance().enterLoop(61); if (QTestEventLoop::instance().timeout()) - QFAIL("Network operation timed out"); + QSKIP( msgTimedOut(QtNetworkSettings::ftpServerName()) ); QCOMPARE(spy.count(), 1); QCOMPARE(spy.first().first().toBool(), false); |