aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorhjk <hjk@qt.io>2020-08-12 00:18:00 +0200
committerhjk <hjk@qt.io>2020-10-06 07:01:04 +0000
commitf08c3d150af86a4c0760054e5b6cdbff023f8634 (patch)
tree2dc03c62a3956318f7bef3dca271ef78c33a0fd8 /tests/auto
parentee5feb4939007a1114c420dcac808b4398c19855 (diff)
Debugger: Fix parsing of octal-encoded gdb escapes
Fixes: QTCREATORBUG-24462 Change-Id: I89153a04eeef6a2e20fefef45e0efa3712ec0997 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/debugger/CMakeLists.txt9
-rw-r--r--tests/auto/debugger/debugger.pro1
-rw-r--r--tests/auto/debugger/debugger.qbs1
-rw-r--r--tests/auto/debugger/protocol.pro46
-rw-r--r--tests/auto/debugger/protocol.qbs17
-rw-r--r--tests/auto/debugger/tst_protocol.cpp92
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"
+