[NFC][Coroutines] Use structured binding with llvm::enumerate in CoroSplit (#116879)
[llvm-project.git] / lldb / unittests / Host / common / ZipFileResolverTest.cpp
blob12aba31411305c50d26134b2b8cc0f99c64eb6b1
1 //===-- ZipFileResolverTest.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 "lldb/Host/common/ZipFileResolver.h"
10 #include "TestingSupport/SubsystemRAII.h"
11 #include "TestingSupport/TestUtilities.h"
12 #include "gtest/gtest.h"
14 using namespace lldb_private;
15 using namespace llvm;
17 namespace {
18 class ZipFileResolverTest : public ::testing::Test {
19 SubsystemRAII<FileSystem> subsystems;
22 std::string TestZipPath() {
23 FileSpec zip_spec(GetInputFilePath("zip-test.zip"));
24 FileSystem::Instance().Resolve(zip_spec);
25 return zip_spec.GetPath();
27 } // namespace
29 TEST_F(ZipFileResolverTest, ResolveSharedLibraryPathWithNormalFile) {
30 const FileSpec file_spec("/system/lib64/libtest.so");
32 ZipFileResolver::FileKind file_kind;
33 std::string file_path;
34 lldb::offset_t file_offset;
35 lldb::offset_t file_size;
36 ASSERT_TRUE(ZipFileResolver::ResolveSharedLibraryPath(
37 file_spec, file_kind, file_path, file_offset, file_size));
39 EXPECT_EQ(file_kind, ZipFileResolver::FileKind::eFileKindNormal);
40 EXPECT_EQ(file_path, file_spec.GetPath());
41 EXPECT_EQ(file_offset, 0UL);
42 EXPECT_EQ(file_size, 0UL);
45 TEST_F(ZipFileResolverTest, ResolveSharedLibraryPathWithZipMissing) {
46 const std::string zip_path = TestZipPath();
47 const FileSpec file_spec(zip_path + "!/lib/arm64-v8a/libmissing.so");
49 ZipFileResolver::FileKind file_kind;
50 std::string file_path;
51 lldb::offset_t file_offset;
52 lldb::offset_t file_size;
53 ASSERT_FALSE(ZipFileResolver::ResolveSharedLibraryPath(
54 file_spec, file_kind, file_path, file_offset, file_size));
57 TEST_F(ZipFileResolverTest, ResolveSharedLibraryPathWithZipExisting) {
58 const std::string zip_path = TestZipPath();
59 const FileSpec file_spec(zip_path + "!/lib/arm64-v8a/libzip-test.so");
61 ZipFileResolver::FileKind file_kind;
62 std::string file_path;
63 lldb::offset_t file_offset;
64 lldb::offset_t file_size;
65 ASSERT_TRUE(ZipFileResolver::ResolveSharedLibraryPath(
66 file_spec, file_kind, file_path, file_offset, file_size));
68 EXPECT_EQ(file_kind, ZipFileResolver::FileKind::eFileKindZip);
69 EXPECT_EQ(file_path, zip_path);
70 EXPECT_EQ(file_offset, 4096UL);
71 EXPECT_EQ(file_size, 3600UL);