Commit 1ef6c2b1 authored by hjk's avatar hjk Committed by hjk

debugger: work on autotest integration

Change-Id: Iafd07a55e20cd2a65c3bcd23208c24855aeb429f
Reviewed-by: default avatarhjk <qthjk@ovi.com>
parent 800dfe4c
......@@ -66,6 +66,13 @@ class Symbol;
class DebuggerToolTipManager;
class GlobalDebuggerOptions;
enum TestCases
{
// Gdb
TestNoBoundsOfCurrentFunction = 1,
TestPythonDumpers
};
class DebuggerCore : public QObject
{
Q_OBJECT
......
......@@ -89,6 +89,8 @@
#include <extensionsystem/pluginmanager.h>
#include <projectexplorer/abi.h>
#include <projectexplorer/applicationrunconfiguration.h>
#include <projectexplorer/buildconfiguration.h>
#include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/projectexplorer.h>
#include <projectexplorer/projectexplorersettings.h>
......@@ -127,6 +129,12 @@
#include <QtGui/QTreeWidget>
#include <QtGui/QInputDialog>
#ifdef WITH_TESTS
#include <QtTest/QTest>
#include <QtTest/QSignalSpy>
#include <QtTest/QTestEventLoop>
#endif
#include <climits>
#define DEBUG_STATE 1
......@@ -824,6 +832,14 @@ public slots:
void evaluateExpression(const QString &expression);
void coreShutdown();
#ifdef WITH_TESTS
public slots:
void testStuff(int testCase);
void testProjectLoaded(ProjectExplorer::Project *project);
void testRunControlFinished();
#endif
public slots:
void updateDebugActions();
......@@ -3632,6 +3648,106 @@ QAction *DebuggerPlugin::visibleDebugAction()
return theDebuggerCore->m_visibleStartAction;
}
#ifdef WITH_TESTS
static bool g_success;
class TestCase
{
public:
TestCases id;
DebuggerEngineType suitableEngine;
bool needsProject;
};
static TestCase theTests[] =
{
{ TestNoBoundsOfCurrentFunction, GdbEngineType, true },
{ TestPythonDumpers, GdbEngineType, true },
};
void DebuggerPluginPrivate::testStuff(int testCase)
{
ProjectExplorerPlugin *pe = ProjectExplorerPlugin::instance();
connect(pe, SIGNAL(currentProjectChanged(ProjectExplorer::Project*)),
this, SLOT(testProjectLoaded(ProjectExplorer::Project*)));
QString proFile = ICore::instance()->resourcePath() + "/../../tests/manual/debugger/simple/simple.pro";
QString error;
if (!pe->openProject(proFile,&error)) {
qWarning("Cannot open %s: %s", qPrintable(proFile), qPrintable(error));
QVERIFY(false);
return;
}
g_success == false;
QTestEventLoop::instance().enterLoop(20);
//QCOMPARE(spy.count(), 1); // make sure the signal was emitted exactly one time
//QList<QVariant> arguments = spy.takeFirst(); // take the first signal
//QVERIFY(arguments.at(0).toBool() == true); // verify the first argument
QVERIFY(g_success);
}
void DebuggerPluginPrivate::testProjectLoaded(Project *project)
{
if (!project) {
qWarning("Changed to null project.");
return;
}
QString fileName = project->file()->fileName();
QVERIFY(!fileName.isEmpty());
qWarning("Project %s loaded", qPrintable(fileName));
Target *target = project->activeTarget();
QVERIFY(target);
qWarning("Target %s selected", qPrintable(target->displayName()));
BuildConfiguration *bc = target->activeBuildConfiguration();
QVERIFY(bc);
RunConfiguration *rc = target->activeRunConfiguration();
QVERIFY(rc);
LocalApplicationRunConfiguration *lrc =
qobject_cast<LocalApplicationRunConfiguration *>(rc);
QVERIFY(lrc);
ToolChain *tc = bc->toolChain();
QVERIFY(tc);
DebuggerStartParameters sp;
sp.toolChainAbi = tc->targetAbi();
sp.executable = lrc->executable();
RunControl *rctl = createDebugger(sp);
QVERIFY(rctl);
connect(rctl, SIGNAL(finished()), this, SLOT(testRunControlFinished()));
ProjectExplorerPlugin::instance()->startRunControl(rctl, DebugRunMode);
}
void DebuggerPluginPrivate::testRunControlFinished()
{
ProjectExplorerPlugin *pe = ProjectExplorerPlugin::instance();
qWarning("Run control finished.");
g_success = true;
disconnect(pe, SIGNAL(currentProjectChanged(ProjectExplorer::Project*)),
this, SLOT(testProjectLoaded(ProjectExplorer::Project*)));
QTestEventLoop::instance().exitLoop();
}
void DebuggerPlugin::testPythonDumpers()
{
//theDebuggerCore->testStuff(TestDumpers);
theDebuggerCore->testStuff(TestPythonDumpers);
}
#endif
} // namespace Debugger
#include "debuggerplugin.moc"
......
......@@ -74,6 +74,11 @@ private:
void remoteCommand(const QStringList &options, const QStringList &arguments);
ShutdownFlag aboutToShutdown();
void extensionsInitialized();
#ifdef WITH_TESTS
private slots:
void testPythonDumpers();
#endif
};
} // namespace Debugger
......
......@@ -2114,7 +2114,7 @@ void GdbEngine::executeNext()
if (isReverseDebugging()) {
postCommand("reverse-next", RunRequest, CB(handleExecuteNext));
} else {
scheduleTestResponse(GdbTestNoBoundsOfCurrentFunction,
scheduleTestResponse(TestNoBoundsOfCurrentFunction,
"@TOKEN@^error,msg=\"Warning:\\nCannot insert breakpoint -39.\\n"
" Error accessing memory address 0x11673fc: Input/output error.\\n\"");
postCommand("-exec-next", RunRequest, CB(handleExecuteNext));
......
......@@ -78,12 +78,6 @@ enum DebuggingHelperState
DebuggingHelperUnavailable
};
enum GdbTestCase
{
GdbTestNoBoundsOfCurrentFunction = 1
};
class UpdateParameters
{
public:
......
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