summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDominik Haumann <dhaumann@kde.org>2014-01-19 20:40:21 (GMT)
committerDominik Haumann <dhaumann@kde.org>2014-01-19 20:40:29 (GMT)
commit55821d993404ee45109cfd5351b9ee0bc657acc5 (patch)
treeb7827cd06332035e2adb22adf1174a28df75dfd5
parent65064825e7f233b4a25c282449bce4c115cd0cff (diff)
unit test the gdb backtrace parser
-rw-r--r--autotests/CMakeLists.txt10
-rw-r--r--autotests/btbrowsertest.cpp99
-rw-r--r--autotests/btbrowsertest.h40
3 files changed, 148 insertions, 1 deletions
diff --git a/autotests/CMakeLists.txt b/autotests/CMakeLists.txt
index b2e74db..76727ac 100644
--- a/autotests/CMakeLists.txt
+++ b/autotests/CMakeLists.txt
@@ -5,6 +5,7 @@ include_directories(
${CMAKE_SOURCE_DIR}/kate/app
${CMAKE_SOURCE_DIR}/kate/app/session
${CMAKE_SOURCE_DIR}/kate/filetree
+ ${CMAKE_SOURCE_DIR}/addons/kate/backtracebrowser
)
macro(kate_executable_tests)
@@ -33,4 +34,11 @@ endmacro(filetree_executable_tests)
filetree_executable_tests(
filetree_model_test
-) \ No newline at end of file
+)
+
+# Plugin Kate Backtrace Browser
+set(BtBrowserSrc btbrowsertest.cpp ${CMAKE_SOURCE_DIR}/addons/kate/backtracebrowser/btparser.cpp)
+add_executable(btbrowser_test ${BtBrowserSrc})
+add_test(plugin-btbrowser_test btbrowser_test)
+target_link_libraries(btbrowser_test kdeinit_kate Qt5::Test)
+ecm_mark_as_test(btbrowser_test)
diff --git a/autotests/btbrowsertest.cpp b/autotests/btbrowsertest.cpp
new file mode 100644
index 0000000..a184c3e
--- /dev/null
+++ b/autotests/btbrowsertest.cpp
@@ -0,0 +1,99 @@
+/* This file is part of the KDE project
+ *
+ * Copyright 2014 Dominik Haumann <dhaumann@kde.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "btbrowsertest.h"
+#include "btparser.h"
+
+
+#include <QtTestWidgets>
+#include <QTemporaryFile>
+#include <QFileInfo>
+
+QTEST_MAIN(KateBtBrowserTest)
+
+void KateBtBrowserTest::initTestCase()
+{
+}
+
+void KateBtBrowserTest::cleanupTestCase()
+{
+}
+
+void KateBtBrowserTest::testParser()
+{
+ // make sure the different types of gdb backtraces are parsed correctly
+
+ // 1) #24 0xb688ff8e in QApplication::notify (this=0xbf997e8c, receiver=0x82607e8, e=0xbf997074) at kernel/qapplication.cpp:3115
+ // 2) #39 0xb634211c in g_main_context_dispatch () from /usr/lib/libglib-2.0.so.0
+ // 3) #41 0x0805e690 in ?? ()
+ // 4) #5 0xffffe410 in __kernel_vsyscall ()
+
+
+ QString bt = QLatin1String("#24 0xb688ff8e in QApplication::notify (this=0xbf997e8c, receiver=0x82607e8, e=0xbf997074) at kernel/qapplication.cpp:3115");
+ QList<BtInfo> info = KateBtParser::parseBacktrace(bt);
+
+ QVERIFY(info.size() == 1);
+ QCOMPARE(info[0].type, BtInfo::Source);
+ QCOMPARE(info[0].original, bt);
+ QCOMPARE(info[0].filename, QLatin1String("kernel/qapplication.cpp"));
+ QCOMPARE(info[0].function, QLatin1String("QApplication::notify (this=0xbf997e8c, receiver=0x82607e8, e=0xbf997074)"));
+ QCOMPARE(info[0].address, QLatin1String("0xb688ff8e"));
+ QCOMPARE(info[0].line, 3115);
+ QCOMPARE(info[0].step, 24);
+
+ bt = QLatin1String("#39 0xb634211c in g_main_context_dispatch () from /usr/lib/libglib-2.0.so.0");
+ info = KateBtParser::parseBacktrace(bt);
+ QVERIFY(info.size() == 1);
+ QCOMPARE(info[0].type, BtInfo::Lib);
+ QCOMPARE(info[0].original, bt);
+ QCOMPARE(info[0].filename, QLatin1String("/usr/lib/libglib-2.0.so.0"));
+ QCOMPARE(info[0].function, QLatin1String("g_main_context_dispatch ()"));
+ QCOMPARE(info[0].address, QLatin1String("0xb634211c"));
+ QCOMPARE(info[0].line, -1);
+ QCOMPARE(info[0].step, 39);
+
+ bt = QLatin1String("#41 0x0805e690 in ?? ()");
+ info = KateBtParser::parseBacktrace(bt);
+ QVERIFY(info.size() == 1);
+ QCOMPARE(info[0].type, BtInfo::Unknown);
+ QCOMPARE(info[0].original, bt);
+ QCOMPARE(info[0].filename, QString());
+ QCOMPARE(info[0].function, QString());
+ QCOMPARE(info[0].address, QLatin1String("0x0805e690"));
+ QCOMPARE(info[0].line, -1);
+ QCOMPARE(info[0].step, 41);
+
+ bt = QLatin1String("#5 0xffffe410 in __kernel_vsyscall ()");
+ info = KateBtParser::parseBacktrace(bt);
+ QVERIFY(info.size() == 1);
+ QCOMPARE(info[0].type, BtInfo::Unknown);
+ QCOMPARE(info[0].original, bt);
+ QCOMPARE(info[0].filename, QString());
+ QCOMPARE(info[0].function, QLatin1String("__kernel_vsyscall ()"));
+ QCOMPARE(info[0].address, QLatin1String("0xffffe410"));
+ QCOMPARE(info[0].line, -1);
+ QCOMPARE(info[0].step, 5);
+
+ bt = QLatin1String(" Thread 1 (Thread 0x7fb6ba260780 (LWP 16447)):\n[KCrash Handler]");
+ info = KateBtParser::parseBacktrace(bt);
+ QVERIFY(info.size() == 0);
+}
+
+// kate: space-indent on; indent-width 4; replace-tabs on;
diff --git a/autotests/btbrowsertest.h b/autotests/btbrowsertest.h
new file mode 100644
index 0000000..0e942e2
--- /dev/null
+++ b/autotests/btbrowsertest.h
@@ -0,0 +1,40 @@
+/* This file is part of the KDE project
+ *
+ * Copyright 2014 Dominik Haumann <dhaumann@kde.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef KATE_BACKTRACE_BROWSER_TEST_H
+#define KATE_BACKTRACE_BROWSER_TEST_H
+
+#include <QObject>
+
+class KateBtBrowserTest : public QObject
+{
+ Q_OBJECT
+
+public Q_SLOTS:
+ void initTestCase();
+ void cleanupTestCase();
+
+private Q_SLOTS:
+ void testParser();
+};
+
+#endif
+
+// kate: space-indent on; indent-width 4; replace-tabs on;