summaryrefslogtreecommitdiffstats
path: root/tools/runonphone/trksignalhandler.cpp
diff options
context:
space:
mode:
authorShane Kearns <shane.kearns@accenture.com>2009-12-22 16:14:59 (GMT)
committerShane Kearns <shane.kearns@sosco.com>2010-01-04 14:49:52 (GMT)
commit0e94349de0b602f1b6af747b66ef03b22133cc3a (patch)
treebddd755f649be409c2af2fda9f4ffa8f32d18afc /tools/runonphone/trksignalhandler.cpp
parent44f7b73940c67b8e81f52dfc6370453ff07d3aa2 (diff)
downloadQt-0e94349de0b602f1b6af747b66ef03b22133cc3a.zip
Qt-0e94349de0b602f1b6af747b66ef03b22133cc3a.tar.gz
Qt-0e94349de0b602f1b6af747b66ef03b22133cc3a.tar.bz2
Deal with test cases that crash or hang
Added an optional timeout to runonphone - the application will be killed after this time. Used when autotesting unattended, as some tests can hang. Handled the just in time debug halting the application when it is about to crash, by terminating the application. In future, we could capture a call stack or something here. Also added quiet/verbose options to control the amount of output from runonphone. Reviewed-by: Janne Koskinen
Diffstat (limited to 'tools/runonphone/trksignalhandler.cpp')
-rw-r--r--tools/runonphone/trksignalhandler.cpp98
1 files changed, 83 insertions, 15 deletions
diff --git a/tools/runonphone/trksignalhandler.cpp b/tools/runonphone/trksignalhandler.cpp
index afb1918..099be7a 100644
--- a/tools/runonphone/trksignalhandler.cpp
+++ b/tools/runonphone/trksignalhandler.cpp
@@ -41,81 +41,149 @@
#include <QDebug>
#include <QCoreApplication>
+#include <QObject>
#include "trksignalhandler.h"
+class TrkSignalHandlerPrivate
+{
+ friend class TrkSignalHandler;
+public:
+ TrkSignalHandlerPrivate();
+ ~TrkSignalHandlerPrivate();
+private:
+ QTextStream out;
+ QTextStream err;
+ int loglevel;
+};
+
void TrkSignalHandler::copyingStarted()
{
- qDebug() << "Copying...\n";
+ if(d->loglevel > 0)
+ d->out << "Copying..." << endl;
}
void TrkSignalHandler::canNotConnect(const QString &errorMessage)
{
- qWarning() << "Cannot Connect - " << errorMessage;
+ d->err << "Cannot Connect - " << errorMessage << endl;
}
void TrkSignalHandler::canNotCreateFile(const QString &filename, const QString &errorMessage)
{
- qWarning() << "Cannot create file (" << filename << ") - " << errorMessage << "\n";
+ d->err << "Cannot create file (" << filename << ") - " << errorMessage << endl;
}
void TrkSignalHandler::canNotWriteFile(const QString &filename, const QString &errorMessage)
{
- qWarning() << "Cannot write file (" << filename << ") - " << errorMessage << "\n";
+ d->err << "Cannot write file (" << filename << ") - " << errorMessage << endl;
}
void TrkSignalHandler::canNotCloseFile(const QString &filename, const QString &errorMessage)
{
- qWarning() << "Cannot close file (" << filename << ") - " << errorMessage << "\n";
+ d->err << "Cannot close file (" << filename << ") - " << errorMessage << endl;
}
void TrkSignalHandler::installingStarted()
{
- qDebug() << "Installing...\n";
+ if(d->loglevel > 0)
+ d->out << "Installing..." << endl;
}
void TrkSignalHandler::canNotInstall(const QString &packageFilename, const QString &errorMessage)
{
- qWarning() << "Cannot install file (" << packageFilename << ") - " << errorMessage << "\n";
+ d->err << "Cannot install file (" << packageFilename << ") - " << errorMessage << endl;
}
void TrkSignalHandler::installingFinished()
{
- qDebug() << "Installing finished\n";
+ if(d->loglevel > 0)
+ d->out << "Installing finished" << endl;
}
void TrkSignalHandler::startingApplication()
{
- qDebug() << "Starting app...\n";
+ if(d->loglevel > 0)
+ d->out << "Starting app..." << endl;
}
void TrkSignalHandler::applicationRunning(uint pid)
{
- qDebug() << "Running...\n";
+ if(d->loglevel > 0)
+ d->out << "Running..." << endl;
}
void TrkSignalHandler::canNotRun(const QString &errorMessage)
{
- qWarning() << "Cannot run - " << errorMessage << "\n";
+ d->err << "Cannot run - " << errorMessage << endl;
}
void TrkSignalHandler::finished()
{
- qDebug() << "Done.\n";
+ if(d->loglevel > 0)
+ d->out << "Done." << endl;
QCoreApplication::quit();
}
void TrkSignalHandler::applicationOutputReceived(const QString &output)
{
- qDebug() << "> " << output;
+ d->out << output;
}
void TrkSignalHandler::copyProgress(int percent)
{
- qDebug() << percent << "%";
+ if(d->loglevel > 0) {
+ d->out << percent << "% ";
+ d->out.flush();
+ if(percent==100)
+ d->out << endl;
+ }
}
void TrkSignalHandler::stateChanged(int state)
{
- qDebug() << "State" << state;
+ if(d->loglevel > 1)
+ d->out << "State" << state << endl;
+}
+
+void TrkSignalHandler::setLogLevel(int level)
+{
+ d->loglevel = level;
+}
+
+void TrkSignalHandler::stopped(uint pc, uint pid, uint tid, const QString& reason)
+{
+ d->err << "STOPPED: pc=" << hex << pc << " pid=" << pid
+ << " tid=" << tid << dec << " - " << reason << endl;
+ // if it was a breakpoint, then we could continue with "emit resume(pid, tid);"
+ // since we have set no breakpoints, it will be a just in time debug of a panic / exception
+ emit terminate();
+}
+
+void TrkSignalHandler::timeout()
+{
+ d->err << "FAILED: stopping test due to timeout" << endl;
+ emit terminate();
}
+TrkSignalHandlerPrivate::TrkSignalHandlerPrivate() :
+ out(stdout),
+ err(stderr),
+ loglevel(0)
+{
+
+}
+
+TrkSignalHandlerPrivate::~TrkSignalHandlerPrivate()
+{
+ out.flush();
+ err.flush();
+}
+
+TrkSignalHandler::TrkSignalHandler()
+{
+ d = new TrkSignalHandlerPrivate();
+}
+
+TrkSignalHandler::~TrkSignalHandler()
+{
+ delete d;
+}