Commit 55821d99 authored by Dominik Haumann's avatar Dominik Haumann

unit test the gdb backtrace parser

parent 65064825
......@@ -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)
/* 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;
/* 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;
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