[sanitizer] Improve FreeBSD ASLR detection
[llvm-project.git] / lldb / unittests / Symbol / LocateSymbolFileTest.cpp
blobc51b1ba490461e032f5c7a8b02e03ab8fa058d42
1 //===-- SymbolsTest.cpp ---------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 #include "gtest/gtest.h"
11 #include "TestingSupport/SubsystemRAII.h"
12 #include "lldb/Core/ModuleSpec.h"
13 #include "lldb/Host/FileSystem.h"
14 #include "lldb/Host/HostInfo.h"
15 #include "lldb/Symbol/LocateSymbolFile.h"
16 #include "lldb/Target/Target.h"
17 #include "lldb/Utility/Reproducer.h"
19 using namespace lldb_private;
21 namespace {
22 class SymbolsTest : public ::testing::Test {
23 public:
24 SubsystemRAII<repro::Reproducer, FileSystem, HostInfo> subsystems;
26 } // namespace
28 TEST_F(
29 SymbolsTest,
30 TerminateLocateExecutableSymbolFileForUnknownExecutableAndUnknownSymbolFile) {
31 ModuleSpec module_spec;
32 FileSpecList search_paths = Target::GetDefaultDebugFileSearchPaths();
33 FileSpec symbol_file_spec =
34 Symbols::LocateExecutableSymbolFile(module_spec, search_paths);
35 EXPECT_TRUE(symbol_file_spec.GetFilename().IsEmpty());
38 TEST_F(SymbolsTest,
39 LocateExecutableSymbolFileForUnknownExecutableAndMissingSymbolFile) {
40 ModuleSpec module_spec;
41 // using a GUID here because the symbol file shouldn't actually exist on disk
42 module_spec.GetSymbolFileSpec().SetFile(
43 "4A524676-B24B-4F4E-968A-551D465EBAF1.so", FileSpec::Style::native);
44 FileSpecList search_paths = Target::GetDefaultDebugFileSearchPaths();
45 FileSpec symbol_file_spec =
46 Symbols::LocateExecutableSymbolFile(module_spec, search_paths);
47 EXPECT_TRUE(symbol_file_spec.GetFilename().IsEmpty());