summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhjk <hjk@theqtcompany.com>2016-03-09 19:16:14 +0100
committerhjk <hjk@theqtcompany.com>2016-03-16 14:04:05 +0000
commit35a16cc3945fe1530454649dfa05f694d61759bc (patch)
treea49493b13cec52de2127ae4384135bf314b32e8c
parent6cecb7e4db3b6c9e27046adf1af067a4ef58530f (diff)
downloadqt-creator-35a16cc3945fe1530454649dfa05f694d61759bc.tar.gz
Debugger: Make some of the plugin tests compilable again
Change-Id: I5c3885cb385dc1c15dce14f2ff52bf70edee8399 Reviewed-by: Christian Stenger <christian.stenger@theqtcompany.com>
-rw-r--r--src/plugins/debugger/debugger.pro5
-rw-r--r--src/plugins/debugger/debugger.qbs25
-rw-r--r--src/plugins/debugger/debugger_dependencies.pri3
-rw-r--r--src/plugins/debugger/debuggercore.h2
-rw-r--r--src/plugins/debugger/debuggeritem.cpp110
-rw-r--r--src/plugins/debugger/debuggerplugin.cpp347
-rw-r--r--src/plugins/debugger/debuggerplugin.h9
-rw-r--r--src/plugins/debugger/debuggerunittests.qrc6
-rw-r--r--src/plugins/debugger/gdb/gdbengine.cpp2
-rw-r--r--src/plugins/debugger/unit-tests/simple/main.cpp5
-rw-r--r--src/plugins/debugger/unit-tests/simple/simple.pro3
11 files changed, 236 insertions, 281 deletions
diff --git a/src/plugins/debugger/debugger.pro b/src/plugins/debugger/debugger.pro
index 8b9fb0dc06..08d0e25fd8 100644
--- a/src/plugins/debugger/debugger.pro
+++ b/src/plugins/debugger/debugger.pro
@@ -141,6 +141,11 @@ SOURCES += registerpostmortemaction.cpp
LIBS *= -lole32 \
-lshell32
}
+
+equals(TEST, 1) {
+ RESOURCES += debuggerunittests.qrc
+}
+
include(cdb/cdb.pri)
include(gdb/gdb.pri)
include(pdb/pdb.pri)
diff --git a/src/plugins/debugger/debugger.qbs b/src/plugins/debugger/debugger.qbs
index df08a58de4..a4c8834568 100644
--- a/src/plugins/debugger/debugger.qbs
+++ b/src/plugins/debugger/debugger.qbs
@@ -18,6 +18,16 @@ QtcPlugin {
Depends { name: "QtSupport" }
Depends { name: "TextEditor" }
+
+ Depends {
+ name: "Qt.test"
+ condition: project.testsEnabled
+ }
+
+ pluginTestDepends: [
+ "QmakeProjectManager"
+ ]
+
cpp.includePaths: base.concat([project.sharedSourcesDir + "/registryaccess"])
pluginRecommends: [
@@ -253,6 +263,21 @@ QtcPlugin {
]
}
+ Group {
+ name: "Unit tests"
+ condition: project.testsEnabled
+ files: [
+ "debuggerunittests.qrc",
+ ]
+ }
+
+ Group {
+ name: "Unit test resources"
+ prefix: "unit-tests/"
+ fileTags: []
+ files: ["**/*"]
+ }
+
Export {
Depends { name: "QtcSsh" }
Depends { name: "CPlusPlus" }
diff --git a/src/plugins/debugger/debugger_dependencies.pri b/src/plugins/debugger/debugger_dependencies.pri
index 259d30c6b1..7c0f491116 100644
--- a/src/plugins/debugger/debugger_dependencies.pri
+++ b/src/plugins/debugger/debugger_dependencies.pri
@@ -16,3 +16,6 @@ QTC_PLUGIN_DEPENDS += \
texteditor
QTC_PLUGIN_RECOMMENDS += \
cppeditor
+QTC_TEST_DEPENDS += \
+ qmakeprojectmanager
+
diff --git a/src/plugins/debugger/debuggercore.h b/src/plugins/debugger/debuggercore.h
index 2ac5a48ce2..6441c5df2c 100644
--- a/src/plugins/debugger/debuggercore.h
+++ b/src/plugins/debugger/debuggercore.h
@@ -93,6 +93,8 @@ void setSessionValue(const QByteArray &name, const QVariant &value);
QVariant configValue(const QByteArray &name);
void setConfigValue(const QByteArray &name, const QVariant &value);
+bool isTestRun();
+
Utils::SavedAction *action(int code);
bool boolSetting(int code);
QString stringSetting(int code);
diff --git a/src/plugins/debugger/debuggeritem.cpp b/src/plugins/debugger/debuggeritem.cpp
index ffa8c52036..ec6ac3d799 100644
--- a/src/plugins/debugger/debuggeritem.cpp
+++ b/src/plugins/debugger/debuggeritem.cpp
@@ -363,114 +363,4 @@ bool DebuggerItem::isValid() const
return !m_id.isNull();
}
-#ifdef WITH_TESTS
-
-namespace Internal {
-
-void DebuggerPlugin::testDebuggerMatching_data()
-{
- QTest::addColumn<QStringList>("debugger");
- QTest::addColumn<QString>("target");
- QTest::addColumn<int>("result");
-
- QTest::newRow("Invalid data")
- << QStringList()
- << QString()
- << int(DebuggerItem::DoesNotMatch);
- QTest::newRow("Invalid debugger")
- << QStringList()
- << QString::fromLatin1("x86-linux-generic-elf-32bit")
- << int(DebuggerItem::DoesNotMatch);
- QTest::newRow("Invalid target")
- << (QStringList() << QLatin1String("x86-linux-generic-elf-32bit"))
- << QString()
- << int(DebuggerItem::DoesNotMatch);
-
- QTest::newRow("Fuzzy match 1")
- << (QStringList() << QLatin1String("unknown-unknown-unknown-unknown-0bit"))
- << QString::fromLatin1("x86-linux-generic-elf-32bit")
- << int(DebuggerItem::MatchesWell); // Is this the expected behavior?
- QTest::newRow("Fuzzy match 2")
- << (QStringList() << QLatin1String("unknown-unknown-unknown-unknown-0bit"))
- << QString::fromLatin1("arm-windows-msys-pe-64bit")
- << int(DebuggerItem::MatchesWell); // Is this the expected behavior?
-
- QTest::newRow("Architecture mismatch")
- << (QStringList() << QLatin1String("x86-linux-generic-elf-32bit"))
- << QString::fromLatin1("arm-linux-generic-elf-32bit")
- << int(DebuggerItem::DoesNotMatch);
- QTest::newRow("OS mismatch")
- << (QStringList() << QLatin1String("x86-linux-generic-elf-32bit"))
- << QString::fromLatin1("x86-macosx-generic-elf-32bit")
- << int(DebuggerItem::DoesNotMatch);
- QTest::newRow("Format mismatch")
- << (QStringList() << QLatin1String("x86-linux-generic-elf-32bit"))
- << QString::fromLatin1("x86-linux-generic-pe-32bit")
- << int(DebuggerItem::DoesNotMatch);
-
- QTest::newRow("Linux perfect match")
- << (QStringList() << QLatin1String("x86-linux-generic-elf-32bit"))
- << QString::fromLatin1("x86-linux-generic-elf-32bit")
- << int(DebuggerItem::MatchesWell);
- QTest::newRow("Linux match")
- << (QStringList() << QLatin1String("x86-linux-generic-elf-64bit"))
- << QString::fromLatin1("x86-linux-generic-elf-32bit")
- << int(DebuggerItem::MatchesSomewhat);
-
- QTest::newRow("Windows perfect match 1")
- << (QStringList() << QLatin1String("x86-windows-msvc2013-pe-64bit"))
- << QString::fromLatin1("x86-windows-msvc2013-pe-64bit")
- << int(DebuggerItem::MatchesWell);
- QTest::newRow("Windows perfect match 2")
- << (QStringList() << QLatin1String("x86-windows-msvc2013-pe-64bit"))
- << QString::fromLatin1("x86-windows-msvc2012-pe-64bit")
- << int(DebuggerItem::MatchesWell);
- QTest::newRow("Windows match 1")
- << (QStringList() << QLatin1String("x86-windows-msvc2013-pe-64bit"))
- << QString::fromLatin1("x86-windows-msvc2013-pe-32bit")
- << int(DebuggerItem::MatchesSomewhat);
- QTest::newRow("Windows match 2")
- << (QStringList() << QLatin1String("x86-windows-msvc2013-pe-64bit"))
- << QString::fromLatin1("x86-windows-msvc2012-pe-32bit")
- << int(DebuggerItem::MatchesSomewhat);
- QTest::newRow("Windows mismatch on word size")
- << (QStringList() << QLatin1String("x86-windows-msvc2013-pe-32bit"))
- << QString::fromLatin1("x86-windows-msvc2013-pe-64bit")
- << int(DebuggerItem::DoesNotMatch);
- QTest::newRow("Windows mismatch on osflavor 1")
- << (QStringList() << QLatin1String("x86-windows-msvc2013-pe-32bit"))
- << QString::fromLatin1("x86-windows-msys-pe-64bit")
- << int(DebuggerItem::DoesNotMatch);
- QTest::newRow("Windows mismatch on osflavor 2")
- << (QStringList() << QLatin1String("x86-windows-msys-pe-32bit"))
- << QString::fromLatin1("x86-windows-msvc2010-pe-64bit")
- << int(DebuggerItem::DoesNotMatch);
-}
-
-void DebuggerPlugin::testDebuggerMatching()
-{
- QFETCH(QStringList, debugger);
- QFETCH(QString, target);
- QFETCH(int, result);
-
- DebuggerItem::MatchLevel expectedLevel = static_cast<DebuggerItem::MatchLevel>(result);
-
- QList<Abi> debuggerAbis;
- foreach (const QString &abi, debugger)
- debuggerAbis << Abi(abi);
-
- DebuggerItem item;
- item.setAbis(debuggerAbis);
-
- DebuggerItem::MatchLevel level = item.matchTarget(Abi(target));
- if (level == DebuggerItem::MatchesPerfectly)
- level = DebuggerItem::MatchesWell;
-
- QCOMPARE(expectedLevel, level);
-}
-
-} // namespace Internal
-
-#endif
-
} // namespace Debugger;
diff --git a/src/plugins/debugger/debuggerplugin.cpp b/src/plugins/debugger/debuggerplugin.cpp
index 65025a9b00..7fc925e616 100644
--- a/src/plugins/debugger/debuggerplugin.cpp
+++ b/src/plugins/debugger/debuggerplugin.cpp
@@ -34,6 +34,7 @@
#include "debuggerdialogs.h"
#include "debuggerengine.h"
#include "debuggericons.h"
+#include "debuggeritem.h"
#include "debuggeritemmanager.h"
#include "debuggermainwindow.h"
#include "debuggerrunconfigurationaspect.h"
@@ -84,7 +85,6 @@
#include <coreplugin/editormanager/documentmodel.h>
#include <coreplugin/editormanager/editormanager.h>
#include <coreplugin/find/itemviewfind.h>
-#include <coreplugin/findplaceholder.h>
#include <coreplugin/icore.h>
#include <coreplugin/imode.h>
#include <coreplugin/messagebox.h>
@@ -98,8 +98,6 @@
#include <cppeditor/cppeditorconstants.h>
#include <cpptools/cppmodelmanager.h>
-#include <extensionsystem/invoker.h>
-
#include <projectexplorer/buildconfiguration.h>
#include <projectexplorer/buildmanager.h>
#include <projectexplorer/devicesupport/deviceprocessesdialog.h>
@@ -160,14 +158,11 @@
#include <QVariant>
#include <QtPlugin>
-using namespace Core;
-using namespace Utils;
-using namespace Core::Constants;
-using namespace ProjectExplorer;
-using namespace Debugger;
-using namespace Debugger::Internal;
-
#ifdef WITH_TESTS
+
+#include <cpptools/cpptoolstestcase.h>
+#include <cpptools/projectinfo.h>
+
#include <QTest>
#include <QSignalSpy>
#include <QTestEventLoop>
@@ -414,6 +409,7 @@ sg1: }
\endcode */
using namespace Core;
+using namespace Core::Constants;
using namespace Debugger::Constants;
using namespace Debugger::Internal;
using namespace ExtensionSystem;
@@ -427,16 +423,6 @@ namespace PE = ProjectExplorer::Constants;
namespace Debugger {
namespace Internal {
-struct TestCallBack
-{
- TestCallBack() : receiver(0), slot(0) {}
- TestCallBack(QObject *ob, const char *s) : receiver(ob), slot(s) {}
-
- QObject *receiver;
- const char *slot;
- QVariant cookie;
-};
-
void addCdbOptionPages(QList<IOptionsPage*> *opts);
void addGdbOptionPages(QList<IOptionsPage*> *opts);
QObject *createDebuggerRunControlFactory(QObject *parent);
@@ -718,7 +704,7 @@ public:
void attachToRunningApplication();
void attachToUnstartedApplicationDialog();
void attachToQmlPort();
- Q_SLOT void runScheduled();
+ void runScheduled();
void attachCore();
void enableReverseDebuggingTriggered(const QVariant &value);
@@ -745,31 +731,6 @@ public:
void coreShutdown();
-#ifdef WITH_TESTS
-public slots:
- void testLoadProject(const QString &proFile, const TestCallBack &cb);
- void testProjectLoaded(Project *project);
- void testProjectEvaluated();
- void testProjectBuilt(bool success);
- void testUnloadProject();
- void testFinished();
-
- void testRunProject(const DebuggerRunParameters &sp, const TestCallBack &cb);
- void testRunControlFinished();
-
-// void testStateMachine1();
-// void testStateMachine2();
-// void testStateMachine3();
-
- void testBenchmark1();
-
-public:
- Project *m_testProject;
- bool m_testSuccess;
- QList<TestCallBack> m_testCallbacks;
-
-#endif
-
public:
void updateDebugActions();
@@ -1227,7 +1188,7 @@ void DebuggerPluginPrivate::parseCommandLineArguments()
MessageManager::write(errorMessage);
}
if (!m_scheduledStarts.isEmpty())
- QTimer::singleShot(0, this, SLOT(runScheduled()));
+ QTimer::singleShot(0, this, &DebuggerPluginPrivate::runScheduled);
}
bool DebuggerPluginPrivate::initialize(const QStringList &arguments,
@@ -3583,146 +3544,93 @@ bool operator==(const AnalyzerConnection &c1, const AnalyzerConnection &c2)
&& c1.analyzerPort == c2.analyzerPort;
}
-#ifdef WITH_TESTS
-void DebuggerPluginPrivate::testLoadProject(const QString &proFile, const TestCallBack &cb)
-{
- connect(ProjectTree::instance(), &ProjectTree::currentProjectChanged,
- this, &DebuggerPluginPrivate::testProjectLoaded);
-
- m_testCallbacks.append(cb);
- ProjectExplorerPlugin::OpenProjectResult result = ProjectExplorerPlugin::openProject(proFile);
- if (result) {
- // Will end up in callback below due to the connections to
- // signal currentProjectChanged().
- return;
- }
+namespace Internal {
- // Project opening failed. Eat the unused callback.
- qWarning("Cannot open %s: %s", qPrintable(proFile), qPrintable(result.errorMessage()));
- QVERIFY(false);
- m_testCallbacks.pop_back();
-}
+static bool s_testRun = false;
+bool isTestRun() { return s_testRun; }
-void DebuggerPluginPrivate::testProjectLoaded(Project *project)
-{
- if (!project) {
- qWarning("Changed to null project.");
- return;
- }
- m_testProject = project;
- connect(project, SIGNAL(proFilesEvaluated()), SLOT(testProjectEvaluated()));
- project->configureAsExampleProject({ });
-}
+#ifdef WITH_TESTS
-void DebuggerPluginPrivate::testProjectEvaluated()
+class DebuggerUnitTests : public QObject
{
- QString fileName = m_testProject->projectFilePath().toUserOutput();
- QVERIFY(!fileName.isEmpty());
- qWarning("Project %s loaded", qPrintable(fileName));
- connect(BuildManager::instance(), SIGNAL(buildQueueFinished(bool)),
- this, SLOT(testProjectBuilt(bool)));
- ProjectExplorerPlugin::buildProject(m_testProject);
-}
+ Q_OBJECT
-void DebuggerPluginPrivate::testProjectBuilt(bool success)
-{
- QVERIFY(success);
- QVERIFY(!m_testCallbacks.isEmpty());
- TestCallBack cb = m_testCallbacks.takeLast();
- invoke<void>(cb.receiver, cb.slot);
-}
+public:
+ DebuggerUnitTests() {}
-void DebuggerPluginPrivate::testUnloadProject()
-{
- ProjectExplorerPlugin *pe = ProjectExplorerPlugin::instance();
- invoke<void>(pe, "unloadProject");
-}
+private slots:
+ void initTestCase();
+ void cleanupTestCase();
-//static Target *activeTarget()
-//{
-// Project *project = ProjectExplorerPlugin::instance()->currentProject();
-// return project->activeTarget();
-//}
+ void testDebuggerMatching_data();
+ void testDebuggerMatching();
-//static Kit *currentKit()
-//{
-// Target *t = activeTarget();
-// if (!t || !t->isEnabled())
-// return 0;
-// return t->kit();
-//}
+ void testBenchmark();
+ void testStateMachine();
-//static LocalApplicationRunConfiguration *activeLocalRunConfiguration()
-//{
-// Target *t = activeTarget();
-// return t ? qobject_cast<LocalApplicationRunConfiguration *>(t->activeRunConfiguration()) : 0;
-//}
+private:
+ CppTools::Tests::TemporaryCopiedDir *m_tmpDir = 0;
+};
-void DebuggerPluginPrivate::testRunProject(const DebuggerRunParameters &rp, const TestCallBack &cb)
+void DebuggerUnitTests::initTestCase()
{
- m_testCallbacks.append(cb);
- RunControl *rc = createAndScheduleRun(rp, 0);
- connect(rc, &RunControl::finished, this, &DebuggerPluginPrivate::testRunControlFinished);
-}
+// const QList<Kit *> allKits = KitManager::kits();
+// if (allKits.count() != 1)
+// QSKIP("This test requires exactly one kit to be present");
+// const ToolChain * const toolchain = ToolChainKitInformation::toolChain(allKits.first());
+// if (!toolchain)
+// QSKIP("This test requires that there is a kit with a toolchain.");
+// bool hasClangExecutable;
+// clangExecutableFromSettings(toolchain->typeId(), &hasClangExecutable);
+// if (!hasClangExecutable)
+// QSKIP("No clang suitable for analyzing found");
-void DebuggerPluginPrivate::testRunControlFinished()
-{
- QVERIFY(!m_testCallbacks.isEmpty());
- TestCallBack cb = m_testCallbacks.takeLast();
- ExtensionSystem::invoke<void>(cb.receiver, cb.slot);
+ s_testRun = true;
+ m_tmpDir = new CppTools::Tests::TemporaryCopiedDir(QLatin1String(":/unit-tests"));
+ QVERIFY(m_tmpDir->isValid());
}
-void DebuggerPluginPrivate::testFinished()
+void DebuggerUnitTests::cleanupTestCase()
{
- QTestEventLoop::instance().exitLoop();
- QVERIFY(m_testSuccess);
+ delete m_tmpDir;
}
-///////////////////////////////////////////////////////////////////////////
-
-//void DebuggerPlugin::testStateMachine()
-//{
-// dd->testStateMachine1();
-//}
-
-//void DebuggerPluginPrivate::testStateMachine1()
-//{
-// m_testSuccess = true;
-// QString proFile = ICore::resourcePath();
-// if (Utils::HostOsInfo::isMacHost())
-// proFile += QLatin1String("/../..");
-// proFile += QLatin1String("/../../tests/manual/debugger/simple/simple.pro");
-// testLoadProject(proFile, TestCallBack(this, "testStateMachine2"));
-// QVERIFY(m_testSuccess);
-// QTestEventLoop::instance().enterLoop(20);
-//}
-
-//void DebuggerPluginPrivate::testStateMachine2()
-//{
-// DebuggerRunParameters sp;
-// fillParameters(&sp, currentKit());
-// sp.executable = activeLocalRunConfiguration()->executable();
-// sp.testCase = TestNoBoundsOfCurrentFunction;
-// testRunProject(sp, TestCallBack(this, "testStateMachine3"));
-//}
+void DebuggerUnitTests::testStateMachine()
+{
+ QString proFile = m_tmpDir->absolutePath("simple/simple.pro");
-//void DebuggerPluginPrivate::testStateMachine3()
-//{
-// testUnloadProject();
-// testFinished();
-//}
+ CppTools::Tests::ProjectOpenerAndCloser projectManager;
+ const CppTools::ProjectInfo projectInfo = projectManager.open(proFile, true);
+ QVERIFY(projectInfo.isValid());
+ QEventLoop loop;
+ connect(BuildManager::instance(), &BuildManager::buildQueueFinished,
+ &loop, &QEventLoop::quit);
+ ProjectExplorerPlugin::buildProject(SessionManager::startupProject());
+ loop.exec();
-///////////////////////////////////////////////////////////////////////////
+ DebuggerRunParameters rp;
+ Target *t = SessionManager::startupProject()->activeTarget();
+ QVERIFY(t);
+ Kit *kit = t->kit();
+ QVERIFY(kit);
+ RunConfiguration *rc = t->activeRunConfiguration();
+ QVERIFY(rc);
+ rp.inferior = rc->runnable().as<StandardRunnable>();
+ rp.testCase = TestNoBoundsOfCurrentFunction;
+ DebuggerRunControl *runControl = createAndScheduleRun(rp, kit);
+
+ connect(runControl, &RunControl::finished, this, [this] {
+ QTestEventLoop::instance().exitLoop();
+ });
-void DebuggerPlugin::testBenchmark()
-{
- dd->testBenchmark1();
+// QTestEventLoop::instance().enterLoop(20);
}
+
enum FakeEnum { FakeDebuggerCommonSettingsId };
-void DebuggerPluginPrivate::testBenchmark1()
+void DebuggerUnitTests::testBenchmark()
{
#ifdef WITH_BENCHMARK
CALLGRIND_START_INSTRUMENTATION;
@@ -3737,9 +3645,124 @@ void DebuggerPluginPrivate::testBenchmark1()
#endif
}
+void DebuggerUnitTests::testDebuggerMatching_data()
+{
+ QTest::addColumn<QStringList>("debugger");
+ QTest::addColumn<QString>("target");
+ QTest::addColumn<int>("result");
+
+ QTest::newRow("Invalid data")
+ << QStringList()
+ << QString()
+ << int(DebuggerItem::DoesNotMatch);
+ QTest::newRow("Invalid debugger")
+ << QStringList()
+ << QString::fromLatin1("x86-linux-generic-elf-32bit")
+ << int(DebuggerItem::DoesNotMatch);
+ QTest::newRow("Invalid target")
+ << (QStringList() << QLatin1String("x86-linux-generic-elf-32bit"))
+ << QString()
+ << int(DebuggerItem::DoesNotMatch);
+
+ QTest::newRow("Fuzzy match 1")
+ << (QStringList() << QLatin1String("unknown-unknown-unknown-unknown-0bit"))
+ << QString::fromLatin1("x86-linux-generic-elf-32bit")
+ << int(DebuggerItem::MatchesWell); // Is this the expected behavior?
+ QTest::newRow("Fuzzy match 2")
+ << (QStringList() << QLatin1String("unknown-unknown-unknown-unknown-0bit"))
+ << QString::fromLatin1("arm-windows-msys-pe-64bit")
+ << int(DebuggerItem::MatchesWell); // Is this the expected behavior?
+
+ QTest::newRow("Architecture mismatch")
+ << (QStringList() << QLatin1String("x86-linux-generic-elf-32bit"))
+ << QString::fromLatin1("arm-linux-generic-elf-32bit")
+ << int(DebuggerItem::DoesNotMatch);
+ QTest::newRow("OS mismatch")
+ << (QStringList() << QLatin1String("x86-linux-generic-elf-32bit"))
+ << QString::fromLatin1("x86-macosx-generic-elf-32bit")
+ << int(DebuggerItem::DoesNotMatch);
+ QTest::newRow("Format mismatch")
+ << (QStringList() << QLatin1String("x86-linux-generic-elf-32bit"))
+ << QString::fromLatin1("x86-linux-generic-pe-32bit")
+ << int(DebuggerItem::DoesNotMatch);
+
+ QTest::newRow("Linux perfect match")
+ << (QStringList() << QLatin1String("x86-linux-generic-elf-32bit"))
+ << QString::fromLatin1("x86-linux-generic-elf-32bit")
+ << int(DebuggerItem::MatchesWell);
+ QTest::newRow("Linux match")
+ << (QStringList() << QLatin1String("x86-linux-generic-elf-64bit"))
+ << QString::fromLatin1("x86-linux-generic-elf-32bit")
+ << int(DebuggerItem::MatchesSomewhat);
+
+ QTest::newRow("Windows perfect match 1")
+ << (QStringList() << QLatin1String("x86-windows-msvc2013-pe-64bit"))
+ << QString::fromLatin1("x86-windows-msvc2013-pe-64bit")
+ << int(DebuggerItem::MatchesWell);
+ QTest::newRow("Windows perfect match 2")
+ << (QStringList() << QLatin1String("x86-windows-msvc2013-pe-64bit"))
+ << QString::fromLatin1("x86-windows-msvc2012-pe-64bit")
+ << int(DebuggerItem::MatchesWell);
+ QTest::newRow("Windows match 1")
+ << (QStringList() << QLatin1String("x86-windows-msvc2013-pe-64bit"))
+ << QString::fromLatin1("x86-windows-msvc2013-pe-32bit")
+ << int(DebuggerItem::MatchesSomewhat);
+ QTest::newRow("Windows match 2")
+ << (QStringList() << QLatin1String("x86-windows-msvc2013-pe-64bit"))
+ << QString::fromLatin1("x86-windows-msvc2012-pe-32bit")
+ << int(DebuggerItem::MatchesSomewhat);
+ QTest::newRow("Windows mismatch on word size")
+ << (QStringList() << QLatin1String("x86-windows-msvc2013-pe-32bit"))
+ << QString::fromLatin1("x86-windows-msvc2013-pe-64bit")
+ << int(DebuggerItem::DoesNotMatch);
+ QTest::newRow("Windows mismatch on osflavor 1")
+ << (QStringList() << QLatin1String("x86-windows-msvc2013-pe-32bit"))
+ << QString::fromLatin1("x86-windows-msys-pe-64bit")
+ << int(DebuggerItem::DoesNotMatch);
+ QTest::newRow("Windows mismatch on osflavor 2")
+ << (QStringList() << QLatin1String("x86-windows-msys-pe-32bit"))
+ << QString::fromLatin1("x86-windows-msvc2010-pe-64bit")
+ << int(DebuggerItem::DoesNotMatch);
+}
+
+void DebuggerUnitTests::testDebuggerMatching()
+{
+ QFETCH(QStringList, debugger);
+ QFETCH(QString, target);
+ QFETCH(int, result);
+
+ DebuggerItem::MatchLevel expectedLevel = static_cast<DebuggerItem::MatchLevel>(result);
+
+ QList<Abi> debuggerAbis;
+ foreach (const QString &abi, debugger)
+ debuggerAbis << Abi(abi);
+
+ DebuggerItem item;
+ item.setAbis(debuggerAbis);
+
+ DebuggerItem::MatchLevel level = item.matchTarget(Abi(target));
+ if (level == DebuggerItem::MatchesPerfectly)
+ level = DebuggerItem::MatchesWell;
+
+ QCOMPARE(expectedLevel, level);
+}
+
+
+QList<QObject *> DebuggerPlugin::createTestObjects() const
+{
+ return { new DebuggerUnitTests };
+}
+
+#else // ^-- if WITH_TESTS else --v
+
+QList<QObject *> DebuggerPlugin::createTestObjects() const
+{
+ return {};
+}
#endif // if WITH_TESTS
+} // namespace Internal
} // namespace Debugger
#include "debuggerplugin.moc"
diff --git a/src/plugins/debugger/debuggerplugin.h b/src/plugins/debugger/debuggerplugin.h
index 32ef71d1c6..1d682b610d 100644
--- a/src/plugins/debugger/debuggerplugin.h
+++ b/src/plugins/debugger/debuggerplugin.h
@@ -57,14 +57,7 @@ private:
// Called from AppOutputPane::attachToRunControl().
Q_SLOT void attachExternalApplication(ProjectExplorer::RunControl *rc);
-#ifdef WITH_TESTS
-private slots:
- void testDebuggerMatching_data();
- void testDebuggerMatching();
-
- void testBenchmark();
-// void testStateMachine();
-#endif
+ QList<QObject *> createTestObjects() const override;
};
} // namespace Internal
diff --git a/src/plugins/debugger/debuggerunittests.qrc b/src/plugins/debugger/debuggerunittests.qrc
new file mode 100644
index 0000000000..42d52705a8
--- /dev/null
+++ b/src/plugins/debugger/debuggerunittests.qrc
@@ -0,0 +1,6 @@
+<RCC>
+ <qresource prefix="/">
+ <file>unit-tests/simple/main.cpp</file>
+ <file>unit-tests/simple/simple.pro</file>
+ </qresource>
+</RCC>
diff --git a/src/plugins/debugger/gdb/gdbengine.cpp b/src/plugins/debugger/gdb/gdbengine.cpp
index 33c3ba259f..5ada376165 100644
--- a/src/plugins/debugger/gdb/gdbengine.cpp
+++ b/src/plugins/debugger/gdb/gdbengine.cpp
@@ -4274,7 +4274,7 @@ void GdbEngine::handleAdapterStartFailed(const QString &msg, Id settingsIdHint)
{
CHECK_STATE(EngineSetupOk);
showMessage(_("ADAPTER START FAILED"));
- if (!msg.isEmpty()) {
+ if (!msg.isEmpty() && !Internal::isTestRun()) {
const QString title = tr("Adapter start failed");
if (!settingsIdHint.isValid()) {
ICore::showWarningWithOptions(title, msg);
diff --git a/src/plugins/debugger/unit-tests/simple/main.cpp b/src/plugins/debugger/unit-tests/simple/main.cpp
new file mode 100644
index 0000000000..af917a3a33
--- /dev/null
+++ b/src/plugins/debugger/unit-tests/simple/main.cpp
@@ -0,0 +1,5 @@
+int main()
+{
+ int *i = 0;
+ *i = 42;
+}
diff --git a/src/plugins/debugger/unit-tests/simple/simple.pro b/src/plugins/debugger/unit-tests/simple/simple.pro
new file mode 100644
index 0000000000..fb560c2af6
--- /dev/null
+++ b/src/plugins/debugger/unit-tests/simple/simple.pro
@@ -0,0 +1,3 @@
+CONFIG -= QT
+
+SOURCES = main.cpp