Commit 898179f8 authored by hjk's avatar hjk
Browse files

debugger: work on auto test

parent ad8eec7e
......@@ -1172,7 +1172,7 @@ void DebuggerManager::setStatus(int status)
if (status == m_status)
return;
if (!isAllowedTransition(m_status, status)) {
if (0 && !isAllowedTransition(m_status, status)) {
const QString msg = QString::fromLatin1("%1: UNEXPECTED TRANSITION: %2 -> %3").
arg(QLatin1String(Q_FUNC_INFO), QLatin1String(stateName(m_status)), QLatin1String(stateName(status)));
qWarning("%s", qPrintable(msg));
......@@ -1449,4 +1449,27 @@ void DebuggerManager::reloadRegisters()
}
//////////////////////////////////////////////////////////////////////
//
// Testing
//
//////////////////////////////////////////////////////////////////////
void DebuggerManager::runTest(const QString &fileName)
{
m_executable = fileName;
m_processArgs = QStringList() << "--run-debuggee";
m_workingDir = QString();
qDebug() << "TESTING: " << fileName;
//QFile file(fileName);
//file.open(QIODevice::ReadOnly);
//QTextStream ts(&file);
//foreach (QString line, ts.readAll().split('\n')) {
// qDebug() << "TESTING: " << line;
// if (line.startsWith("Executable="))
//}
startNewDebugger(StartInternal);
}
#include "debuggermanager.moc"
......@@ -341,6 +341,7 @@ public:
private:
void init();
void setDebuggerType(DebuggerType type);
void runTest(const QString &fileName);
QDockWidget *createDockForWidget(QWidget *widget);
Q_SLOT void createNewDock(QWidget *widget);
......
......@@ -797,6 +797,10 @@ bool DebuggerPlugin::initialize(const QStringList &arguments, QString *errorMess
void DebuggerPlugin::extensionsInitialized()
{
// time gdb -i mi -ex 'debuggerplugin.cpp:800' -ex r -ex q bin/qtcreator.bin
qDebug() << "EXTENSIONS INITIALIZED";
QByteArray env = qgetenv("QTC_DEBUGGER_TEST");
if (!env.isEmpty())
m_manager->runTest(QString::fromLocal8Bit(env));
}
/*! Activates the previous mode when the current mode is the debug mode. */
......
QT += testlib
QT = core testlib
DEBUGGERDIR = ../../../src/plugins/debugger
UTILSDIR = ../../../src/libs
......
......@@ -2,7 +2,10 @@
#include "gdbmi.h"
#include <QtCore/QObject>
#include <QtCore/QProcess>
#include <QtCore/QFileInfo>
#include <QtTest/QtTest>
//#include <QtTest/qtest_gui.h>
using namespace Debugger;
using namespace Debugger::Internal;
......@@ -35,7 +38,6 @@ static const char test5[] =
"file=\"test1.cpp\",fullname=\"/home/apoenitz/work/test1/test1.cpp\","
"line=\"209\"}]";
static const char test8[] =
"[data={locals={{name=\"a\"},{name=\"w\"}}}]";
......@@ -77,9 +79,48 @@ private slots:
void mi10() { testMi(test10); }
void mi11() { testMi(test11); }
void mi12() { testMi(test12); }
void runQtc();
};
QTEST_MAIN(tst_Debugger)
void tst_Debugger::runQtc()
{
QString test = QFileInfo(qApp->arguments().at(0)).absoluteFilePath();
//QString qtc = QFileInfo(test + "../../bin/qtcreator.bin").absoluteFilePath();
QString qtc = QFileInfo(test).absolutePath() + "/../../../bin/qtcreator.bin";
qtc = QFileInfo(qtc).absoluteFilePath();
QProcess proc;
QStringList env = QProcess::systemEnvironment();
env.append("QTC_DEBUGGER_TEST=" + test);
proc.setEnvironment(env);
qDebug() << "APP: " << test << qtc;
foreach (QString item, env)
qDebug() << item;
proc.start(qtc);
proc.waitForStarted();
QCOMPARE(proc.state(), QProcess::Running);
proc.waitForFinished();
QCOMPARE(proc.state(), QProcess::NotRunning);
}
void runDebuggee()
{
qDebug() << "RUNNING DEBUGGEE";
}
int main(int argc, char *argv[])
{
QCoreApplication app(argc, argv);
QStringList args = app.arguments();
if (args.size() == 2 && args.at(1) == "--run-debuggee") {
runDebuggee();
return 0;
}
tst_Debugger test;
return QTest::qExec(&test, argc, argv);
}
#include "main.moc"
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment