forked from qt-creator/qt-creator
debugger: re-organize autotests. also adjust to recent QScopedPointer changes
This commit is contained in:
@@ -43,6 +43,7 @@
|
|||||||
#define GDBMACROS_P_H
|
#define GDBMACROS_P_H
|
||||||
|
|
||||||
#include <QtCore/QObject>
|
#include <QtCore/QObject>
|
||||||
|
#include <QtCore/QPointer>
|
||||||
|
|
||||||
#ifndef QT_BOOTSTRAPPED
|
#ifndef QT_BOOTSTRAPPED
|
||||||
|
|
||||||
|
@@ -1,17 +1,5 @@
|
|||||||
QT = core testlib gui
|
|
||||||
|
|
||||||
|
TEMPLATE = subdirs
|
||||||
|
|
||||||
DEBUGGERDIR = ../../../src/plugins/debugger
|
SUBDIRS = dumpers.pro plugin.pro
|
||||||
UTILSDIR = ../../../src/libs
|
|
||||||
MACROSDIR = ../../../share/qtcreator/gdbmacros
|
|
||||||
|
|
||||||
SOURCES += \
|
|
||||||
$$DEBUGGERDIR/gdb/gdbmi.cpp \
|
|
||||||
$$DEBUGGERDIR/tcf/json.cpp \
|
|
||||||
$$MACROSDIR/gdbmacros.cpp \
|
|
||||||
main.cpp \
|
|
||||||
|
|
||||||
DEFINES += MACROSDEBUG
|
|
||||||
|
|
||||||
INCLUDEPATH += $$DEBUGGERDIR $$UTILSDIR $$MACROSDIR
|
|
||||||
|
|
||||||
|
16
tests/auto/debugger/dumpers.pro
Normal file
16
tests/auto/debugger/dumpers.pro
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
QT += testlib
|
||||||
|
|
||||||
|
DEBUGGERDIR = ../../../src/plugins/debugger
|
||||||
|
UTILSDIR = ../../../src/libs
|
||||||
|
MACROSDIR = ../../../share/qtcreator/gdbmacros
|
||||||
|
|
||||||
|
SOURCES += \
|
||||||
|
$$DEBUGGERDIR/gdb/gdbmi.cpp \
|
||||||
|
$$DEBUGGERDIR/tcf/json.cpp \
|
||||||
|
$$MACROSDIR/gdbmacros.cpp \
|
||||||
|
tst_dumpers.cpp \
|
||||||
|
|
||||||
|
DEFINES += MACROSDEBUG
|
||||||
|
|
||||||
|
INCLUDEPATH += $$DEBUGGERDIR $$UTILSDIR $$MACROSDIR
|
||||||
|
|
14
tests/auto/debugger/plugin.pro
Normal file
14
tests/auto/debugger/plugin.pro
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
QT += testlib
|
||||||
|
|
||||||
|
|
||||||
|
DEBUGGERDIR = ../../../src/plugins/debugger
|
||||||
|
UTILSDIR = ../../../src/libs
|
||||||
|
MACROSDIR = ../../../share/qtcreator/gdbmacros
|
||||||
|
|
||||||
|
SOURCES += \
|
||||||
|
tst_plugin.cpp \
|
||||||
|
|
||||||
|
DEFINES += MACROSDEBUG
|
||||||
|
|
||||||
|
INCLUDEPATH += $$DEBUGGERDIR $$UTILSDIR $$MACROSDIR
|
||||||
|
|
@@ -1,33 +1,16 @@
|
|||||||
#include <ctype.h>
|
|
||||||
|
|
||||||
#include <QtCore/QObject>
|
|
||||||
#include <QtCore/QProcess>
|
|
||||||
#include <QtCore/QFileInfo>
|
|
||||||
#include <QtCore/QMap>
|
|
||||||
#include <QtCore/QMetaMethod>
|
|
||||||
#include <QtCore/QModelIndex>
|
|
||||||
#if QT_VERSION >= 0x040500
|
|
||||||
#include <QtCore/QSharedPointer>
|
|
||||||
#endif
|
|
||||||
#include <QtCore/QStringList>
|
|
||||||
#include <QtCore/QTextCodec>
|
|
||||||
#include <QtGui/QApplication>
|
|
||||||
#include <QtGui/QDialog>
|
|
||||||
#include <QtGui/QImage>
|
|
||||||
#include <QtGui/QPixmap>
|
|
||||||
#include <QtGui/QStandardItemModel>
|
|
||||||
#include <QtGui/QStringListModel>
|
|
||||||
#include <QtTest/QtTest>
|
|
||||||
|
|
||||||
//#include <QtTest/qtest_gui.h>
|
|
||||||
|
|
||||||
#include <QtCore/private/qobject_p.h>
|
|
||||||
|
|
||||||
#include "gdb/gdbmi.h"
|
#include "gdb/gdbmi.h"
|
||||||
#include "tcf/json.h"
|
#include "tcf/json.h"
|
||||||
#include "gdbmacros.h"
|
#include "gdbmacros.h"
|
||||||
#include "gdbmacros_p.h"
|
#include "gdbmacros_p.h"
|
||||||
|
|
||||||
|
#include <QtCore/private/qobject_p.h>
|
||||||
|
|
||||||
|
#include <QtGui/QStandardItemModel>
|
||||||
|
#include <QtGui/QStringListModel>
|
||||||
|
|
||||||
|
#include <QtTest/QtTest>
|
||||||
|
//#include <QtTest/qtest_gui.h>
|
||||||
|
|
||||||
#undef NS
|
#undef NS
|
||||||
#ifdef QT_NAMESPACE
|
#ifdef QT_NAMESPACE
|
||||||
# define STRINGIFY0(s) #s
|
# define STRINGIFY0(s) #s
|
||||||
@@ -178,16 +161,7 @@ private slots:
|
|||||||
void dumpQWeakPointer();
|
void dumpQWeakPointer();
|
||||||
void initTestCase();
|
void initTestCase();
|
||||||
|
|
||||||
public slots:
|
|
||||||
void runQtc();
|
|
||||||
|
|
||||||
public slots:
|
|
||||||
void readStandardOutput();
|
|
||||||
void readStandardError();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QProcess m_proc; // the Qt Creator process
|
|
||||||
|
|
||||||
void dumpQAbstractItemHelper(QModelIndex &index);
|
void dumpQAbstractItemHelper(QModelIndex &index);
|
||||||
void dumpQAbstractItemModelHelper(QAbstractItemModel &m);
|
void dumpQAbstractItemModelHelper(QAbstractItemModel &m);
|
||||||
void dumpQByteArrayHelper(QByteArray &ba);
|
void dumpQByteArrayHelper(QByteArray &ba);
|
||||||
@@ -220,17 +194,6 @@ private:
|
|||||||
void dumpQTextCodecHelper(QTextCodec *codec);
|
void dumpQTextCodecHelper(QTextCodec *codec);
|
||||||
};
|
};
|
||||||
|
|
||||||
static QByteArray stripped(QByteArray ba)
|
|
||||||
{
|
|
||||||
for (int i = ba.size(); --i >= 0; ) {
|
|
||||||
if (ba.at(i) == '\n' || ba.at(i) == ' ')
|
|
||||||
ba.chop(1);
|
|
||||||
else
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return ba;
|
|
||||||
}
|
|
||||||
|
|
||||||
void tst_Debugger::infoBreak()
|
void tst_Debugger::infoBreak()
|
||||||
{
|
{
|
||||||
// This tests the regular expression used in GdbEngine::extractDataFromInfoBreak
|
// This tests the regular expression used in GdbEngine::extractDataFromInfoBreak
|
||||||
@@ -1765,7 +1728,12 @@ class Cheater : public QObject
|
|||||||
public:
|
public:
|
||||||
static const QObjectPrivate *getPrivate(const QObject &o)
|
static const QObjectPrivate *getPrivate(const QObject &o)
|
||||||
{
|
{
|
||||||
return dynamic_cast<const QObjectPrivate *>(static_cast<const Cheater&>(o).d_ptr);
|
const Cheater &cheater = static_cast<const Cheater&>(o);
|
||||||
|
#if QT_VERSION >= 0x040600
|
||||||
|
return dynamic_cast<const QObjectPrivate *>(cheater.d_ptr.data());
|
||||||
|
#else
|
||||||
|
return dynamic_cast<const QObjectPrivate *>(cheater.d_ptr);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -2408,54 +2376,13 @@ void tst_Debugger::initTestCase()
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_Debugger::readStandardOutput()
|
|
||||||
{
|
|
||||||
qDebug() << "qtcreator-out: " << stripped(m_proc.readAllStandardOutput());
|
|
||||||
}
|
|
||||||
|
|
||||||
void tst_Debugger::readStandardError()
|
|
||||||
{
|
|
||||||
qDebug() << "qtcreator-err: " << stripped(m_proc.readAllStandardError());
|
|
||||||
}
|
|
||||||
|
|
||||||
void tst_Debugger::runQtc()
|
|
||||||
{
|
|
||||||
QString test = QFileInfo(qApp->arguments().at(0)).absoluteFilePath();
|
|
||||||
QString qtc = QFileInfo(test).absolutePath() + "/../../../bin/qtcreator.bin";
|
|
||||||
qtc = QFileInfo(qtc).absoluteFilePath();
|
|
||||||
QStringList env = QProcess::systemEnvironment();
|
|
||||||
env.append("QTC_DEBUGGER_TEST=" + test);
|
|
||||||
m_proc.setEnvironment(env);
|
|
||||||
connect(&m_proc, SIGNAL(readyReadStandardOutput()),
|
|
||||||
this, SLOT(readStandardOutput()));
|
|
||||||
connect(&m_proc, SIGNAL(readyReadStandardError()),
|
|
||||||
this, SLOT(readStandardError()));
|
|
||||||
m_proc.start(qtc);
|
|
||||||
m_proc.waitForStarted();
|
|
||||||
QCOMPARE(m_proc.state(), QProcess::Running);
|
|
||||||
m_proc.waitForFinished();
|
|
||||||
QCOMPARE(m_proc.state(), QProcess::NotRunning);
|
|
||||||
}
|
|
||||||
|
|
||||||
void runDebuggee()
|
|
||||||
{
|
|
||||||
qDebug() << "RUNNING DEBUGGEE";
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
QCoreApplication app(argc, argv);
|
QApplication app(argc, argv);
|
||||||
QStringList args = app.arguments();
|
|
||||||
|
|
||||||
if (args.size() == 2 && args.at(1) == "--run-debuggee") {
|
|
||||||
runDebuggee();
|
|
||||||
app.exec();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
tst_Debugger test;
|
tst_Debugger test;
|
||||||
return QTest::qExec(&test, argc, argv);
|
return QTest::qExec(&test, argc, argv);
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "main.moc"
|
#include "tst_dumpers.moc"
|
||||||
|
|
125
tests/auto/debugger/tst_plugin.cpp
Normal file
125
tests/auto/debugger/tst_plugin.cpp
Normal file
@@ -0,0 +1,125 @@
|
|||||||
|
#include <ctype.h>
|
||||||
|
|
||||||
|
#include <QtCore/QObject>
|
||||||
|
#include <QtCore/QProcess>
|
||||||
|
#include <QtCore/QFileInfo>
|
||||||
|
#include <QtCore/QMap>
|
||||||
|
#include <QtCore/QMetaMethod>
|
||||||
|
#include <QtCore/QModelIndex>
|
||||||
|
#if QT_VERSION >= 0x040500
|
||||||
|
#include <QtCore/QSharedPointer>
|
||||||
|
#endif
|
||||||
|
#include <QtCore/QStringList>
|
||||||
|
#include <QtCore/QTextCodec>
|
||||||
|
#include <QtGui/QApplication>
|
||||||
|
#include <QtGui/QDialog>
|
||||||
|
#include <QtGui/QImage>
|
||||||
|
#include <QtGui/QPixmap>
|
||||||
|
#include <QtGui/QStandardItemModel>
|
||||||
|
#include <QtGui/QStringListModel>
|
||||||
|
#include <QtTest/QtTest>
|
||||||
|
|
||||||
|
//#include <QtTest/qtest_gui.h>
|
||||||
|
|
||||||
|
#include <QtCore/private/qobject_p.h>
|
||||||
|
|
||||||
|
#include "gdb/gdbmi.h"
|
||||||
|
#include "tcf/json.h"
|
||||||
|
#include "gdbmacros.h"
|
||||||
|
#include "gdbmacros_p.h"
|
||||||
|
|
||||||
|
#undef NS
|
||||||
|
#ifdef QT_NAMESPACE
|
||||||
|
# define STRINGIFY0(s) #s
|
||||||
|
# define STRINGIFY1(s) STRINGIFY0(s)
|
||||||
|
# define NS STRINGIFY1(QT_NAMESPACE) "::"
|
||||||
|
#else
|
||||||
|
# define NS ""
|
||||||
|
#endif
|
||||||
|
|
||||||
|
using namespace Debugger;
|
||||||
|
using namespace Debugger::Internal;
|
||||||
|
|
||||||
|
|
||||||
|
static QByteArray stripped(QByteArray ba)
|
||||||
|
{
|
||||||
|
for (int i = ba.size(); --i >= 0; ) {
|
||||||
|
if (ba.at(i) == '\n' || ba.at(i) == ' ')
|
||||||
|
ba.chop(1);
|
||||||
|
else
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return ba;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class tst_Plugin : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
tst_Plugin() {}
|
||||||
|
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void runQtc();
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void readStandardOutput();
|
||||||
|
void readStandardError();
|
||||||
|
|
||||||
|
private:
|
||||||
|
QProcess m_proc; // the Qt Creator process
|
||||||
|
};
|
||||||
|
|
||||||
|
void tst_Plugin::readStandardOutput()
|
||||||
|
{
|
||||||
|
qDebug() << "qtcreator-out: " << stripped(m_proc.readAllStandardOutput());
|
||||||
|
}
|
||||||
|
|
||||||
|
void tst_Plugin::readStandardError()
|
||||||
|
{
|
||||||
|
qDebug() << "qtcreator-err: " << stripped(m_proc.readAllStandardError());
|
||||||
|
}
|
||||||
|
|
||||||
|
void tst_Plugin::runQtc()
|
||||||
|
{
|
||||||
|
QString test = QFileInfo(qApp->arguments().at(0)).absoluteFilePath();
|
||||||
|
QString qtc = QFileInfo(test).absolutePath() + "/../../../bin/qtcreator.bin";
|
||||||
|
qtc = QFileInfo(qtc).absoluteFilePath();
|
||||||
|
QStringList env = QProcess::systemEnvironment();
|
||||||
|
env.append("QTC_DEBUGGER_TEST=" + test);
|
||||||
|
m_proc.setEnvironment(env);
|
||||||
|
connect(&m_proc, SIGNAL(readyReadStandardOutput()),
|
||||||
|
this, SLOT(readStandardOutput()));
|
||||||
|
connect(&m_proc, SIGNAL(readyReadStandardError()),
|
||||||
|
this, SLOT(readStandardError()));
|
||||||
|
m_proc.start(qtc);
|
||||||
|
m_proc.waitForStarted();
|
||||||
|
QCOMPARE(m_proc.state(), QProcess::Running);
|
||||||
|
m_proc.waitForFinished();
|
||||||
|
QCOMPARE(m_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();
|
||||||
|
app.exec();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
tst_Plugin test;
|
||||||
|
return QTest::qExec(&test, argc, argv);
|
||||||
|
}
|
||||||
|
|
||||||
|
#include "tst_plugin.moc"
|
||||||
|
|
Reference in New Issue
Block a user