Revert "QFtp: Skip the flaky QTestEventLoop::timeout in Coin network"

This reverts commit 33d2715dd34d39a3250d7b66b785f421c7e07719.

Reason for revert: <QTBUG-76367>

Change-Id: I134514e729d7066ab5f67a0536e653868bf15ed7
Reviewed-by: Dimitrios Apostolou <dimitrios.apostolou@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
This commit is contained in:
Ryan Chu 2019-06-21 15:03:00 +00:00
parent 211830b233
commit d72ea9cbd3

View File

@ -134,8 +134,8 @@ private:
bool fileExists( const QString &host, quint16 port, const QString &user, const QString &password, const QString &file, const QString &cdDir = QString() ); 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 ); bool dirExists( const QString &host, quint16 port, const QString &user, const QString &password, const QString &cdDir, const QString &dirToCreate );
void renameInit( bool &isSuccess, const QString &host, const QString &user, const QString &password, const QString &createFile ); void renameInit( 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 ); void renameCleanup( const QString &host, const QString &user, const QString &password, const QString &fileToDelete );
QFtp *ftp; QFtp *ftp;
#ifndef QT_NO_BEARERMANAGEMENT #ifndef QT_NO_BEARERMANAGEMENT
@ -336,11 +336,7 @@ static QByteArray msgTimedOut(const QString &host, quint16 port = 0)
result += ':'; result += ':';
result += QByteArray::number(port); result += QByteArray::number(port);
} }
return result;
if (host == QtNetworkSettings::ftpServerName())
return "(QTBUG-75549) Flaky results: " % result;
else
return result;
} }
void tst_QFtp::connectToHost() void tst_QFtp::connectToHost()
@ -355,7 +351,7 @@ void tst_QFtp::connectToHost()
delete ftp; delete ftp;
ftp = 0; ftp = 0;
if ( QTestEventLoop::instance().timeout() ) if ( QTestEventLoop::instance().timeout() )
QSKIP( msgTimedOut(host, port) ); QFAIL( msgTimedOut(host, port) );
QTEST( connectToHost_state, "state" ); QTEST( connectToHost_state, "state" );
@ -438,7 +434,7 @@ void tst_QFtp::login()
delete ftp; delete ftp;
ftp = 0; ftp = 0;
if ( QTestEventLoop::instance().timeout() ) if ( QTestEventLoop::instance().timeout() )
QSKIP( msgTimedOut(host, port) ); QFAIL( msgTimedOut(host, port) );
ResMapIt it = resultMap.find( QFtp::Login ); ResMapIt it = resultMap.find( QFtp::Login );
QVERIFY( it != resultMap.end() ); QVERIFY( it != resultMap.end() );
@ -486,7 +482,7 @@ void tst_QFtp::close()
delete ftp; delete ftp;
ftp = 0; ftp = 0;
if ( QTestEventLoop::instance().timeout() ) if ( QTestEventLoop::instance().timeout() )
QSKIP( msgTimedOut(host, port) ); QFAIL( msgTimedOut(host, port) );
QCOMPARE( close_state, (int)QFtp::Unconnected ); QCOMPARE( close_state, (int)QFtp::Unconnected );
@ -554,7 +550,7 @@ void tst_QFtp::list()
delete ftp; delete ftp;
ftp = 0; ftp = 0;
if ( QTestEventLoop::instance().timeout() ) if ( QTestEventLoop::instance().timeout() )
QSKIP( msgTimedOut(host, port) ); QFAIL( msgTimedOut(host, port) );
ResMapIt it = resultMap.find( QFtp::List ); ResMapIt it = resultMap.find( QFtp::List );
QVERIFY( it != resultMap.end() ); QVERIFY( it != resultMap.end() );
@ -615,7 +611,7 @@ void tst_QFtp::cd()
delete ftp; delete ftp;
ftp = 0; ftp = 0;
if ( QTestEventLoop::instance().timeout() ) { if ( QTestEventLoop::instance().timeout() ) {
QSKIP( msgTimedOut(host, port) ); QFAIL( msgTimedOut(host, port) );
} }
ResMapIt it = resultMap.find( QFtp::Cd ); ResMapIt it = resultMap.find( QFtp::Cd );
@ -692,7 +688,7 @@ void tst_QFtp::get()
delete ftp; delete ftp;
ftp = 0; ftp = 0;
if ( QTestEventLoop::instance().timeout() ) if ( QTestEventLoop::instance().timeout() )
QSKIP( msgTimedOut(host, port) ); QFAIL( msgTimedOut(host, port) );
ResMapIt it = resultMap.find( QFtp::Get ); ResMapIt it = resultMap.find( QFtp::Get );
QVERIFY( it != resultMap.end() ); QVERIFY( it != resultMap.end() );
@ -819,7 +815,7 @@ void tst_QFtp::put()
delete ftp; delete ftp;
ftp = 0; ftp = 0;
if ( QTestEventLoop::instance().timeout() ) if ( QTestEventLoop::instance().timeout() )
QSKIP( msgTimedOut(host, port) ); QFAIL( msgTimedOut(host, port) );
it = resultMap.find( QFtp::Put ); it = resultMap.find( QFtp::Put );
QVERIFY( it != resultMap.end() ); QVERIFY( it != resultMap.end() );
@ -852,7 +848,7 @@ void tst_QFtp::put()
delete ftp; delete ftp;
ftp = 0; ftp = 0;
if ( QTestEventLoop::instance().timeout() ) if ( QTestEventLoop::instance().timeout() )
QSKIP( msgTimedOut(host, port) ); QFAIL( msgTimedOut(host, port) );
QCOMPARE( done_success, 1 ); QCOMPARE( done_success, 1 );
QTEST( buf.buffer(), "fileData" ); QTEST( buf.buffer(), "fileData" );
@ -870,7 +866,7 @@ void tst_QFtp::put()
delete ftp; delete ftp;
ftp = 0; ftp = 0;
if ( QTestEventLoop::instance().timeout() ) if ( QTestEventLoop::instance().timeout() )
QSKIP( msgTimedOut(host, port) ); QFAIL( msgTimedOut(host, port) );
it = resultMap.find( QFtp::Remove ); it = resultMap.find( QFtp::Remove );
QVERIFY( it != resultMap.end() ); QVERIFY( it != resultMap.end() );
@ -934,7 +930,7 @@ void tst_QFtp::mkdir()
delete ftp; delete ftp;
ftp = 0; ftp = 0;
if ( QTestEventLoop::instance().timeout() ) if ( QTestEventLoop::instance().timeout() )
QSKIP( msgTimedOut(host, port) ); QFAIL( msgTimedOut(host, port) );
ResMapIt it = resultMap.find( QFtp::Mkdir ); ResMapIt it = resultMap.find( QFtp::Mkdir );
QVERIFY( it != resultMap.end() ); QVERIFY( it != resultMap.end() );
@ -959,7 +955,7 @@ void tst_QFtp::mkdir()
delete ftp; delete ftp;
ftp = 0; ftp = 0;
if ( QTestEventLoop::instance().timeout() ) if ( QTestEventLoop::instance().timeout() )
QSKIP( msgTimedOut(host, port) ); QFAIL( msgTimedOut(host, port) );
it = resultMap.find( QFtp::Mkdir ); it = resultMap.find( QFtp::Mkdir );
QVERIFY( it != resultMap.end() ); QVERIFY( it != resultMap.end() );
@ -979,7 +975,7 @@ void tst_QFtp::mkdir()
delete ftp; delete ftp;
ftp = 0; ftp = 0;
if ( QTestEventLoop::instance().timeout() ) if ( QTestEventLoop::instance().timeout() )
QSKIP( msgTimedOut(host, port) ); QFAIL( msgTimedOut(host, port) );
it = resultMap.find( QFtp::Rmdir ); it = resultMap.find( QFtp::Rmdir );
QVERIFY( it != resultMap.end() ); QVERIFY( it != resultMap.end() );
@ -1077,9 +1073,8 @@ void tst_QFtp::rename_data()
<< 0; << 0;
} }
void tst_QFtp::renameInit( bool &isSuccess, const QString &host, const QString &user, const QString &password, const QString &createFile ) void tst_QFtp::renameInit( const QString &host, const QString &user, const QString &password, const QString &createFile )
{ {
isSuccess = false;
if ( !createFile.isNull() ) { if ( !createFile.isNull() ) {
// upload the file // upload the file
init(); init();
@ -1093,7 +1088,7 @@ void tst_QFtp::renameInit( bool &isSuccess, const QString &host, const QString &
delete ftp; delete ftp;
ftp = 0; ftp = 0;
if ( QTestEventLoop::instance().timeout() ) if ( QTestEventLoop::instance().timeout() )
QSKIP( msgTimedOut(host) ); QFAIL( msgTimedOut(host) );
ResMapIt it = resultMap.find( QFtp::Put ); ResMapIt it = resultMap.find( QFtp::Put );
QVERIFY( it != resultMap.end() ); QVERIFY( it != resultMap.end() );
@ -1101,12 +1096,10 @@ void tst_QFtp::renameInit( bool &isSuccess, const QString &host, const QString &
QVERIFY( fileExists( host, 21, user, password, createFile ) ); QVERIFY( fileExists( host, 21, user, password, createFile ) );
} }
isSuccess = true;
} }
void tst_QFtp::renameCleanup( bool &isSuccess, const QString &host, const QString &user, const QString &password, const QString &fileToDelete ) void tst_QFtp::renameCleanup( const QString &host, const QString &user, const QString &password, const QString &fileToDelete )
{ {
isSuccess = false;
if ( !fileToDelete.isNull() ) { if ( !fileToDelete.isNull() ) {
// cleanup (i.e. remove the file) // cleanup (i.e. remove the file)
init(); init();
@ -1120,7 +1113,7 @@ void tst_QFtp::renameCleanup( bool &isSuccess, const QString &host, const QStrin
delete ftp; delete ftp;
ftp = 0; ftp = 0;
if ( QTestEventLoop::instance().timeout() ) if ( QTestEventLoop::instance().timeout() )
QSKIP( msgTimedOut(host) ); QFAIL( msgTimedOut(host) );
ResMapIt it = resultMap.find( QFtp::Remove ); ResMapIt it = resultMap.find( QFtp::Remove );
QVERIFY( it != resultMap.end() ); QVERIFY( it != resultMap.end() );
@ -1128,7 +1121,6 @@ void tst_QFtp::renameCleanup( bool &isSuccess, const QString &host, const QStrin
QVERIFY( !fileExists( host, 21, user, password, fileToDelete ) ); QVERIFY( !fileExists( host, 21, user, password, fileToDelete ) );
} }
isSuccess = true;
} }
void tst_QFtp::rename() void tst_QFtp::rename()
@ -1151,10 +1143,7 @@ void tst_QFtp::rename()
if(renamedFile.contains('%')) if(renamedFile.contains('%'))
renamedFile = renamedFile.arg(uniqueExtension); renamedFile = renamedFile.arg(uniqueExtension);
bool isSuccess = true; renameInit( host, user, password, createFile );
renameInit(isSuccess, host, user, password, createFile);
if (!isSuccess)
QSKIP("(QTBUG-75549) abort test when there is an error in helper functions");
init(); init();
ftp = newFtp(); ftp = newFtp();
@ -1169,7 +1158,7 @@ void tst_QFtp::rename()
delete ftp; delete ftp;
ftp = 0; ftp = 0;
if ( QTestEventLoop::instance().timeout() ) if ( QTestEventLoop::instance().timeout() )
QSKIP( msgTimedOut(host) ); QFAIL( msgTimedOut(host) );
ResMapIt it = resultMap.find( QFtp::Rename ); ResMapIt it = resultMap.find( QFtp::Rename );
QVERIFY( it != resultMap.end() ); QVERIFY( it != resultMap.end() );
@ -1184,9 +1173,7 @@ void tst_QFtp::rename()
QVERIFY( !fileExists( host, 21, user, password, renamedFile ) ); QVERIFY( !fileExists( host, 21, user, password, renamedFile ) );
} }
renameCleanup(isSuccess, host, user, password, renamedFile); renameCleanup( host, user, password, renamedFile );
if (!isSuccess)
QSKIP("(QTBUG-75549) abort test when there is an error in helper functions");
} }
/* /*
@ -1360,7 +1347,7 @@ void tst_QFtp::commandSequence()
delete ftp; delete ftp;
ftp = 0; ftp = 0;
if ( QTestEventLoop::instance().timeout() ) if ( QTestEventLoop::instance().timeout() )
QSKIP( msgTimedOut(host) ); QFAIL( msgTimedOut(host) );
QTEST( commandSequence_success, "success" ); QTEST( commandSequence_success, "success" );
} }
@ -1415,7 +1402,7 @@ void tst_QFtp::abort()
delete ftp; delete ftp;
ftp = 0; ftp = 0;
if ( QTestEventLoop::instance().timeout() ) if ( QTestEventLoop::instance().timeout() )
QSKIP( msgTimedOut(host, port) ); QFAIL( msgTimedOut(host, port) );
ResMapIt it = resultMap.find( cmd ); ResMapIt it = resultMap.find( cmd );
QVERIFY( it != resultMap.end() ); QVERIFY( it != resultMap.end() );
@ -1453,7 +1440,7 @@ void tst_QFtp::abort()
delete ftp; delete ftp;
ftp = 0; ftp = 0;
if ( QTestEventLoop::instance().timeout() ) if ( QTestEventLoop::instance().timeout() )
QSKIP( msgTimedOut(host, port) ); QFAIL( msgTimedOut(host, port) );
it = resultMap.find( QFtp::Remove ); it = resultMap.find( QFtp::Remove );
QVERIFY( it != resultMap.end() ); QVERIFY( it != resultMap.end() );
@ -1491,11 +1478,8 @@ void tst_QFtp::bytesAvailable()
addCommand( QFtp::Close, ftp->close() ); addCommand( QFtp::Close, ftp->close() );
QTestEventLoop::instance().enterLoop( 40 ); QTestEventLoop::instance().enterLoop( 40 );
if ( QTestEventLoop::instance().timeout() ) { if ( QTestEventLoop::instance().timeout() )
delete ftp; QFAIL( msgTimedOut(host) );
ftp = 0;
QSKIP( msgTimedOut(host) );
}
ResMapIt it = resultMap.find( QFtp::Get ); ResMapIt it = resultMap.find( QFtp::Get );
QVERIFY( it != resultMap.end() ); QVERIFY( it != resultMap.end() );
@ -1588,7 +1572,7 @@ void tst_QFtp::proxy()
delete ftp; delete ftp;
ftp = 0; ftp = 0;
if ( QTestEventLoop::instance().timeout() ) { if ( QTestEventLoop::instance().timeout() ) {
QSKIP( msgTimedOut(host, port) ); QFAIL( msgTimedOut(host, port) );
} }
ResMapIt it = resultMap.find( QFtp::Cd ); ResMapIt it = resultMap.find( QFtp::Cd );
@ -1623,7 +1607,7 @@ void tst_QFtp::binaryAscii()
delete ftp; delete ftp;
ftp = 0; ftp = 0;
if ( QTestEventLoop::instance().timeout() ) if ( QTestEventLoop::instance().timeout() )
QSKIP( msgTimedOut(QtNetworkSettings::ftpServerName()) ); QFAIL( msgTimedOut(QtNetworkSettings::ftpServerName()) );
ResMapIt it = resultMap.find(QFtp::Put); ResMapIt it = resultMap.find(QFtp::Put);
QVERIFY(it != resultMap.end()); QVERIFY(it != resultMap.end());
@ -1645,7 +1629,7 @@ void tst_QFtp::binaryAscii()
delete ftp; delete ftp;
ftp = 0; ftp = 0;
if ( QTestEventLoop::instance().timeout() ) if ( QTestEventLoop::instance().timeout() )
QSKIP( msgTimedOut(QtNetworkSettings::ftpServerName()) ); QFAIL( msgTimedOut(QtNetworkSettings::ftpServerName()) );
ResMapIt it2 = resultMap.find(QFtp::Get); ResMapIt it2 = resultMap.find(QFtp::Get);
QVERIFY(it2 != resultMap.end()); QVERIFY(it2 != resultMap.end());
@ -1668,7 +1652,7 @@ void tst_QFtp::binaryAscii()
delete ftp; delete ftp;
ftp = 0; ftp = 0;
if ( QTestEventLoop::instance().timeout() ) if ( QTestEventLoop::instance().timeout() )
QSKIP( msgTimedOut(QtNetworkSettings::ftpServerName()) ); QFAIL( msgTimedOut(QtNetworkSettings::ftpServerName()) );
it = resultMap.find( QFtp::Remove ); it = resultMap.find( QFtp::Remove );
QVERIFY( it != resultMap.end() ); QVERIFY( it != resultMap.end() );
@ -2100,7 +2084,7 @@ void tst_QFtp::doneSignal()
connect(&ftp, SIGNAL(done(bool)), &(QTestEventLoop::instance()), SLOT(exitLoop())); connect(&ftp, SIGNAL(done(bool)), &(QTestEventLoop::instance()), SLOT(exitLoop()));
QTestEventLoop::instance().enterLoop(61); QTestEventLoop::instance().enterLoop(61);
if (QTestEventLoop::instance().timeout()) if (QTestEventLoop::instance().timeout())
QSKIP( msgTimedOut(QtNetworkSettings::ftpServerName()) ); QFAIL("Network operation timed out");
QCOMPARE(spy.count(), 1); QCOMPARE(spy.count(), 1);
QCOMPARE(spy.first().first().toBool(), false); QCOMPARE(spy.first().first().toBool(), false);