From b9c1b51e45b845debb76d8658edabca70ca56079 Mon Sep 17 00:00:00 2001 From: Kate Stone Date: Tue, 6 Sep 2016 20:57:50 +0000 Subject: =?UTF-8?q?***=20This=20commit=20represents=20a=20complete=20refor?= =?UTF-8?q?matting=20of=20the=20LLDB=20source=20code=20***=20to=20conform?= =?UTF-8?q?=20to=20clang-format=E2=80=99s=20LLVM=20style.=20=20This=20kind?= =?UTF-8?q?=20of=20mass=20change=20has=20***=20two=20obvious=20implication?= =?UTF-8?q?s:?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Firstly, merging this particular commit into a downstream fork may be a huge effort. Alternatively, it may be worth merging all changes up to this commit, performing the same reformatting operation locally, and then discarding the merge for this particular commit. The commands used to accomplish this reformatting were as follows (with current working directory as the root of the repository): find . \( -iname "*.c" -or -iname "*.cpp" -or -iname "*.h" -or -iname "*.mm" \) -exec clang-format -i {} + find . -iname "*.py" -exec autopep8 --in-place --aggressive --aggressive {} + ; The version of clang-format used was 3.9.0, and autopep8 was 1.2.4. Secondly, “blame” style tools will generally point to this commit instead of a meaningful prior commit. There are alternatives available that will attempt to look through this change and find the appropriate prior commit. YMMV. llvm-svn: 280751 --- lldb/unittests/Utility/ModuleCacheTest.cpp | 224 ++++++++++++++--------------- 1 file changed, 107 insertions(+), 117 deletions(-) (limited to 'lldb/unittests/Utility/ModuleCacheTest.cpp') diff --git a/lldb/unittests/Utility/ModuleCacheTest.cpp b/lldb/unittests/Utility/ModuleCacheTest.cpp index 53bfc88..911c278 100644 --- a/lldb/unittests/Utility/ModuleCacheTest.cpp +++ b/lldb/unittests/Utility/ModuleCacheTest.cpp @@ -16,24 +16,20 @@ extern const char *TestMainArgv0; using namespace lldb_private; using namespace lldb; -namespace -{ +namespace { -class ModuleCacheTest : public testing::Test -{ +class ModuleCacheTest : public testing::Test { public: - static void - SetUpTestCase(); + static void SetUpTestCase(); - static void - TearDownTestCase(); + static void TearDownTestCase(); protected: - static FileSpec s_cache_dir; - static llvm::SmallString<128> s_test_executable; + static FileSpec s_cache_dir; + static llvm::SmallString<128> s_test_executable; - void - TryGetAndPut(const FileSpec &cache_dir, const char *hostname, bool expect_download); + void TryGetAndPut(const FileSpec &cache_dir, const char *hostname, + bool expect_download); }; } @@ -43,137 +39,131 @@ llvm::SmallString<128> ModuleCacheTest::s_test_executable; static const char dummy_hostname[] = "dummy_hostname"; static const char dummy_remote_dir[] = "bin"; static const char module_name[] = "TestModule.so"; -static const char module_uuid[] = "F4E7E991-9B61-6AD4-0073-561AC3D9FA10-C043A476"; +static const char module_uuid[] = + "F4E7E991-9B61-6AD4-0073-561AC3D9FA10-C043A476"; static const uint32_t uuid_bytes = 20; static const size_t module_size = 5602; -static FileSpec -GetDummyRemotePath() -{ - FileSpec fs("/", false, FileSpec::ePathSyntaxPosix); - fs.AppendPathComponent(dummy_remote_dir); - fs.AppendPathComponent(module_name); - return fs; +static FileSpec GetDummyRemotePath() { + FileSpec fs("/", false, FileSpec::ePathSyntaxPosix); + fs.AppendPathComponent(dummy_remote_dir); + fs.AppendPathComponent(module_name); + return fs; } -static FileSpec -GetUuidView(FileSpec spec) -{ - spec.AppendPathComponent(".cache"); - spec.AppendPathComponent(module_uuid); - spec.AppendPathComponent(module_name); - return spec; +static FileSpec GetUuidView(FileSpec spec) { + spec.AppendPathComponent(".cache"); + spec.AppendPathComponent(module_uuid); + spec.AppendPathComponent(module_name); + return spec; } -static FileSpec -GetSysrootView(FileSpec spec, const char *hostname) -{ - spec.AppendPathComponent(hostname); - spec.AppendPathComponent(dummy_remote_dir); - spec.AppendPathComponent(module_name); - return spec; +static FileSpec GetSysrootView(FileSpec spec, const char *hostname) { + spec.AppendPathComponent(hostname); + spec.AppendPathComponent(dummy_remote_dir); + spec.AppendPathComponent(module_name); + return spec; } -void -ModuleCacheTest::SetUpTestCase() -{ - HostInfo::Initialize(); - ObjectFileELF::Initialize(); +void ModuleCacheTest::SetUpTestCase() { + HostInfo::Initialize(); + ObjectFileELF::Initialize(); - FileSpec tmpdir_spec; - HostInfo::GetLLDBPath(lldb::ePathTypeLLDBTempSystemDir, s_cache_dir); + FileSpec tmpdir_spec; + HostInfo::GetLLDBPath(lldb::ePathTypeLLDBTempSystemDir, s_cache_dir); - llvm::StringRef exe_folder = llvm::sys::path::parent_path(TestMainArgv0); - s_test_executable = exe_folder; - llvm::sys::path::append(s_test_executable, "Inputs", module_name); + llvm::StringRef exe_folder = llvm::sys::path::parent_path(TestMainArgv0); + s_test_executable = exe_folder; + llvm::sys::path::append(s_test_executable, "Inputs", module_name); } -void -ModuleCacheTest::TearDownTestCase() -{ - ObjectFileELF::Terminate(); - HostInfo::Terminate(); +void ModuleCacheTest::TearDownTestCase() { + ObjectFileELF::Terminate(); + HostInfo::Terminate(); } -static void -VerifyDiskState(const FileSpec &cache_dir, const char *hostname) -{ - FileSpec uuid_view = GetUuidView(cache_dir); - EXPECT_TRUE(uuid_view.Exists()) << "uuid_view is: " << uuid_view.GetCString(); - EXPECT_EQ(module_size, uuid_view.GetByteSize()); +static void VerifyDiskState(const FileSpec &cache_dir, const char *hostname) { + FileSpec uuid_view = GetUuidView(cache_dir); + EXPECT_TRUE(uuid_view.Exists()) << "uuid_view is: " << uuid_view.GetCString(); + EXPECT_EQ(module_size, uuid_view.GetByteSize()); - FileSpec sysroot_view = GetSysrootView(cache_dir, hostname); - EXPECT_TRUE(sysroot_view.Exists()) << "sysroot_view is: " << sysroot_view.GetCString(); - EXPECT_EQ(module_size, sysroot_view.GetByteSize()); + FileSpec sysroot_view = GetSysrootView(cache_dir, hostname); + EXPECT_TRUE(sysroot_view.Exists()) << "sysroot_view is: " + << sysroot_view.GetCString(); + EXPECT_EQ(module_size, sysroot_view.GetByteSize()); } -void -ModuleCacheTest::TryGetAndPut(const FileSpec &cache_dir, const char *hostname, bool expect_download) -{ - ModuleCache mc; - ModuleSpec module_spec; - module_spec.GetFileSpec() = GetDummyRemotePath(); - module_spec.GetUUID().SetFromCString(module_uuid, uuid_bytes); - module_spec.SetObjectSize(module_size); - ModuleSP module_sp; - bool did_create; - bool download_called = false; - - Error error = mc.GetAndPut( - cache_dir, hostname, module_spec, - [this, &download_called](const ModuleSpec &module_spec, const FileSpec &tmp_download_file_spec) { - download_called = true; - EXPECT_STREQ(GetDummyRemotePath().GetCString(), module_spec.GetFileSpec().GetCString()); - std::error_code ec = llvm::sys::fs::copy_file(s_test_executable, tmp_download_file_spec.GetCString()); - EXPECT_FALSE(ec); - return Error(); - }, - [](const ModuleSP &module_sp, const FileSpec &tmp_download_file_spec) { return Error("Not supported."); }, - module_sp, &did_create); - EXPECT_EQ(expect_download, download_called); - - EXPECT_TRUE(error.Success()) << "Error was: " << error.AsCString(); - EXPECT_TRUE(did_create); - ASSERT_TRUE(bool(module_sp)); - - SymbolContextList sc_list; - EXPECT_EQ(1u, module_sp->FindFunctionSymbols(ConstString("boom"), eFunctionNameTypeFull, sc_list)); - EXPECT_STREQ(GetDummyRemotePath().GetCString(), module_sp->GetPlatformFileSpec().GetCString()); - EXPECT_STREQ(module_uuid, module_sp->GetUUID().GetAsString().c_str()); +void ModuleCacheTest::TryGetAndPut(const FileSpec &cache_dir, + const char *hostname, bool expect_download) { + ModuleCache mc; + ModuleSpec module_spec; + module_spec.GetFileSpec() = GetDummyRemotePath(); + module_spec.GetUUID().SetFromCString(module_uuid, uuid_bytes); + module_spec.SetObjectSize(module_size); + ModuleSP module_sp; + bool did_create; + bool download_called = false; + + Error error = mc.GetAndPut( + cache_dir, hostname, module_spec, + [this, &download_called](const ModuleSpec &module_spec, + const FileSpec &tmp_download_file_spec) { + download_called = true; + EXPECT_STREQ(GetDummyRemotePath().GetCString(), + module_spec.GetFileSpec().GetCString()); + std::error_code ec = llvm::sys::fs::copy_file( + s_test_executable, tmp_download_file_spec.GetCString()); + EXPECT_FALSE(ec); + return Error(); + }, + [](const ModuleSP &module_sp, const FileSpec &tmp_download_file_spec) { + return Error("Not supported."); + }, + module_sp, &did_create); + EXPECT_EQ(expect_download, download_called); + + EXPECT_TRUE(error.Success()) << "Error was: " << error.AsCString(); + EXPECT_TRUE(did_create); + ASSERT_TRUE(bool(module_sp)); + + SymbolContextList sc_list; + EXPECT_EQ(1u, module_sp->FindFunctionSymbols(ConstString("boom"), + eFunctionNameTypeFull, sc_list)); + EXPECT_STREQ(GetDummyRemotePath().GetCString(), + module_sp->GetPlatformFileSpec().GetCString()); + EXPECT_STREQ(module_uuid, module_sp->GetUUID().GetAsString().c_str()); } -TEST_F(ModuleCacheTest, GetAndPut) -{ - FileSpec test_cache_dir = s_cache_dir; - test_cache_dir.AppendPathComponent("GetAndPut"); +TEST_F(ModuleCacheTest, GetAndPut) { + FileSpec test_cache_dir = s_cache_dir; + test_cache_dir.AppendPathComponent("GetAndPut"); - const bool expect_download = true; - TryGetAndPut(test_cache_dir, dummy_hostname, expect_download); - VerifyDiskState(test_cache_dir, dummy_hostname); + const bool expect_download = true; + TryGetAndPut(test_cache_dir, dummy_hostname, expect_download); + VerifyDiskState(test_cache_dir, dummy_hostname); } -TEST_F(ModuleCacheTest, GetAndPutUuidExists) -{ - FileSpec test_cache_dir = s_cache_dir; - test_cache_dir.AppendPathComponent("GetAndPutUuidExists"); +TEST_F(ModuleCacheTest, GetAndPutUuidExists) { + FileSpec test_cache_dir = s_cache_dir; + test_cache_dir.AppendPathComponent("GetAndPutUuidExists"); - FileSpec uuid_view = GetUuidView(test_cache_dir); - std::error_code ec = llvm::sys::fs::create_directories(uuid_view.GetDirectory().GetCString()); - ASSERT_FALSE(ec); - ec = llvm::sys::fs::copy_file(s_test_executable, uuid_view.GetCString()); - ASSERT_FALSE(ec); + FileSpec uuid_view = GetUuidView(test_cache_dir); + std::error_code ec = + llvm::sys::fs::create_directories(uuid_view.GetDirectory().GetCString()); + ASSERT_FALSE(ec); + ec = llvm::sys::fs::copy_file(s_test_executable, uuid_view.GetCString()); + ASSERT_FALSE(ec); - const bool expect_download = false; - TryGetAndPut(test_cache_dir, dummy_hostname, expect_download); - VerifyDiskState(test_cache_dir, dummy_hostname); + const bool expect_download = false; + TryGetAndPut(test_cache_dir, dummy_hostname, expect_download); + VerifyDiskState(test_cache_dir, dummy_hostname); } -TEST_F(ModuleCacheTest, GetAndPutStrangeHostname) -{ - FileSpec test_cache_dir = s_cache_dir; - test_cache_dir.AppendPathComponent("GetAndPutStrangeHostname"); +TEST_F(ModuleCacheTest, GetAndPutStrangeHostname) { + FileSpec test_cache_dir = s_cache_dir; + test_cache_dir.AppendPathComponent("GetAndPutStrangeHostname"); - const bool expect_download = true; - TryGetAndPut(test_cache_dir, "tab\tcolon:asterisk*", expect_download); - VerifyDiskState(test_cache_dir, "tab_colon_asterisk_"); + const bool expect_download = true; + TryGetAndPut(test_cache_dir, "tab\tcolon:asterisk*", expect_download); + VerifyDiskState(test_cache_dir, "tab_colon_asterisk_"); } -- cgit v1.1