xref: /llvm-project/lldb/unittests/Symbol/LocateSymbolFileTest.cpp (revision 745e8bfd1ade216c909074153d2dc9eb39d4adb7)
180814287SRaphael Isemann //===-- SymbolsTest.cpp ---------------------------------------------------===//
280552918SZachary Turner //
380552918SZachary Turner // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
480552918SZachary Turner // See https://llvm.org/LICENSE.txt for license information.
580552918SZachary Turner // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
680552918SZachary Turner //
780552918SZachary Turner //===----------------------------------------------------------------------===//
880552918SZachary Turner 
980552918SZachary Turner #include "gtest/gtest.h"
1080552918SZachary Turner 
115dca0596SRaphael Isemann #include "TestingSupport/SubsystemRAII.h"
1280552918SZachary Turner #include "lldb/Core/ModuleSpec.h"
13*19df9aa3SJonas Devlieghere #include "lldb/Core/PluginManager.h"
1480552918SZachary Turner #include "lldb/Host/FileSystem.h"
1580552918SZachary Turner #include "lldb/Host/HostInfo.h"
16a89ce43cSZachary Turner #include "lldb/Target/Target.h"
1780552918SZachary Turner 
1880552918SZachary Turner using namespace lldb_private;
1980552918SZachary Turner 
2080552918SZachary Turner namespace {
2180552918SZachary Turner class SymbolsTest : public ::testing::Test {
2280552918SZachary Turner public:
2370599d70SJonas Devlieghere   SubsystemRAII<FileSystem, HostInfo> subsystems;
2480552918SZachary Turner };
2580552918SZachary Turner } // namespace
2680552918SZachary Turner 
TEST_F(SymbolsTest,TerminateLocateExecutableSymbolFileForUnknownExecutableAndUnknownSymbolFile)2780552918SZachary Turner TEST_F(
2880552918SZachary Turner     SymbolsTest,
2980552918SZachary Turner     TerminateLocateExecutableSymbolFileForUnknownExecutableAndUnknownSymbolFile) {
3080552918SZachary Turner   ModuleSpec module_spec;
31a89ce43cSZachary Turner   FileSpecList search_paths = Target::GetDefaultDebugFileSearchPaths();
32a89ce43cSZachary Turner   FileSpec symbol_file_spec =
33*19df9aa3SJonas Devlieghere       PluginManager::LocateExecutableSymbolFile(module_spec, search_paths);
3480552918SZachary Turner   EXPECT_TRUE(symbol_file_spec.GetFilename().IsEmpty());
3580552918SZachary Turner }
3680552918SZachary Turner 
TEST_F(SymbolsTest,LocateExecutableSymbolFileForUnknownExecutableAndMissingSymbolFile)3780552918SZachary Turner TEST_F(SymbolsTest,
3880552918SZachary Turner        LocateExecutableSymbolFileForUnknownExecutableAndMissingSymbolFile) {
3980552918SZachary Turner   ModuleSpec module_spec;
4080552918SZachary Turner   // using a GUID here because the symbol file shouldn't actually exist on disk
4180552918SZachary Turner   module_spec.GetSymbolFileSpec().SetFile(
4280552918SZachary Turner       "4A524676-B24B-4F4E-968A-551D465EBAF1.so", FileSpec::Style::native);
43a89ce43cSZachary Turner   FileSpecList search_paths = Target::GetDefaultDebugFileSearchPaths();
44a89ce43cSZachary Turner   FileSpec symbol_file_spec =
45*19df9aa3SJonas Devlieghere       PluginManager::LocateExecutableSymbolFile(module_spec, search_paths);
4680552918SZachary Turner   EXPECT_TRUE(symbol_file_spec.GetFilename().IsEmpty());
4780552918SZachary Turner }
48