diff options
author | Friedemann Kleint <Friedemann.Kleint@digia.com> | 2012-10-02 06:39:11 (GMT) |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2012-10-02 15:45:50 (GMT) |
commit | e086f429a148ce48c8a0332918fa95951025a70f (patch) | |
tree | 2b1ffdd258e762352991935eaf1d8752a1ab1e57 /tests/auto | |
parent | d412f11cea4dc336c684aafcd8979d5cec751cb5 (diff) | |
download | Qt-e086f429a148ce48c8a0332918fa95951025a70f.zip Qt-e086f429a148ce48c8a0332918fa95951025a70f.tar.gz Qt-e086f429a148ce48c8a0332918fa95951025a70f.tar.bz2 |
Fix autotests that no longer find executables on Windows.
The tests are now run from the 'debug',
'release' subdirectories on Windows by 'make check'.
Go up one directory so that the relative paths are correct.
Network tests only.
Task-number: QTQAINFRA-428
Change-Id: I03bc04028b405bc4f897cbf9d7cb400cc009bb8f
Reviewed-by: Sergio Ahumada <sergio.ahumada@digia.com>
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/qtcpserver/tst_qtcpserver.cpp | 23 | ||||
-rw-r--r-- | tests/auto/qtextstream/test/test.pro | 2 | ||||
-rw-r--r-- | tests/auto/qtextstream/tst_qtextstream.cpp | 42 |
3 files changed, 60 insertions, 7 deletions
diff --git a/tests/auto/qtcpserver/tst_qtcpserver.cpp b/tests/auto/qtcpserver/tst_qtcpserver.cpp index eb4d456..952df13 100644 --- a/tests/auto/qtcpserver/tst_qtcpserver.cpp +++ b/tests/auto/qtcpserver/tst_qtcpserver.cpp @@ -62,6 +62,7 @@ #include <qtcpserver.h> #include <qhostaddress.h> #include <qprocess.h> +#include <qdir.h> #include <qstringlist.h> #include <qplatformdefs.h> #include <qhostinfo.h> @@ -122,6 +123,7 @@ private: QNetworkSession *networkSession; QNetworkConfigurationManager *netConfMan; #endif + QString m_crashingServer; }; // Testing get/set functions @@ -158,6 +160,23 @@ void tst_QTcpServer::initTestCase_data() void tst_QTcpServer::initTestCase() { + if (m_crashingServer.isEmpty()) { + QString crashingServer = QLatin1String("crashingServer/crashingServer"); + QDir workingDirectory = QDir::current(); + // Windows: cd up to be able to locate the binary of the sub-process. +#ifdef Q_OS_WIN + crashingServer.append(QLatin1String(".exe")); + if (workingDirectory.absolutePath().endsWith(QLatin1String("/debug"), Qt::CaseInsensitive) + || workingDirectory.absolutePath().endsWith(QLatin1String("/release"), Qt::CaseInsensitive)) { + QVERIFY(workingDirectory.cdUp()); + QVERIFY(QDir::setCurrent(workingDirectory.absolutePath())); + } +#endif + m_crashingServer = workingDirectory.absoluteFilePath(crashingServer); + QVERIFY2(QFileInfo(m_crashingServer).exists(), + qPrintable(QString::fromLatin1("Crashing server executable '%1' does not exist!") + .arg(QDir::toNativeSeparators(m_crashingServer)))); + } #ifndef QT_NO_BEARERMANAGEMENT netConfMan = new QNetworkConfigurationManager(this); netConfMan->updateConfigurations(); @@ -537,7 +556,7 @@ void tst_QTcpServer::addressReusable() QFile::remove(signalName); // The crashingServer process will crash once it gets a connection. QProcess process; - process.start("crashingServer/crashingServer"); + process.start(m_crashingServer); int waitCount = 5; while (waitCount-- && !QFile::exists(signalName)) QTest::qWait(1000); @@ -546,7 +565,7 @@ void tst_QTcpServer::addressReusable() #else // The crashingServer process will crash once it gets a connection. QProcess process; - process.start("crashingServer/crashingServer"); + process.start(m_crashingServer); QVERIFY(process.waitForReadyRead(5000)); #endif diff --git a/tests/auto/qtextstream/test/test.pro b/tests/auto/qtextstream/test/test.pro index 635404e..41aeacf 100644 --- a/tests/auto/qtextstream/test/test.pro +++ b/tests/auto/qtextstream/test/test.pro @@ -36,5 +36,3 @@ wince*: { }else { DEFINES += SRCDIR=\\\"$$PWD/../\\\" } - -win32:CONFIG+=insignificant_test # QTQAINFRA-428 diff --git a/tests/auto/qtextstream/tst_qtextstream.cpp b/tests/auto/qtextstream/tst_qtextstream.cpp index b8322f5..c34cae5 100644 --- a/tests/auto/qtextstream/tst_qtextstream.cpp +++ b/tests/auto/qtextstream/tst_qtextstream.cpp @@ -89,6 +89,7 @@ public: virtual ~tst_QTextStream(); public slots: + void initTestCase(); void init(); void cleanup(); @@ -342,6 +343,9 @@ private: QBuffer *inBuffer; QString *inString; bool file_is_empty; + QString m_readAllStdinProcess; + QString m_stdinProcess; + QString m_readLineStdinProcess; }; // Testing get/set functions @@ -484,6 +488,38 @@ tst_QTextStream::~tst_QTextStream() { } +void tst_QTextStream::initTestCase() +{ + QDir workingDirectory = QDir::current(); + QString readAllStdinProcess = QLatin1String("readAllStdinProcess/readAllStdinProcess"); + QString stdinProcess = QLatin1String("stdinProcess/stdinProcess"); + QString readLineStdinProcess = QLatin1String("readLineStdinProcess/readLineStdinProcess"); + // Windows: cd up to be able to locate the binary of the sub-process. +#ifdef Q_OS_WIN + const QString suffix = QLatin1String(".exe"); + readAllStdinProcess.append(suffix); + stdinProcess.append(suffix); + readLineStdinProcess.append(suffix); + if (workingDirectory.absolutePath().endsWith(QLatin1String("/debug"), Qt::CaseInsensitive) + || workingDirectory.absolutePath().endsWith(QLatin1String("/release"), Qt::CaseInsensitive)) { + QVERIFY(workingDirectory.cdUp()); + QVERIFY(QDir::setCurrent(workingDirectory.absolutePath())); + } +#endif + m_readAllStdinProcess = workingDirectory.absoluteFilePath(readAllStdinProcess); + m_readLineStdinProcess = workingDirectory.absoluteFilePath(readLineStdinProcess); + m_stdinProcess = workingDirectory.absoluteFilePath(stdinProcess); + QVERIFY2(QFileInfo(m_readAllStdinProcess).exists(), + qPrintable(QString::fromLatin1("ReadAllStdinProcess executable '%1' does not exist!") + .arg(QDir::toNativeSeparators(m_readAllStdinProcess)))); + QVERIFY2(QFileInfo(m_readLineStdinProcess).exists(), + qPrintable(QString::fromLatin1("ReadLineStdinProcess executable '%1' does not exist!") + .arg(QDir::toNativeSeparators(m_readLineStdinProcess)))); + QVERIFY2(QFileInfo(m_stdinProcess).exists(), + qPrintable(QString::fromLatin1("StdinProcess executable '%1' does not exist!") + .arg(QDir::toNativeSeparators(m_stdinProcess)))); +} + void tst_QTextStream::init() { // Initialize Qt 3 data @@ -1544,7 +1580,7 @@ void tst_QTextStream::readStdin() QSKIP("Qt/CE and Symbian have no stdin/out support for processes", SkipAll); #endif QProcess stdinProcess; - stdinProcess.start("stdinProcess/stdinProcess"); + stdinProcess.start(m_stdinProcess); stdinProcess.setReadChannel(QProcess::StandardError); QTextStream stream(&stdinProcess); @@ -1570,7 +1606,7 @@ void tst_QTextStream::readAllFromStdin() QSKIP("Qt/CE and Symbian have no stdin/out support for processes", SkipAll); #endif QProcess stdinProcess; - stdinProcess.start("readAllStdinProcess/readAllStdinProcess", QIODevice::ReadWrite | QIODevice::Text); + stdinProcess.start(m_readAllStdinProcess, QIODevice::ReadWrite | QIODevice::Text); stdinProcess.setReadChannel(QProcess::StandardError); QTextStream stream(&stdinProcess); @@ -1591,7 +1627,7 @@ void tst_QTextStream::readLineFromStdin() QSKIP("Qt/CE and Symbian have no stdin/out support for processes", SkipAll); #endif QProcess stdinProcess; - stdinProcess.start("readLineStdinProcess/readLineStdinProcess", QIODevice::ReadWrite | QIODevice::Text); + stdinProcess.start(m_readLineStdinProcess, QIODevice::ReadWrite | QIODevice::Text); stdinProcess.setReadChannel(QProcess::StandardError); stdinProcess.write("abc\n"); |