diff --git a/debuggers/common/tests/CMakeLists.txt b/debuggers/common/tests/CMakeLists.txt --- a/debuggers/common/tests/CMakeLists.txt +++ b/debuggers/common/tests/CMakeLists.txt @@ -7,3 +7,13 @@ configure_file(debuggers-tests-config.h.in debuggers-tests-config.h) add_subdirectory(debuggees) + +add_library(kdevdbg_testhelper STATIC testhelper.cpp) +target_link_libraries(kdevdbg_testhelper + PUBLIC + kdevdebuggercommon + KDev::Debugger + Qt5::Core + PRIVATE + Qt5::Test +) diff --git a/debuggers/common/tests/debuggees/path with space/CMakeLists.txt b/debuggers/common/tests/debuggees/path with space/CMakeLists.txt --- a/debuggers/common/tests/debuggees/path with space/CMakeLists.txt +++ b/debuggers/common/tests/debuggees/path with space/CMakeLists.txt @@ -1,2 +1,2 @@ -add_debuggable_executable(lldb_spacedebugee SRCS "spacedebugee.cpp") -target_link_libraries(lldb_spacedebugee Qt5::Core) +add_debuggable_executable(debuggee_spacedebugee SRCS "spacedebugee.cpp") +target_link_libraries(debuggee_spacedebugee Qt5::Core) diff --git a/debuggers/common/tests/debuggers-tests-config.h.in b/debuggers/common/tests/debuggers-tests-config.h.in --- a/debuggers/common/tests/debuggers-tests-config.h.in +++ b/debuggers/common/tests/debuggers-tests-config.h.in @@ -1,4 +1,5 @@ #pragma once #define DEBUGGEE_BIN_DIR "${CMAKE_CURRENT_BINARY_DIR}/debuggees" +#define DEBUGGEE_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/debuggees" #cmakedefine01 HAVE_PATH_WITH_SPACES_TEST diff --git a/debuggers/lldb/unittests/testhelper.h b/debuggers/common/tests/testhelper.h rename from debuggers/lldb/unittests/testhelper.h rename to debuggers/common/tests/testhelper.h --- a/debuggers/lldb/unittests/testhelper.h +++ b/debuggers/common/tests/testhelper.h @@ -1,5 +1,5 @@ /* - * Helpers for LLDB debugger unit tests + * Helpers for MI debugger unit tests * Copyright 2016 Aetf * * This program is free software; you can redistribute it and/or @@ -20,8 +20,8 @@ * */ -#ifndef LLDB_UNITTEST_H -#define LLDB_UNITTEST_H +#ifndef KDEVDBG_TESTHELPER_H +#define KDEVDBG_TESTHELPER_H #include @@ -34,10 +34,8 @@ class MIDebugSession; -namespace LLDB { - QUrl findExecutable(const QString& name); -QString findSourceFile(const char *file, const QString& name); +QString findSourceFile(const QString& name); bool isAttachForbidden(const char *file, int line); bool compareData(QModelIndex index, const QString& expected, const char *file, int line, bool useRE = false); @@ -62,8 +60,6 @@ int line; }; - -} // end of namespace LLDB } // end of namespace KDevMI -#endif // LLDB_UNITTEST_H +#endif // KDEVDBG_TESTHELPER_H diff --git a/debuggers/lldb/unittests/testhelper.cpp b/debuggers/common/tests/testhelper.cpp rename from debuggers/lldb/unittests/testhelper.cpp rename to debuggers/common/tests/testhelper.cpp --- a/debuggers/lldb/unittests/testhelper.cpp +++ b/debuggers/common/tests/testhelper.cpp @@ -22,7 +22,7 @@ #include "testhelper.h" -#include "common/tests/debuggers-tests-config.h" +#include "debuggers-tests-config.h" #include "midebugsession.h" #include @@ -32,29 +32,21 @@ #include #include -namespace KDevMI { namespace LLDB { +namespace KDevMI { QUrl findExecutable(const QString& name) { - QFileInfo info(QString("%1/%2").arg(QString::fromLocal8Bit(DEBUGGEE_BIN_DIR), name)); - Q_ASSERT(info.exists()); + QFileInfo info(QString::fromLocal8Bit(DEBUGGEE_BIN_DIR), name); + Q_ASSERT_X(info.exists(), "findExecutable", info.filePath().toLocal8Bit()); Q_ASSERT(info.isExecutable()); return QUrl::fromLocalFile(info.canonicalFilePath()); } -// Try to find file in the same folder as `file`, -// if not found, go down to debugees folder. -QString findSourceFile(const char *file, const QString& name) +QString findSourceFile(const QString& name) { - QDir baseDir = QFileInfo(file).dir(); - QFileInfo info(baseDir.absoluteFilePath(name)); - if (info.exists()) { - return info.canonicalFilePath(); - } + QFileInfo info(QString::fromLocal8Bit(DEBUGGEE_SRC_DIR), name); + Q_ASSERT_X(info.exists(), "findSourceFile", info.filePath().toLocal8Bit()); - baseDir.cd(QStringLiteral("debugees")); - info = baseDir.absoluteFilePath(name); - Q_ASSERT(info.exists()); return info.canonicalFilePath(); } @@ -174,5 +166,4 @@ return true; } -} // end of namespace LLDB } // end of namespace KDevMI diff --git a/debuggers/gdb/unittests/CMakeLists.txt b/debuggers/gdb/unittests/CMakeLists.txt --- a/debuggers/gdb/unittests/CMakeLists.txt +++ b/debuggers/gdb/unittests/CMakeLists.txt @@ -1,12 +1,13 @@ ecm_add_test(test_gdb.cpp - LINK_LIBRARIES kdevgdb_static KDev::Tests Qt5::Test + LINK_LIBRARIES + kdevgdb_static + kdevdbg_testhelper + KDev::Tests + Qt5::Test ) + ecm_add_test(test_gdbprinters.cpp LINK_LIBRARIES Qt5::Core Qt5::Test ) - -if (HAVE_PATH_WITH_SPACES_TEST) - set_target_properties(test_gdb PROPERTIES COMPILE_FLAGS "-D") -endif() diff --git a/debuggers/gdb/unittests/debugee space.cpp b/debuggers/gdb/unittests/debugee space.cpp deleted file mode 100644 --- a/debuggers/gdb/unittests/debugee space.cpp +++ /dev/null @@ -1,23 +0,0 @@ -/* - Copyright 2009 Niko Sams - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License version 2 as published by the Free Software Foundation. - - 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 - -int main() { - std::cout << "Hello, world!" << std::endl; - return 0; -} diff --git a/debuggers/gdb/unittests/debugee.cpp b/debuggers/gdb/unittests/debugee.cpp deleted file mode 100644 --- a/debuggers/gdb/unittests/debugee.cpp +++ /dev/null @@ -1,41 +0,0 @@ -/* - Copyright 2009 Niko Sams - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License version 2 as published by the Free Software Foundation. - - 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 -struct testStruct { int a; int b; int c; }; -void noop() {} -void foo() { - static int i=0; - ++i; - noop(); - noop(); -} -int main(int argc, char **argv) { - std::cout << "Hello, world!" << std::endl; - foo(); - foo(); - (void)argc;(void)argv; - const char *x = "Hello"; - std::cout << x << std::endl; - - testStruct ts; - ts.a = 0; - ts.b = 1; - ts.c = 2; - ts.a++; - return 0; -} diff --git a/debuggers/gdb/unittests/debugeecrash.cpp b/debuggers/gdb/unittests/debugeecrash.cpp deleted file mode 100644 --- a/debuggers/gdb/unittests/debugeecrash.cpp +++ /dev/null @@ -1,31 +0,0 @@ -/* - Copyright 2009 Niko Sams - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License version 2 as published by the Free Software Foundation. - - 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 -void foo() { - int j = 0; - j++; - j++; - int *i=nullptr; - *i = 0; -} -int main() { - std::cout << "Hello, world!" << std::endl; - foo(); - return 0; -} diff --git a/debuggers/gdb/unittests/debugeeechoenv.cpp b/debuggers/gdb/unittests/debugeeechoenv.cpp deleted file mode 100644 --- a/debuggers/gdb/unittests/debugeeechoenv.cpp +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright 2016 Aetf - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of - * the License or (at your option) version 3 or any later version - * accepted by the membership of KDE e.V. (or its successor approved - * by the membership of KDE e.V.), which shall act as a proxy - * defined in Section 14 of version 3 of the license. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - */ - -#include -#include - -int main() { - char * value = std::getenv("VariableA"); - if (value) { - std::cout << value << std::endl; - } else { - std::cout << "Not found!" << std::endl; - } - - value = std::getenv("VariableB"); - if (value) { - std::cout << value << std::endl; - } else { - std::cout << "Not found!" << std::endl; - } - return 0; -} diff --git a/debuggers/gdb/unittests/debugeeexception.cpp b/debuggers/gdb/unittests/debugeeexception.cpp deleted file mode 100644 --- a/debuggers/gdb/unittests/debugeeexception.cpp +++ /dev/null @@ -1,37 +0,0 @@ -/* - Copyright 2012 Niko Sams - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License version 2 as published by the Free Software Foundation. - - 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 -void foo() -{ - int i = 20; - throw i; -} - -int main () -{ - try - { - foo(); - } - catch (int e) - { - std::cout << "An exception occurred. Exception Nr. " << e << std::endl; - } - return 0; -} diff --git a/debuggers/gdb/unittests/debugeemultilocbreakpoint.cpp b/debuggers/gdb/unittests/debugeemultilocbreakpoint.cpp deleted file mode 100644 --- a/debuggers/gdb/unittests/debugeemultilocbreakpoint.cpp +++ /dev/null @@ -1,35 +0,0 @@ -/* - Copyright 2012 Niko Sams - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License version 2 as published by the Free Software Foundation. - - 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. -*/ - -inline int aPlusB(int a, int b) { - return a+b; -} - -inline int aPlusB(int a) { - return a+1; -} - -int main() -{ - int test1 = aPlusB(1, 1); - (void)test1; - int test4 = aPlusB(2); - (void)test4; - - return 0; -} diff --git a/debuggers/gdb/unittests/debugeemultiplebreakpoint.cpp b/debuggers/gdb/unittests/debugeemultiplebreakpoint.cpp deleted file mode 100644 --- a/debuggers/gdb/unittests/debugeemultiplebreakpoint.cpp +++ /dev/null @@ -1,52 +0,0 @@ -/* - Copyright 2013 Vlas Puhov - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License version 2 as published by the Free Software Foundation. - - 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 - -class Str2 { - public: void print(void) { - std::cout << "Str2\n"; - } -}; - -class Str { - public: Str() : S("str\n") { - } - public: void print(void) { - std::cout << S; - } - private: std::string S; -}; - - -void Print ( Str2& c, Str& s, bool b ) -{ - if(b){ - c.print(); - s.print(); - } -} - -int main ( void ) -{ - Str2 c; - Str s; - Print ( c, s, true ); - return 1; -} diff --git a/debuggers/gdb/unittests/debugeeqt.cpp b/debuggers/gdb/unittests/debugeeqt.cpp deleted file mode 100644 --- a/debuggers/gdb/unittests/debugeeqt.cpp +++ /dev/null @@ -1,30 +0,0 @@ -/* - Copyright 2011 Niko Sams - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License version 2 as published by the Free Software Foundation. - - 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 -#include - -int main() -{ - qDebug(); - for(int i=0; i<10; ++i) { - QString x(QStringLiteral("foobar")); - x += QString::number(i); - qDebug() << x; - } - return 0; -} diff --git a/debuggers/gdb/unittests/debugeerecursion.cpp b/debuggers/gdb/unittests/debugeerecursion.cpp deleted file mode 100644 --- a/debuggers/gdb/unittests/debugeerecursion.cpp +++ /dev/null @@ -1,32 +0,0 @@ -/* - Copyright 2009 Niko Sams - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License version 2 as published by the Free Software Foundation. - - 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 - -void foo() { - static int i=0; - ++i; - if (i < 300) - foo(); - else - std::cout << "Hello, world!" << std::endl; -} - -int main() { - foo(); - return 0; -} diff --git a/debuggers/gdb/unittests/debugeeslow.cpp b/debuggers/gdb/unittests/debugeeslow.cpp deleted file mode 100644 --- a/debuggers/gdb/unittests/debugeeslow.cpp +++ /dev/null @@ -1,37 +0,0 @@ -/* - Copyright 2009 Niko Sams - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License version 2 as published by the Free Software Foundation. - - 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 - -#include - -void foo() { - static int i=0; - ++i; - std::cout << i << std::endl; - sleep(2); -} - -int main() { - std::cout << "Hello, world!" << std::endl; - for (int i=0; i<3; i++) { - foo(); - } - - return 0; -} diff --git a/debuggers/gdb/unittests/debugeethreads.cpp b/debuggers/gdb/unittests/debugeethreads.cpp deleted file mode 100644 --- a/debuggers/gdb/unittests/debugeethreads.cpp +++ /dev/null @@ -1,42 +0,0 @@ -/* - Copyright 2009 Niko Sams - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License version 2 as published by the Free Software Foundation. - - 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 -#include -#include - -class TestThread : public QThread -{ -public: - void run() override { - sleep(1); - std::cout << "Hello, world!" << std::endl; - } -}; - - -int main(int /*argc*/, char **/*argv*/) { - TestThread t1; - TestThread t2; - TestThread t3; - t1.start(); - t2.start(); - t3.start(); - usleep(500000); - usleep(600000); - return 0; -} diff --git a/debuggers/gdb/unittests/path with space/CMakeLists.txt b/debuggers/gdb/unittests/path with space/CMakeLists.txt deleted file mode 100644 --- a/debuggers/gdb/unittests/path with space/CMakeLists.txt +++ /dev/null @@ -1,2 +0,0 @@ -add_debuggable_executable(spacedebugee SRCS "spacedebugee.cpp") -target_link_libraries(spacedebugee Qt5::Core) diff --git a/debuggers/gdb/unittests/path with space/spacedebugee.cpp b/debuggers/gdb/unittests/path with space/spacedebugee.cpp deleted file mode 100644 --- a/debuggers/gdb/unittests/path with space/spacedebugee.cpp +++ /dev/null @@ -1,31 +0,0 @@ -/* - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License version 2 as published by the Free Software Foundation. - - 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 -#include -#include -#include - -int main(int argc, char *argv[]) -{ - QCoreApplication a(argc, argv); - - if (QCoreApplication::applicationDirPath() != QDir::currentPath()) { - qWarning() << "Unexpected app dir path: " << QCoreApplication::applicationDirPath() << QDir::currentPath(); - return 1; - } - - return 0; -} diff --git a/debuggers/gdb/unittests/test_gdb.cpp b/debuggers/gdb/unittests/test_gdb.cpp --- a/debuggers/gdb/unittests/test_gdb.cpp +++ b/debuggers/gdb/unittests/test_gdb.cpp @@ -24,6 +24,8 @@ #include "mi/micommand.h" #include "mi/milexer.h" #include "mi/miparser.h" +#include "tests/debuggers-tests-config.h" +#include "tests/testhelper.h" #include #include @@ -52,49 +54,18 @@ #include #include -using KDevelop::AutoTestShell; - -namespace KDevMI { namespace GDB { - -QUrl findExecutable(const QString& name) -{ - QFileInfo info(qApp->applicationDirPath() + "/unittests/" + name); - Q_ASSERT(info.exists()); - Q_ASSERT(info.isExecutable()); - return QUrl::fromLocalFile(info.canonicalFilePath()); -} - -QString findSourceFile(const QString& name) -{ - QFileInfo info(QFileInfo(__FILE__).dir().absoluteFilePath(name)); - Q_ASSERT(info.exists()); - return info.canonicalFilePath(); -} - -static bool isAttachForbidden(const char * file, int line) -{ - // if on linux, ensure we can actually attach - QFile canRun(QStringLiteral("/proc/sys/kernel/yama/ptrace_scope")); - if (canRun.exists()) { - if (!canRun.open(QIODevice::ReadOnly)) { - QTest::qFail("Something is wrong: /proc/sys/kernel/yama/ptrace_scope exists but cannot be read", file, line); - return true; - } - if (canRun.read(1).toInt() != 0) { - QTest::qSkip("ptrace attaching not allowed, skipping test. To enable it, set /proc/sys/kernel/yama/ptrace_scope to 0.", file, line); - return true; - } - } - - return false; -} - #define SKIP_IF_ATTACH_FORBIDDEN() \ do { \ - if (isAttachForbidden(__FILE__, __LINE__)) \ + if (KDevMI::isAttachForbidden(__FILE__, __LINE__)) \ return; \ } while(0) +using KDevelop::AutoTestShell; +using KDevMI::findExecutable; +using KDevMI::findSourceFile; + +namespace KDevMI { namespace GDB { + void GdbTest::initTestCase() { AutoTestShell::init(); @@ -139,7 +110,7 @@ class TestLaunchConfiguration : public KDevelop::ILaunchConfiguration { public: - explicit TestLaunchConfiguration(const QUrl& executable = findExecutable(QStringLiteral("debugee")), + explicit TestLaunchConfiguration(const QUrl& executable = findExecutable(QStringLiteral("debuggee_debugee")), const QUrl& workingDirectory = QUrl()) { qDebug() << "FIND" << executable; c = new KConfig(); @@ -309,7 +280,7 @@ void GdbTest::testEnvironmentSet() { TestDebugSession *session = new TestDebugSession; - TestLaunchConfiguration cfg(findExecutable(QStringLiteral("debugeeechoenv"))); + TestLaunchConfiguration cfg(findExecutable(QStringLiteral("debuggee_debugeeechoenv"))); cfg.config().writeEntry("EnvironmentGroup", "GdbTestGroup"); @@ -471,7 +442,7 @@ breakpoints()->addCodeBreakpoint(QUrl::fromLocalFile(debugeeFileName), 28); - KDevelop::Breakpoint * b = breakpoints()->addCodeBreakpoint(QUrl::fromLocalFile(findSourceFile(QStringLiteral("test_gdb.cpp"))), 10); + KDevelop::Breakpoint * b = breakpoints()->addCodeBreakpoint(QUrl::fromLocalFile(findSourceFile(QStringLiteral("debugeeqt.cpp"))), 10); QCOMPARE(b->state(), KDevelop::Breakpoint::NotStartedState); session->startDebugging(&cfg, m_iface); @@ -689,7 +660,7 @@ void GdbTest::testInsertBreakpointWhileRunning() { TestDebugSession *session = new TestDebugSession; - TestLaunchConfiguration cfg(findExecutable(QStringLiteral("debugeeslow"))); + TestLaunchConfiguration cfg(findExecutable(QStringLiteral("debuggee_debugeeslow"))); QString fileName = findSourceFile(QStringLiteral("debugeeslow.cpp")); session->startDebugging(&cfg, m_iface); @@ -710,7 +681,7 @@ void GdbTest::testInsertBreakpointWhileRunningMultiple() { TestDebugSession *session = new TestDebugSession; - TestLaunchConfiguration cfg(findExecutable(QStringLiteral("debugeeslow"))); + TestLaunchConfiguration cfg(findExecutable(QStringLiteral("debuggee_debugeeslow"))); QString fileName = findSourceFile(QStringLiteral("debugeeslow.cpp")); session->startDebugging(&cfg, m_iface); @@ -863,7 +834,7 @@ void GdbTest::testStackFetchMore() { TestDebugSession *session = new TestDebugSession; - TestLaunchConfiguration cfg(findExecutable(QStringLiteral("debugeerecursion"))); + TestLaunchConfiguration cfg(findExecutable(QStringLiteral("debuggee_debugeerecursion"))); QString fileName = findSourceFile(QStringLiteral("debugeerecursion.cpp")); TestFrameStackModel *stackModel = session->frameStackModel(); @@ -962,7 +933,7 @@ void GdbTest::testStackSwitchThread() { TestDebugSession *session = new TestDebugSession; - TestLaunchConfiguration cfg(findExecutable(QStringLiteral("debugeethreads"))); + TestLaunchConfiguration cfg(findExecutable(QStringLiteral("debuggee_debugeethreads"))); QString fileName = findSourceFile(QStringLiteral("debugeethreads.cpp")); TestFrameStackModel *stackModel = session->frameStackModel(); @@ -998,7 +969,7 @@ QString fileName = findSourceFile(QStringLiteral("debugeeslow.cpp")); KProcess debugeeProcess; - debugeeProcess << QStringLiteral("nice") << findExecutable(QStringLiteral("debugeeslow")).toLocalFile(); + debugeeProcess << QStringLiteral("nice") << findExecutable(QStringLiteral("debuggee_debugeeslow")).toLocalFile(); debugeeProcess.start(); QVERIFY(debugeeProcess.waitForStarted()); QTest::qWait(100); @@ -1027,7 +998,7 @@ QString fileName = findSourceFile(QStringLiteral("debugeeslow.cpp")); KProcess debugeeProcess; - debugeeProcess << QStringLiteral("nice") << findExecutable(QStringLiteral("debugeeslow")).toLocalFile(); + debugeeProcess << QStringLiteral("nice") << findExecutable(QStringLiteral("debuggee_debugeeslow")).toLocalFile(); debugeeProcess.start(); QVERIFY(debugeeProcess.waitForStarted()); @@ -1047,31 +1018,33 @@ void GdbTest::testCoreFile() { - QFile f(QStringLiteral("core")); - if (f.exists()) f.remove(); + QFileInfo f(QStringLiteral("core")); + if (f.exists()) QFile::remove(f.canonicalFilePath()); KProcess debugeeProcess; debugeeProcess.setOutputChannelMode(KProcess::MergedChannels); - debugeeProcess << QStringLiteral("bash") << QStringLiteral("-c") << "ulimit -c unlimited; " + findExecutable(QStringLiteral("debugeecrash")).toLocalFile(); + debugeeProcess << QStringLiteral("bash") << QStringLiteral("-c") + << "ulimit -c unlimited; " + + findExecutable(QStringLiteral("debuggee_crash")).toLocalFile(); debugeeProcess.start(); debugeeProcess.waitForFinished(); qDebug() << debugeeProcess.readAll(); - bool coreFileFound = QFile::exists(QStringLiteral("core")); + bool coreFileFound = f.exists(); if (!coreFileFound) { // Try to use coredumpctl auto coredumpctl = QStandardPaths::findExecutable(QStringLiteral("coredumpctl")); if (!coredumpctl.isEmpty()) { - QFileInfo fi(QStringLiteral("core")); - KProcess::execute(coredumpctl, {"-1", "-o", fi.absoluteFilePath(), "dump", "debugeecrash"}); - coreFileFound = fi.exists(); + KProcess::execute(coredumpctl, {"-1", "-o", f.canonicalFilePath(), "dump", "debugeecrash"}); + coreFileFound = f.exists(); } } if (!coreFileFound) QSKIP("no core dump found, check your system configuration (see /proc/sys/kernel/core_pattern).", SkipSingle); TestDebugSession *session = new TestDebugSession; - session->examineCoreFile(findExecutable(QStringLiteral("debugeecrash")), QUrl::fromLocalFile(QDir::currentPath()+"/core")); + session->examineCoreFile(findExecutable(QStringLiteral("debuggee_crash")), + QUrl::fromLocalFile(f.canonicalFilePath())); TestFrameStackModel *stackModel = session->frameStackModel(); @@ -1433,7 +1406,7 @@ { TestDebugSession *session = new TestDebugSession; session->variableController()->setAutoUpdate(KDevelop::IVariableController::UpdateLocals); - TestLaunchConfiguration cfg(findExecutable(QStringLiteral("debugeecrash"))); + TestLaunchConfiguration cfg(findExecutable(QStringLiteral("debuggee_crash"))); QString fileName = findSourceFile(QStringLiteral("debugeecrash.cpp")); breakpoints()->addCodeBreakpoint(QUrl::fromLocalFile(fileName), 23); @@ -1479,7 +1452,7 @@ void GdbTest::testInsertAndRemoveBreakpointWhileRunning() { TestDebugSession *session = new TestDebugSession; - TestLaunchConfiguration cfg(findExecutable(QStringLiteral("debugeeslow"))); + TestLaunchConfiguration cfg(findExecutable(QStringLiteral("debuggee_debugeeslow"))); QString fileName = findSourceFile(QStringLiteral("debugeeslow.cpp")); session->startDebugging(&cfg, m_iface); @@ -1497,7 +1470,7 @@ { TestDebugSession *session = new TestDebugSession; - TestLaunchConfiguration cfg(findExecutable(QStringLiteral("debugeeqt"))); + TestLaunchConfiguration cfg(findExecutable(QStringLiteral("debuggee_debugeeqt"))); breakpoints()->addCodeBreakpoint(QStringLiteral("main")); QVERIFY(session->startDebugging(&cfg, m_iface)); @@ -1537,7 +1510,7 @@ //inject here, so it behaves similar like a command from .gdbinit QTemporaryFile configScript; configScript.open(); - configScript.write(QStringLiteral("file %0\n").arg(findExecutable(QStringLiteral("debugee")).toLocalFile()).toLocal8Bit()); + configScript.write(QStringLiteral("file %0\n").arg(findExecutable(QStringLiteral("debuggee_debugee")).toLocalFile()).toLocal8Bit()); configScript.write("break debugee.cpp:32\n"); configScript.close(); @@ -1583,7 +1556,7 @@ QTemporaryFile runScript; runScript.open(); - runScript.write("file " + findExecutable(QStringLiteral("debugee")).toLocalFile().toUtf8() + "\n"); + runScript.write("file " + findExecutable(QStringLiteral("debuggee_debugee")).toLocalFile().toUtf8() + "\n"); runScript.write("break main\n"); runScript.write("run\n"); runScript.close(); @@ -1613,14 +1586,14 @@ QTemporaryFile shellScript(QDir::currentPath()+"/shellscript"); shellScript.open(); - shellScript.write("gdbserver localhost:2345 " + findExecutable(QStringLiteral("debugee")).toLocalFile().toUtf8() + "\n"); + shellScript.write("gdbserver localhost:2345 " + findExecutable(QStringLiteral("debuggee_debugee")).toLocalFile().toUtf8() + "\n"); shellScript.close(); shellScript.setPermissions(shellScript.permissions() | QFile::ExeUser); QFile::copy(shellScript.fileName(), shellScript.fileName()+"-copy"); //to avoid "Text file busy" on executing (why?) QTemporaryFile runScript(QDir::currentPath()+"/runscript"); runScript.open(); - runScript.write("file " + findExecutable(QStringLiteral("debugee")).toLocalFile().toUtf8() + "\n"); + runScript.write("file " + findExecutable(QStringLiteral("debuggee_debugee")).toLocalFile().toUtf8() + "\n"); runScript.write("target remote localhost:2345\n"); runScript.write("break debugee.cpp:30\n"); runScript.write("continue\n"); @@ -1657,14 +1630,14 @@ QTemporaryFile shellScript(QDir::currentPath()+"/shellscript"); shellScript.open(); - shellScript.write("gdbserver localhost:2345 " + findExecutable(QStringLiteral("debugee")).toLocalFile().toUtf8() + "\n"); + shellScript.write("gdbserver localhost:2345 " + findExecutable(QStringLiteral("debuggee_debugee")).toLocalFile().toUtf8() + "\n"); shellScript.close(); shellScript.setPermissions(shellScript.permissions() | QFile::ExeUser); QFile::copy(shellScript.fileName(), shellScript.fileName()+"-copy"); //to avoid "Text file busy" on executing (why?) QTemporaryFile runScript(QDir::currentPath()+"/runscript"); runScript.open(); - runScript.write("file " + findExecutable(QStringLiteral("debugee")).toLocalFile().toUtf8() + '\n'); + runScript.write("file " + findExecutable(QStringLiteral("debuggee_debugee")).toLocalFile().toUtf8() + '\n'); runScript.write("target remote localhost:2345\n"); runScript.write("break debugee.cpp:30\n"); runScript.write("continue\n"); @@ -1708,14 +1681,14 @@ QTemporaryFile shellScript(QDir::currentPath()+"/shellscript"); shellScript.open(); - shellScript.write("gdbserver localhost:2345 "+findExecutable(QStringLiteral("debugee")).toLocalFile().toLatin1()+"\n"); + shellScript.write("gdbserver localhost:2345 "+findExecutable(QStringLiteral("debuggee_debugee")).toLocalFile().toLatin1()+"\n"); shellScript.close(); shellScript.setPermissions(shellScript.permissions() | QFile::ExeUser); QFile::copy(shellScript.fileName(), shellScript.fileName()+"-copy"); //to avoid "Text file busy" on executing (why?) QTemporaryFile runScript(QDir::currentPath()+"/runscript"); runScript.open(); - runScript.write("file "+findExecutable(QStringLiteral("debugee")).toLocalFile().toLatin1()+"\n"); + runScript.write("file "+findExecutable(QStringLiteral("debuggee_debugee")).toLocalFile().toLatin1()+"\n"); runScript.write("target remote localhost:2345\n"); runScript.write("break debugee.cpp:30\n"); runScript.write("continue\n"); @@ -1767,7 +1740,7 @@ { TestDebugSession *session = new TestDebugSession; - TestLaunchConfiguration cfg(findExecutable(QStringLiteral("debugeespace"))); + TestLaunchConfiguration cfg(findExecutable(QStringLiteral("debuggee_debugeespace"))); KConfigGroup grp = cfg.config(); QString fileName = findSourceFile(QStringLiteral("debugee space.cpp")); @@ -1809,7 +1782,7 @@ TestDebugSession *session = new TestDebugSession; session->variableController()->setAutoUpdate(KDevelop::IVariableController::UpdateLocals); - TestLaunchConfiguration cfg(findExecutable(QStringLiteral("debugeeexception"))); + TestLaunchConfiguration cfg(findExecutable(QStringLiteral("debuggee_debugeeexception"))); breakpoints()->addCodeBreakpoint(QUrl::fromLocalFile(findSourceFile(QStringLiteral("debugeeexception.cpp"))), 29); @@ -1844,7 +1817,7 @@ // Check if --thread is added to user commands TestDebugSession *session = new TestDebugSession; - TestLaunchConfiguration cfg(findExecutable(QStringLiteral("debugeethreads"))); + TestLaunchConfiguration cfg(findExecutable(QStringLiteral("debuggee_debugeethreads"))); QString fileName = findSourceFile(QStringLiteral("debugeethreads.cpp")); breakpoints()->addCodeBreakpoint(QUrl::fromLocalFile(fileName), 38); @@ -1901,7 +1874,7 @@ { TestDebugSession *session = new TestDebugSession; - TestLaunchConfiguration cfg(findExecutable(QStringLiteral("debugeemultilocbreakpoint"))); + TestLaunchConfiguration cfg(findExecutable(QStringLiteral("debuggee_debugeemultilocbreakpoint"))); breakpoints()->addCodeBreakpoint(QStringLiteral("aPlusB")); @@ -1965,7 +1938,7 @@ TestDebugSession *session = new TestDebugSession; //there'll be about 3-4 breakpoints, but we treat it like one. - TestLaunchConfiguration c(findExecutable(QStringLiteral("debugeemultiplebreakpoint"))); + TestLaunchConfiguration c(findExecutable(QStringLiteral("debuggee_debugeemultiplebreakpoint"))); KDevelop::Breakpoint *b = breakpoints()->addCodeBreakpoint(QStringLiteral("debugeemultiplebreakpoint.cpp:52")); session->startDebugging(&c, m_iface); WAIT_FOR_STATE(session, DebugSession::PausedState); @@ -1980,7 +1953,7 @@ { TestDebugSession *session = new TestDebugSession; - TestLaunchConfiguration c(findExecutable(QStringLiteral("debugeemultilocbreakpoint"))); + TestLaunchConfiguration c(findExecutable(QStringLiteral("debuggee_debugeemultilocbreakpoint"))); breakpoints()->addCodeBreakpoint(QStringLiteral("main")); session->startDebugging(&c, m_iface); WAIT_FOR_STATE(session, DebugSession::PausedState); @@ -1999,7 +1972,7 @@ TestDebugSession *session = new TestDebugSession; - TestLaunchConfiguration c(findExecutable(QStringLiteral("debugeeslow"))); + TestLaunchConfiguration c(findExecutable(QStringLiteral("debuggee_debugeeslow"))); KDevelop::Breakpoint* b = breakpoints()->addCodeBreakpoint(QStringLiteral("debugeeslow.cpp:25")); session->startDebugging(&c, m_iface); @@ -2055,7 +2028,7 @@ #ifdef HAVE_PATH_WITH_SPACES_TEST TestDebugSession* session = new TestDebugSession; - auto debugee = findExecutable(QStringLiteral("path with space/spacedebugee")); + auto debugee = findExecutable(QStringLiteral("path with space/debuggee_spacedebugee")); TestLaunchConfiguration c(debugee, KIO::upUrl(debugee)); KDevelop::Breakpoint* b = breakpoints()->addCodeBreakpoint(QStringLiteral("spacedebugee.cpp:30")); QCOMPARE(b->state(), KDevelop::Breakpoint::NotStartedState); diff --git a/debuggers/lldb/unittests/CMakeLists.txt b/debuggers/lldb/unittests/CMakeLists.txt --- a/debuggers/lldb/unittests/CMakeLists.txt +++ b/debuggers/lldb/unittests/CMakeLists.txt @@ -1,21 +1,16 @@ -set(test_lldb_SRCS - test_lldb.cpp - testhelper.cpp -) - -ecm_add_test(${test_lldb_SRCS} - TEST_NAME test_lldb +ecm_add_test(test_lldb.cpp LINK_LIBRARIES kdevlldb_static + kdevdbg_testhelper KDev::Tests Qt5::Test ) # Unit tests for printers -ecm_add_test(test_lldbformatters.cpp testhelper.cpp - TEST_NAME test_lldbformatters +ecm_add_test(test_lldbformatters.cpp LINK_LIBRARIES kdevlldb_static + kdevdbg_testhelper KDev::Tests Qt5::Test ) diff --git a/debuggers/lldb/unittests/test_lldb.cpp b/debuggers/lldb/unittests/test_lldb.cpp --- a/debuggers/lldb/unittests/test_lldb.cpp +++ b/debuggers/lldb/unittests/test_lldb.cpp @@ -26,7 +26,8 @@ #include "controllers/framestackmodel.h" #include "debugsession.h" -#include "testhelper.h" +#include "tests/debuggers-tests-config.h" +#include "tests/testhelper.h" #include #include @@ -52,34 +53,33 @@ #include #define WAIT_FOR_STATE(session, state) \ - do { if (!KDevMI::LLDB::waitForState((session), (state), __FILE__, __LINE__)) return; } while (0) + do { if (!KDevMI::waitForState((session), (state), __FILE__, __LINE__)) return; } while (0) #define WAIT_FOR_STATE_AND_IDLE(session, state) \ - do { if (!KDevMI::LLDB::waitForState((session), (state), __FILE__, __LINE__, true)) return; } while (0) + do { if (!KDevMI::waitForState((session), (state), __FILE__, __LINE__, true)) return; } while (0) #define WAIT_FOR_A_WHILE(session, ms) \ - do { if (!KDevMI::LLDB::waitForAWhile((session), (ms), __FILE__, __LINE__)) return; } while (0) + do { if (!KDevMI::waitForAWhile((session), (ms), __FILE__, __LINE__)) return; } while (0) #define WAIT_FOR(session, condition) \ do { \ - KDevMI::LLDB::TestWaiter w((session), #condition, __FILE__, __LINE__); \ + KDevMI::TestWaiter w((session), #condition, __FILE__, __LINE__); \ while (w.waitUnless((condition))) /* nothing */ ; \ } while(0) #define COMPARE_DATA(index, expected) \ - do { if (!KDevMI::LLDB::compareData((index), (expected), __FILE__, __LINE__)) return; } while (0) + do { if (!KDevMI::compareData((index), (expected), __FILE__, __LINE__)) return; } while (0) #define SKIP_IF_ATTACH_FORBIDDEN() \ do { \ - if (isAttachForbidden(__FILE__, __LINE__)) \ + if (KDevMI::isAttachForbidden(__FILE__, __LINE__)) \ return; \ } while(0) -#define findSourceFile(name) \ - findSourceFile(__FILE__, (name)) - using namespace KDevelop; using namespace KDevMI::LLDB; +using KDevMI::findExecutable; +using KDevMI::findSourceFile; namespace { class WritableEnvironmentProfileList : public EnvironmentProfileList @@ -95,7 +95,7 @@ class TestLaunchConfiguration : public ILaunchConfiguration { public: - explicit TestLaunchConfiguration(const QUrl& executable = findExecutable(QStringLiteral("lldb_debugee")), + explicit TestLaunchConfiguration(const QUrl& executable = findExecutable(QStringLiteral("debuggee_debugee")), const QUrl& workingDirectory = QUrl()) { qDebug() << "FIND" << executable; c = new KConfig(); @@ -149,9 +149,14 @@ public: TestDebugSession() : DebugSession() { + // explicit set formatter path to force use in-tree formatters, not the one installed in system. + QFileInfo info(QFileInfo(__FILE__).path(), "../formatters/all.py"); + Q_ASSERT(info.exists()); + setFormatterPath(info.canonicalFilePath()); + setSourceInitFile(false); m_frameStackModel = new TestFrameStackModel(this); - setFormatterPath(findSourceFile("../formatters/all.py")); + KDevelop::ICore::self()->debugController()->addSession(this); } @@ -258,7 +263,7 @@ void LldbTest::testEnvironmentSet() { TestDebugSession *session = new TestDebugSession; - TestLaunchConfiguration cfg(findExecutable(QStringLiteral("lldb_debugeeechoenv"))); + TestLaunchConfiguration cfg(findExecutable(QStringLiteral("debuggee_debugeeechoenv"))); cfg.config().writeEntry("EnvironmentGroup", "LldbTestGroup"); @@ -674,7 +679,7 @@ void LldbTest::testInsertBreakpointWhileRunning() { TestDebugSession *session = new TestDebugSession; - TestLaunchConfiguration cfg(findExecutable(QStringLiteral("lldb_debugeeslow"))); + TestLaunchConfiguration cfg(findExecutable(QStringLiteral("debuggee_debugeeslow"))); QString fileName = findSourceFile("debugeeslow.cpp"); QVERIFY(session->startDebugging(&cfg, m_iface)); @@ -698,7 +703,7 @@ void LldbTest::testInsertBreakpointWhileRunningMultiple() { TestDebugSession *session = new TestDebugSession; - TestLaunchConfiguration cfg(findExecutable(QStringLiteral("lldb_debugeeslow"))); + TestLaunchConfiguration cfg(findExecutable(QStringLiteral("debuggee_debugeeslow"))); QString fileName = findSourceFile("debugeeslow.cpp"); QVERIFY(session->startDebugging(&cfg, m_iface)); @@ -786,7 +791,7 @@ void LldbTest::testInsertAndRemoveBreakpointWhileRunning() { TestDebugSession *session = new TestDebugSession; - TestLaunchConfiguration cfg(findExecutable(QStringLiteral("lldb_debugeeslow"))); + TestLaunchConfiguration cfg(findExecutable(QStringLiteral("debuggee_debugeeslow"))); QString fileName = findSourceFile("debugeeslow.cpp"); @@ -854,7 +859,7 @@ void LldbTest::testBreakpointWithSpaceInPath() { TestDebugSession *session = new TestDebugSession; - TestLaunchConfiguration cfg(findExecutable(QStringLiteral("lldb_debugeespace"))); + TestLaunchConfiguration cfg(findExecutable(QStringLiteral("debuggee_debugeespace"))); KConfigGroup grp = cfg.config(); QString fileName = findSourceFile("debugee space.cpp"); @@ -898,7 +903,7 @@ void LldbTest::testMultipleLocationsBreakpoint() { TestDebugSession *session = new TestDebugSession; - TestLaunchConfiguration cfg(findExecutable(QStringLiteral("lldb_debugeemultilocbreakpoint"))); + TestLaunchConfiguration cfg(findExecutable(QStringLiteral("debuggee_debugeemultilocbreakpoint"))); breakpoints()->addCodeBreakpoint(QStringLiteral("aPlusB")); @@ -921,7 +926,7 @@ TestDebugSession *session = new TestDebugSession; //there'll be about 3-4 breakpoints, but we treat it like one. - TestLaunchConfiguration c(findExecutable(QStringLiteral("lldb_debugeemultiplebreakpoint"))); + TestLaunchConfiguration c(findExecutable(QStringLiteral("debuggee_debugeemultiplebreakpoint"))); auto b = breakpoints()->addCodeBreakpoint(QStringLiteral("debugeemultiplebreakpoint.cpp:52")); QVERIFY(session->startDebugging(&c, m_iface)); @@ -939,7 +944,7 @@ QSKIP("Skipping... lldb has only one breakpoint for multiple locations" " (and lldb-mi returns the first one), not support this yet"); TestDebugSession *session = new TestDebugSession; - TestLaunchConfiguration c(findExecutable(QStringLiteral("lldb_debugeemultilocbreakpoint"))); + TestLaunchConfiguration c(findExecutable(QStringLiteral("debuggee_debugeemultilocbreakpoint"))); breakpoints()->addCodeBreakpoint(QStringLiteral("main")); QVERIFY(session->startDebugging(&c, m_iface)); @@ -961,7 +966,7 @@ { QSKIP("Skipping... lldb-mi command -break-enable doesn't enable breakpoint"); TestDebugSession *session = new TestDebugSession; - TestLaunchConfiguration c(findExecutable(QStringLiteral("lldb_debugeeslow"))); + TestLaunchConfiguration c(findExecutable(QStringLiteral("debuggee_debugeeslow"))); KDevelop::Breakpoint* b = breakpoints()->addCodeBreakpoint(QStringLiteral("debugeeslow.cpp:25")); QVERIFY(session->startDebugging(&c, m_iface)); @@ -994,7 +999,7 @@ void LldbTest::testCatchpoint() { TestDebugSession *session = new TestDebugSession; - TestLaunchConfiguration cfg(findExecutable(QStringLiteral("lldb_debugeeexception"))); + TestLaunchConfiguration cfg(findExecutable(QStringLiteral("debuggee_debugeeexception"))); session->variableController()->setAutoUpdate(KDevelop::IVariableController::UpdateLocals); TestFrameStackModel* fsModel = session->frameStackModel(); @@ -1114,7 +1119,7 @@ void LldbTest::testStackFetchMore() { TestDebugSession *session = new TestDebugSession; - TestLaunchConfiguration cfg(findExecutable(QStringLiteral("lldb_debugeerecursion"))); + TestLaunchConfiguration cfg(findExecutable(QStringLiteral("debuggee_debugeerecursion"))); QString fileName = findSourceFile("debugeerecursion.cpp"); TestFrameStackModel *stackModel = session->frameStackModel(); @@ -1223,7 +1228,7 @@ { QSKIP("Skipping... lldb-mi crashes when break at a location with multiple threads running"); TestDebugSession *session = new TestDebugSession; - TestLaunchConfiguration cfg(findExecutable(QStringLiteral("lldb_debugeethreads"))); + TestLaunchConfiguration cfg(findExecutable(QStringLiteral("debuggee_debugeethreads"))); QString fileName = findSourceFile("debugeethreads.cpp"); TestFrameStackModel *stackModel = session->frameStackModel(); @@ -1259,7 +1264,7 @@ QString fileName = findSourceFile("debugeeslow.cpp"); KProcess debugeeProcess; - debugeeProcess << QStringLiteral("nice") << findExecutable(QStringLiteral("lldb_debugeeslow")).toLocalFile(); + debugeeProcess << QStringLiteral("nice") << findExecutable(QStringLiteral("debuggee_debugeeslow")).toLocalFile(); debugeeProcess.start(); QVERIFY(debugeeProcess.waitForStarted()); QTest::qWait(100); @@ -1307,31 +1312,33 @@ void LldbTest::testCoreFile() { - QFile f(QStringLiteral("core")); - if (f.exists()) f.remove(); + QFileInfo f(QStringLiteral("core")); + if (f.exists()) QFile::remove(f.canonicalFilePath()); KProcess debugeeProcess; debugeeProcess.setOutputChannelMode(KProcess::MergedChannels); - debugeeProcess << QStringLiteral("bash") << QStringLiteral("-c") << "ulimit -c unlimited; " + findExecutable(QStringLiteral("lldb_crash")).toLocalFile(); + debugeeProcess << QStringLiteral("bash") << QStringLiteral("-c") + << "ulimit -c unlimited; " + + findExecutable(QStringLiteral("debuggee_crash")).toLocalFile(); debugeeProcess.start(); debugeeProcess.waitForFinished(); qDebug() << debugeeProcess.readAll(); - bool coreFileFound = QFile::exists(QStringLiteral("core")); + bool coreFileFound = f.exists(); if (!coreFileFound) { // Try to use coredumpctl auto coredumpctl = QStandardPaths::findExecutable(QStringLiteral("coredumpctl")); if (!coredumpctl.isEmpty()) { - QFileInfo fi(QStringLiteral("core")); - KProcess::execute(coredumpctl, {"-1", "-o", fi.absoluteFilePath(), "dump", "lldb_crash"}); - coreFileFound = fi.exists(); + KProcess::execute(coredumpctl, {"-1", "-o", f.canonicalFilePath(), "dump", "debuggee_crash"}); + coreFileFound = f.exists(); } } if (!coreFileFound) QSKIP("no core dump found, check your system configuration (see /proc/sys/kernel/core_pattern).", SkipSingle); TestDebugSession *session = new TestDebugSession; - session->examineCoreFile(findExecutable(QStringLiteral("lldb_crash")), QUrl::fromLocalFile(QDir::currentPath()+"/core")); + session->examineCoreFile(findExecutable(QStringLiteral("debuggee_crash")), + QUrl::fromLocalFile(f.canonicalFilePath())); TestFrameStackModel *stackModel = session->frameStackModel(); @@ -1702,7 +1709,7 @@ void LldbTest::testSegfaultDebugee() { TestDebugSession *session = new TestDebugSession; - TestLaunchConfiguration cfg(findExecutable(QStringLiteral("lldb_crash"))); + TestLaunchConfiguration cfg(findExecutable(QStringLiteral("debuggee_crash"))); session->variableController()->setAutoUpdate(KDevelop::IVariableController::UpdateLocals); @@ -1726,7 +1733,7 @@ void LldbTest::testCommandOrderFastStepping() { TestDebugSession *session = new TestDebugSession; - TestLaunchConfiguration cfg(findExecutable(QStringLiteral("lldb_debugeeqt"))); + TestLaunchConfiguration cfg(findExecutable(QStringLiteral("debuggee_debugeeqt"))); breakpoints()->addCodeBreakpoint(QStringLiteral("main")); QVERIFY(session->startDebugging(&cfg, m_iface)); @@ -1841,7 +1848,7 @@ TestDebugSession* session = new TestDebugSession; - auto debugee = findExecutable(QStringLiteral("path with space/lldb_spacedebugee")); + auto debugee = findExecutable(QStringLiteral("path with space/debuggee_spacedebugee")); TestLaunchConfiguration c(debugee, KIO::upUrl(debugee)); KDevelop::Breakpoint* b = breakpoints()->addCodeBreakpoint(QStringLiteral("spacedebugee.cpp:30")); QCOMPARE(b->state(), KDevelop::Breakpoint::NotStartedState); @@ -1861,8 +1868,8 @@ QSignalSpy outputSpy(session, &TestDebugSession::inferiorStdoutLines); - auto path = KIO::upUrl(findExecutable(QStringLiteral("path with space/lldb_spacedebugee"))); - TestLaunchConfiguration cfg(findExecutable(QStringLiteral("lldb_debugeepath")), path); + auto path = KIO::upUrl(findExecutable(QStringLiteral("path with space/debuggee_spacedebugee"))); + TestLaunchConfiguration cfg(findExecutable(QStringLiteral("debuggee_debugeepath")), path); QVERIFY(session->startDebugging(&cfg, m_iface)); WAIT_FOR_STATE(session, KDevelop::IDebugSession::EndedState); diff --git a/debuggers/lldb/unittests/test_lldbformatters.cpp b/debuggers/lldb/unittests/test_lldbformatters.cpp --- a/debuggers/lldb/unittests/test_lldbformatters.cpp +++ b/debuggers/lldb/unittests/test_lldbformatters.cpp @@ -26,7 +26,7 @@ #include "controllers/variablecontroller.h" #include "debugsession.h" #include "stringhelpers.h" -#include "testhelper.h" +#include "tests/testhelper.h" #include #include @@ -48,25 +48,25 @@ #include #define WAIT_FOR_STATE(session, state) \ - do { if (!KDevMI::LLDB::waitForState((session), (state), __FILE__, __LINE__)) return; } while (0) + do { if (!KDevMI::waitForState((session), (state), __FILE__, __LINE__)) return; } while (0) #define WAIT_FOR_STATE_AND_IDLE(session, state) \ - do { if (!KDevMI::LLDB::waitForState((session), (state), __FILE__, __LINE__, true)) return; } while (0) + do { if (!KDevMI::waitForState((session), (state), __FILE__, __LINE__, true)) return; } while (0) #define WAIT_FOR_A_WHILE_AND_IDLE(session, ms) \ - do { if (!KDevMI::LLDB::waitForAWhile((session), (ms), __FILE__, __LINE__)) return; \ - if (!KDevMI::LLDB::waitForState((session), DebugSession::PausedState, __FILE__, __LINE__, true)) \ + do { if (!KDevMI::waitForAWhile((session), (ms), __FILE__, __LINE__)) return; \ + if (!KDevMI::waitForState((session), DebugSession::PausedState, __FILE__, __LINE__, true)) \ return; \ } while (0) #define WAIT_FOR(session, condition) \ do { \ - KDevMI::LLDB::TestWaiter w((session), #condition, __FILE__, __LINE__); \ + KDevMI::TestWaiter w((session), #condition, __FILE__, __LINE__); \ while (w.waitUnless((condition))) /* nothing */ ; \ } while(0) #define COMPARE_DATA(index, expected) \ - do { if (!KDevMI::LLDB::compareData((index), (expected), __FILE__, __LINE__)) return; } while (0) + do { if (!KDevMI::compareData((index), (expected), __FILE__, __LINE__)) return; } while (0) #define VERIFY_LOCAL(row, name, summary, children) \ do { \ @@ -80,11 +80,11 @@ return; \ } while (0) -#define findSourceFile(name) \ - findSourceFile(__FILE__, (name)) - using namespace KDevelop; using namespace KDevMI::LLDB; +using KDevMI::findExecutable; +using KDevMI::findSourceFile; +using KDevMI::compareData; class TestLaunchConfiguration : public ILaunchConfiguration { @@ -122,7 +122,10 @@ TestDebugSession() : DebugSession() { setSourceInitFile(false); - setFormatterPath(findSourceFile("../formatters/all.py")); + // explicit set formatter path to force use in-tree formatters, not the one installed in system. + QFileInfo info(QFileInfo(__FILE__).path(), "../formatters/all.py"); + Q_ASSERT(info.exists()); + setFormatterPath(info.canonicalFilePath()); KDevelop::ICore::self()->debugController()->addSession(this);