diff options
author | Eike Ziller <eike.ziller@qt.io> | 2020-10-06 10:05:47 +0200 |
---|---|---|
committer | Eike Ziller <eike.ziller@qt.io> | 2020-10-06 10:05:47 +0200 |
commit | 2092ebd074e0d5fbe758d99c7455d1e4c968540e (patch) | |
tree | 0824c93fb2bd944b9758bc63295ec8834143a682 /tests/auto | |
parent | 430a9a03b78ff71400ed2837b8cdb4ae50597c4e (diff) | |
parent | 3c281aa48394ed7c74ff076fffce99876637c2b8 (diff) |
Merge remote-tracking branch 'origin/4.14' into master
Change-Id: I4ea98cc1c14808afe44030a057f9ff289a57ccfe
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/debugger/CMakeLists.txt | 9 | ||||
-rw-r--r-- | tests/auto/debugger/debugger.pro | 1 | ||||
-rw-r--r-- | tests/auto/debugger/debugger.qbs | 1 | ||||
-rw-r--r-- | tests/auto/debugger/protocol.pro | 46 | ||||
-rw-r--r-- | tests/auto/debugger/protocol.qbs | 17 | ||||
-rw-r--r-- | tests/auto/debugger/tst_protocol.cpp | 92 |
6 files changed, 166 insertions, 0 deletions
diff --git a/tests/auto/debugger/CMakeLists.txt b/tests/auto/debugger/CMakeLists.txt index 66900623c3..71f48e399c 100644 --- a/tests/auto/debugger/CMakeLists.txt +++ b/tests/auto/debugger/CMakeLists.txt @@ -32,6 +32,15 @@ add_qtc_test(tst_debugger_gdb "${DEBUGGERDIR}/debuggerprotocol.cpp" "${DEBUGGERDIR}/debuggerprotocol.h" ) +add_qtc_test(tst_debugger_protocol + DEPENDS Qt5::Network Utils + INCLUDES + "${DEBUGGERDIR}" + SOURCES + "${DEBUGGERDIR}/debuggerprotocol.cpp" "${DEBUGGERDIR}/debuggerprotocol.h" + tst_protocol.cpp +) + add_qtc_test(tst_debugger_offsets DEPENDS Qt5::CorePrivate INCLUDES "${DEBUGGERDIR}" diff --git a/tests/auto/debugger/debugger.pro b/tests/auto/debugger/debugger.pro index 284db38b0c..6d24b5f799 100644 --- a/tests/auto/debugger/debugger.pro +++ b/tests/auto/debugger/debugger.pro @@ -12,3 +12,4 @@ SUBDIRS += simplifytypes.pro SUBDIRS += dumpers.pro SUBDIRS += disassembler.pro SUBDIRS += offsets.pro +SUBDIRS += protocol.pro diff --git a/tests/auto/debugger/debugger.qbs b/tests/auto/debugger/debugger.qbs index 456c604b26..e4ae105102 100644 --- a/tests/auto/debugger/debugger.qbs +++ b/tests/auto/debugger/debugger.qbs @@ -7,6 +7,7 @@ Project { "disassembler.qbs", "dumpers.qbs", "gdb.qbs", + "protocol.qbs", "offsets.qbs", "simplifytypes.qbs", ] diff --git a/tests/auto/debugger/protocol.pro b/tests/auto/debugger/protocol.pro new file mode 100644 index 0000000000..1008ba3d93 --- /dev/null +++ b/tests/auto/debugger/protocol.pro @@ -0,0 +1,46 @@ +QT = core network + +msvc: QTC_LIB_DEPENDS += utils +include(../qttest.pri) + +DEBUGGERDIR = $$IDE_SOURCE_TREE/src/plugins/debugger +UTILSDIR = $$IDE_SOURCE_TREE/src/libs/utils + +INCLUDEPATH += $$DEBUGGERDIR + +SOURCES += \ + tst_protocol.cpp \ + $$DEBUGGERDIR/debuggerprotocol.cpp + +HEADERS += \ + $$DEBUGGERDIR/debuggerprotocol.h + +!msvc { + SOURCES += \ + $$UTILSDIR/environment.cpp \ + $$UTILSDIR/fileutils.cpp \ + $$UTILSDIR/hostosinfo.cpp \ + $$UTILSDIR/namevaluedictionary.cpp \ + $$UTILSDIR/namevalueitem.cpp \ + $$UTILSDIR/qtcassert.cpp \ + $$UTILSDIR/qtcprocess.cpp \ + $$UTILSDIR/processhandle.cpp \ + $$UTILSDIR/savefile.cpp \ + + HEADERS += \ + $$UTILSDIR/environment.h \ + $$UTILSDIR/fileutils.h \ + $$UTILSDIR/hostosinfo.h \ + $$UTILSDIR/namevaluedictionary.h \ + $$UTILSDIR/namevalueitem.h \ + $$UTILSDIR/qtcassert.h \ + $$UTILSDIR/qtcprocess.h \ + $$UTILSDIR/processhandle.h \ + $$UTILSDIR/savefile.h \ + + macos: { + HEADERS += $$UTILSDIR/fileutils_mac.h + OBJECTIVE_SOURCES += $$UTILSDIR/fileutils_mac.mm + LIBS += -framework Foundation + } +} diff --git a/tests/auto/debugger/protocol.qbs b/tests/auto/debugger/protocol.qbs new file mode 100644 index 0000000000..ca1b0d8bec --- /dev/null +++ b/tests/auto/debugger/protocol.qbs @@ -0,0 +1,17 @@ +import qbs + +QtcAutotest { + name: "debugger protocol autotest" + Depends { name: "Utils" } + Depends { name: "Qt.network" } // For QHostAddress + Group { + name: "Sources from Debugger plugin" + prefix: project.debuggerDir + files: "debuggerprotocol.cpp" + } + Group { + name: "Test sources" + files: "tst_protocol.cpp" + } + cpp.includePaths: base.concat([project.debuggerDir]) +} diff --git a/tests/auto/debugger/tst_protocol.cpp b/tests/auto/debugger/tst_protocol.cpp new file mode 100644 index 0000000000..6d6f119053 --- /dev/null +++ b/tests/auto/debugger/tst_protocol.cpp @@ -0,0 +1,92 @@ +/**************************************************************************** +** +** Copyright (C) 2020 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ + +#include <debuggerprotocol.h> + +#include <QtTest> + +//TESTED_COMPONENT=src/plugins/debugger + +class tst_protocol : public QObject +{ + Q_OBJECT + +public: + tst_protocol() {} + +private slots: + void parseCString(); + void parseCString_data(); +}; + +void tst_protocol::parseCString() +{ + QFETCH(QString, input); + QFETCH(QString, expected); + + const QChar *from = input.begin(); + const QChar *to = input.end(); + QString parsed = Debugger::Internal::GdbMi::parseCString(from, to); + + QCOMPARE(parsed, expected); +} + +void tst_protocol::parseCString_data() +{ + QTest::addColumn<QString>("input"); + QTest::addColumn<QString>("expected"); + + QTest::newRow("empty") + << "" + << ""; + + QTest::newRow("unquoted") + << "irgendwas" + << ""; + + QTest::newRow("plain") + << R"("plain")" + << "plain"; + + // This is expected to throw several warnings + // "MI Parse Error, unrecognized backslash escape" + QChar escapes[] = {'\a', '\b', '\f', '\n', '\r', '\t', '\v', '"', '\'', '\\'}; + QTest::newRow("escaped") + << R"("\a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\y\z\"\'\\")" + << QString(escapes, sizeof(escapes)/sizeof(escapes[0])); + + QTest::newRow("octal") + << R"("abc\303\244\303\251def\303\261")" + << R"(abcäédefñ)"; + + QTest::newRow("hex") + << R"("abc\xc3\xa4\xc3\xa9def\xc3\xb1")" + << R"(abcäédefñ)"; +} + +QTEST_APPLESS_MAIN(tst_protocol); + +#include "tst_protocol.moc" + |