Commit 35a16cc3 authored by hjk's avatar hjk

Debugger: Make some of the plugin tests compilable again

Change-Id: I5c3885cb385dc1c15dce14f2ff52bf70edee8399
Reviewed-by: default avatarChristian Stenger <christian.stenger@theqtcompany.com>
parent 6cecb7e4
......@@ -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)
......
......@@ -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" }
......
......@@ -16,3 +16,6 @@ QTC_PLUGIN_DEPENDS += \
texteditor
QTC_PLUGIN_RECOMMENDS += \
cppeditor
QTC_TEST_DEPENDS += \
qmakeprojectmanager
......@@ -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);
......
......@@ -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;
This diff is collapsed.
......@@ -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
......
<RCC>
<qresource prefix="/">
<file>unit-tests/simple/main.cpp</file>
<file>unit-tests/simple/simple.pro</file>
</qresource>
</RCC>
......@@ -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);
......
int main()
{
int *i = 0;
*i = 42;
}
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