[Lldb-commits] [lldb] 39299f0 - [lldb][LocateModuleCallback] Fix LocateModuleCallbackTest

Kazuki Sakamoto via lldb-commits lldb-commits at lists.llvm.org
Sat Jul 15 12:17:00 PDT 2023


Author: Kazuki Sakamoto
Date: 2023-07-15T11:53:06-07:00
New Revision: 39299f0d367d4ff6b1d1eede80ffb09718614e53

URL: https://github.com/llvm/llvm-project/commit/39299f0d367d4ff6b1d1eede80ffb09718614e53
DIFF: https://github.com/llvm/llvm-project/commit/39299f0d367d4ff6b1d1eede80ffb09718614e53.diff

LOG: [lldb][LocateModuleCallback] Fix LocateModuleCallbackTest

ModuleList unexpectedly caches module beyond test.
Tear it down.

- https://green.lab.llvm.org/green/view/LLDB/job/as-lldb-cmake/2260/testReport/junit/lldb-unit/Target___TargetTests_LocateModuleCallbackTest/GetOrCreateModuleWithCachedModule/
- https://green.lab.llvm.org/green/view/LLDB/job/as-lldb-cmake/2260/testReport/junit/lldb-unit/Target___TargetTests_LocateModuleCallbackTest/GetOrCreateModuleWithCachedModuleAndSymbol/

Differential Revision: https://reviews.llvm.org/D155333

Added: 
    

Modified: 
    lldb/unittests/Target/LocateModuleCallbackTest.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/unittests/Target/LocateModuleCallbackTest.cpp b/lldb/unittests/Target/LocateModuleCallbackTest.cpp
index ad96adb32a471a..3f8eb2f18ac7e5 100644
--- a/lldb/unittests/Target/LocateModuleCallbackTest.cpp
+++ b/lldb/unittests/Target/LocateModuleCallbackTest.cpp
@@ -233,6 +233,11 @@ class LocateModuleCallbackTest : public testing::Test {
     m_module_spec = GetTestModuleSpec();
   }
 
+  void TearDown() override {
+    if (m_module_sp)
+      ModuleList::RemoveSharedModule(m_module_sp);
+  }
+
   void CheckNoCallback() {
     EXPECT_FALSE(m_platform_sp->GetLocateModuleCallback());
     EXPECT_EQ(m_callback_call_count, 0);
@@ -257,51 +262,39 @@ class LocateModuleCallbackTest : public testing::Test {
   TargetSP m_target_sp;
   ProcessSP m_process_sp;
   ModuleSpec m_module_spec;
+  ModuleSP m_module_sp;
   int m_callback_call_count = 0;
 };
 
 } // namespace
 
 TEST_F(LocateModuleCallbackTest, GetOrCreateModuleWithCachedModule) {
-  // Disable test on arm64 because of failures in the lldb incremental arm64
-  // bot.
-#if defined(__arm64__) || defined(__aarch64__) || defined(_M_ARM64)
-  GTEST_SKIP() << "broken on arm64.";
-#endif
   // The module file is cached, and the locate module callback is not set.
   // GetOrCreateModule should succeed to return the module from the cache.
   FileSpec uuid_view = BuildCacheDir(m_test_dir);
 
   CheckNoCallback();
 
-  ModuleSP module_sp =
-      m_target_sp->GetOrCreateModule(m_module_spec, /*notify=*/false);
-  CheckModule(module_sp);
-  ASSERT_EQ(module_sp->GetFileSpec(), uuid_view);
-  ASSERT_FALSE(module_sp->GetSymbolFileFileSpec());
-  CheckStrippedSymbol(module_sp);
+  m_module_sp = m_target_sp->GetOrCreateModule(m_module_spec, /*notify=*/false);
+  CheckModule(m_module_sp);
+  ASSERT_EQ(m_module_sp->GetFileSpec(), uuid_view);
+  ASSERT_FALSE(m_module_sp->GetSymbolFileFileSpec());
+  CheckStrippedSymbol(m_module_sp);
 }
 
 TEST_F(LocateModuleCallbackTest, GetOrCreateModuleWithCachedModuleAndSymbol) {
   // The module and symbol files are cached, and the locate module callback is
   // not set. GetOrCreateModule should succeed to return the module from the
   // cache with the symbol.
-
-  // Disable test on arm64 because of failures in the lldb incremental arm64
-  // bot.
-#if defined(__arm64__) || defined(__aarch64__) || defined(_M_ARM64)
-  GTEST_SKIP() << "broken on arm64.";
-#endif
   FileSpec uuid_view = BuildCacheDirWithSymbol(m_test_dir);
 
   CheckNoCallback();
 
-  ModuleSP module_sp =
-      m_target_sp->GetOrCreateModule(m_module_spec, /*notify=*/false);
-  CheckModule(module_sp);
-  ASSERT_EQ(module_sp->GetFileSpec(), uuid_view);
-  ASSERT_EQ(module_sp->GetSymbolFileFileSpec(), GetSymFileSpec(uuid_view));
-  CheckUnstrippedSymbol(module_sp);
+  m_module_sp = m_target_sp->GetOrCreateModule(m_module_spec, /*notify=*/false);
+  CheckModule(m_module_sp);
+  ASSERT_EQ(m_module_sp->GetFileSpec(), uuid_view);
+  ASSERT_EQ(m_module_sp->GetSymbolFileFileSpec(), GetSymFileSpec(uuid_view));
+  CheckUnstrippedSymbol(m_module_sp);
 }
 
 TEST_F(LocateModuleCallbackTest,
@@ -313,12 +306,11 @@ TEST_F(LocateModuleCallbackTest,
 
   CheckNoCallback();
 
-  ModuleSP module_sp =
-      m_target_sp->GetOrCreateModule(m_module_spec, /*notify=*/false);
-  CheckModule(module_sp);
-  ASSERT_EQ(module_sp->GetFileSpec(), uuid_view);
-  ASSERT_EQ(module_sp->GetSymbolFileFileSpec(), GetSymFileSpec(uuid_view));
-  CheckUnstrippedSymbol(module_sp);
+  m_module_sp = m_target_sp->GetOrCreateModule(m_module_spec, /*notify=*/false);
+  CheckModule(m_module_sp);
+  ASSERT_EQ(m_module_sp->GetFileSpec(), uuid_view);
+  ASSERT_EQ(m_module_sp->GetSymbolFileFileSpec(), GetSymFileSpec(uuid_view));
+  CheckUnstrippedSymbol(m_module_sp);
 }
 
 TEST_F(LocateModuleCallbackTest, GetOrCreateModuleFailure) {
@@ -329,9 +321,8 @@ TEST_F(LocateModuleCallbackTest, GetOrCreateModuleFailure) {
 
   CheckNoCallback();
 
-  ModuleSP module_sp =
-      m_target_sp->GetOrCreateModule(m_module_spec, /*notify=*/false);
-  ASSERT_FALSE(module_sp);
+  m_module_sp = m_target_sp->GetOrCreateModule(m_module_spec, /*notify=*/false);
+  ASSERT_FALSE(m_module_sp);
 }
 
 TEST_F(LocateModuleCallbackTest, GetOrCreateModuleCallbackFailureNoCache) {
@@ -347,9 +338,8 @@ TEST_F(LocateModuleCallbackTest, GetOrCreateModuleCallbackFailureNoCache) {
     return Status("The locate module callback failed");
   });
 
-  ModuleSP module_sp =
-      m_target_sp->GetOrCreateModule(m_module_spec, /*notify=*/false);
-  ASSERT_FALSE(module_sp);
+  m_module_sp = m_target_sp->GetOrCreateModule(m_module_spec, /*notify=*/false);
+  ASSERT_FALSE(m_module_sp);
 }
 
 TEST_F(LocateModuleCallbackTest, GetOrCreateModuleCallbackFailureCached) {
@@ -365,12 +355,11 @@ TEST_F(LocateModuleCallbackTest, GetOrCreateModuleCallbackFailureCached) {
     return Status("The locate module callback failed");
   });
 
-  ModuleSP module_sp =
-      m_target_sp->GetOrCreateModule(m_module_spec, /*notify=*/false);
-  CheckModule(module_sp);
-  ASSERT_EQ(module_sp->GetFileSpec(), uuid_view);
-  ASSERT_FALSE(module_sp->GetSymbolFileFileSpec());
-  CheckStrippedSymbol(module_sp);
+  m_module_sp = m_target_sp->GetOrCreateModule(m_module_spec, /*notify=*/false);
+  CheckModule(m_module_sp);
+  ASSERT_EQ(m_module_sp->GetFileSpec(), uuid_view);
+  ASSERT_FALSE(m_module_sp->GetSymbolFileFileSpec());
+  CheckStrippedSymbol(m_module_sp);
 }
 
 TEST_F(LocateModuleCallbackTest, GetOrCreateModuleCallbackNoFiles) {
@@ -388,12 +377,12 @@ TEST_F(LocateModuleCallbackTest, GetOrCreateModuleCallbackNoFiles) {
     return Status();
   });
 
-  ModuleSP module_sp =
-      m_target_sp->GetOrCreateModule(m_module_spec, /*notify=*/false);
-  CheckModule(module_sp);
-  ASSERT_EQ(module_sp->GetFileSpec(), uuid_view);
-  ASSERT_FALSE(module_sp->GetSymbolFileFileSpec());
-  CheckStrippedSymbol(module_sp);
+  m_module_sp = m_target_sp->GetOrCreateModule(m_module_spec, /*notify=*/false);
+  CheckModule(m_module_sp);
+  ASSERT_EQ(m_module_sp->GetFileSpec(), uuid_view);
+  ASSERT_FALSE(m_module_sp->GetSymbolFileFileSpec());
+  CheckStrippedSymbol(m_module_sp);
+  ModuleList::RemoveSharedModule(m_module_sp);
 }
 
 TEST_F(LocateModuleCallbackTest, GetOrCreateModuleCallbackNonExistentModule) {
@@ -410,12 +399,12 @@ TEST_F(LocateModuleCallbackTest, GetOrCreateModuleCallbackNonExistentModule) {
     return Status();
   });
 
-  ModuleSP module_sp =
-      m_target_sp->GetOrCreateModule(m_module_spec, /*notify=*/false);
-  CheckModule(module_sp);
-  ASSERT_EQ(module_sp->GetFileSpec(), uuid_view);
-  ASSERT_FALSE(module_sp->GetSymbolFileFileSpec());
-  CheckStrippedSymbol(module_sp);
+  m_module_sp = m_target_sp->GetOrCreateModule(m_module_spec, /*notify=*/false);
+  CheckModule(m_module_sp);
+  ASSERT_EQ(m_module_sp->GetFileSpec(), uuid_view);
+  ASSERT_FALSE(m_module_sp->GetSymbolFileFileSpec());
+  CheckStrippedSymbol(m_module_sp);
+  ModuleList::RemoveSharedModule(m_module_sp);
 }
 
 TEST_F(LocateModuleCallbackTest, GetOrCreateModuleCallbackNonExistentSymbol) {
@@ -435,12 +424,12 @@ TEST_F(LocateModuleCallbackTest, GetOrCreateModuleCallbackNonExistentSymbol) {
     return Status();
   });
 
-  ModuleSP module_sp =
-      m_target_sp->GetOrCreateModule(m_module_spec, /*notify=*/false);
-  CheckModule(module_sp);
-  ASSERT_EQ(module_sp->GetFileSpec(), uuid_view);
-  ASSERT_TRUE(module_sp->GetSymbolFileFileSpec().GetPath().empty());
-  CheckStrippedSymbol(module_sp);
+  m_module_sp = m_target_sp->GetOrCreateModule(m_module_spec, /*notify=*/false);
+  CheckModule(m_module_sp);
+  ASSERT_EQ(m_module_sp->GetFileSpec(), uuid_view);
+  ASSERT_TRUE(m_module_sp->GetSymbolFileFileSpec().GetPath().empty());
+  CheckStrippedSymbol(m_module_sp);
+  ModuleList::RemoveSharedModule(m_module_sp);
 }
 
 TEST_F(LocateModuleCallbackTest, GetOrCreateModuleCallbackSuccessWithModule) {
@@ -456,13 +445,13 @@ TEST_F(LocateModuleCallbackTest, GetOrCreateModuleCallbackSuccessWithModule) {
     return Status();
   });
 
-  ModuleSP module_sp =
-      m_target_sp->GetOrCreateModule(m_module_spec, /*notify=*/false);
-  CheckModule(module_sp);
-  ASSERT_EQ(module_sp->GetFileSpec(),
+  m_module_sp = m_target_sp->GetOrCreateModule(m_module_spec, /*notify=*/false);
+  CheckModule(m_module_sp);
+  ASSERT_EQ(m_module_sp->GetFileSpec(),
             FileSpec(GetInputFilePath(k_module_file)));
-  ASSERT_FALSE(module_sp->GetSymbolFileFileSpec());
-  CheckStrippedSymbol(module_sp);
+  ASSERT_FALSE(m_module_sp->GetSymbolFileFileSpec());
+  CheckStrippedSymbol(m_module_sp);
+  ModuleList::RemoveSharedModule(m_module_sp);
 }
 
 TEST_F(LocateModuleCallbackTest,
@@ -481,13 +470,13 @@ TEST_F(LocateModuleCallbackTest,
     return Status();
   });
 
-  ModuleSP module_sp =
-      m_target_sp->GetOrCreateModule(m_module_spec, /*notify=*/false);
-  CheckModule(module_sp);
-  ASSERT_EQ(module_sp->GetFileSpec(),
+  m_module_sp = m_target_sp->GetOrCreateModule(m_module_spec, /*notify=*/false);
+  CheckModule(m_module_sp);
+  ASSERT_EQ(m_module_sp->GetFileSpec(),
             FileSpec(GetInputFilePath(k_symbol_file)));
-  ASSERT_FALSE(module_sp->GetSymbolFileFileSpec());
-  CheckUnstrippedSymbol(module_sp);
+  ASSERT_FALSE(m_module_sp->GetSymbolFileFileSpec());
+  CheckUnstrippedSymbol(m_module_sp);
+  ModuleList::RemoveSharedModule(m_module_sp);
 }
 
 TEST_F(LocateModuleCallbackTest,
@@ -507,14 +496,14 @@ TEST_F(LocateModuleCallbackTest,
     return Status();
   });
 
-  ModuleSP module_sp =
-      m_target_sp->GetOrCreateModule(m_module_spec, /*notify=*/false);
-  CheckModule(module_sp);
-  ASSERT_EQ(module_sp->GetFileSpec(),
+  m_module_sp = m_target_sp->GetOrCreateModule(m_module_spec, /*notify=*/false);
+  CheckModule(m_module_sp);
+  ASSERT_EQ(m_module_sp->GetFileSpec(),
             FileSpec(GetInputFilePath(k_symbol_file)));
-  ASSERT_EQ(module_sp->GetSymbolFileFileSpec(),
+  ASSERT_EQ(m_module_sp->GetSymbolFileFileSpec(),
             FileSpec(GetInputFilePath(k_symbol_file)));
-  CheckUnstrippedSymbol(module_sp);
+  CheckUnstrippedSymbol(m_module_sp);
+  ModuleList::RemoveSharedModule(m_module_sp);
 }
 
 TEST_F(LocateModuleCallbackTest,
@@ -533,14 +522,14 @@ TEST_F(LocateModuleCallbackTest,
     return Status();
   });
 
-  ModuleSP module_sp =
-      m_target_sp->GetOrCreateModule(m_module_spec, /*notify=*/false);
-  CheckModule(module_sp);
-  ASSERT_EQ(module_sp->GetFileSpec(),
+  m_module_sp = m_target_sp->GetOrCreateModule(m_module_spec, /*notify=*/false);
+  CheckModule(m_module_sp);
+  ASSERT_EQ(m_module_sp->GetFileSpec(),
             FileSpec(GetInputFilePath(k_module_file)));
-  ASSERT_EQ(module_sp->GetSymbolFileFileSpec(),
+  ASSERT_EQ(m_module_sp->GetSymbolFileFileSpec(),
             FileSpec(GetInputFilePath(k_symbol_file)));
-  CheckUnstrippedSymbol(module_sp);
+  CheckUnstrippedSymbol(m_module_sp);
+  ModuleList::RemoveSharedModule(m_module_sp);
 }
 
 TEST_F(LocateModuleCallbackTest,
@@ -559,14 +548,14 @@ TEST_F(LocateModuleCallbackTest,
     return Status();
   });
 
-  ModuleSP module_sp =
-      m_target_sp->GetOrCreateModule(m_module_spec, /*notify=*/false);
-  CheckModule(module_sp);
-  ASSERT_EQ(module_sp->GetFileSpec(),
+  m_module_sp = m_target_sp->GetOrCreateModule(m_module_spec, /*notify=*/false);
+  CheckModule(m_module_sp);
+  ASSERT_EQ(m_module_sp->GetFileSpec(),
             FileSpec(GetInputFilePath(k_module_file)));
-  ASSERT_EQ(module_sp->GetSymbolFileFileSpec(),
+  ASSERT_EQ(m_module_sp->GetSymbolFileFileSpec(),
             FileSpec(GetInputFilePath(k_breakpad_symbol_file)));
-  CheckUnstrippedSymbol(module_sp);
+  CheckUnstrippedSymbol(m_module_sp);
+  ModuleList::RemoveSharedModule(m_module_sp);
 }
 
 TEST_F(LocateModuleCallbackTest,
@@ -584,13 +573,13 @@ TEST_F(LocateModuleCallbackTest,
     return Status();
   });
 
-  ModuleSP module_sp =
-      m_target_sp->GetOrCreateModule(m_module_spec, /*notify=*/false);
-  CheckModule(module_sp);
-  ASSERT_EQ(module_sp->GetFileSpec(), uuid_view);
-  ASSERT_EQ(module_sp->GetSymbolFileFileSpec(),
+  m_module_sp = m_target_sp->GetOrCreateModule(m_module_spec, /*notify=*/false);
+  CheckModule(m_module_sp);
+  ASSERT_EQ(m_module_sp->GetFileSpec(), uuid_view);
+  ASSERT_EQ(m_module_sp->GetSymbolFileFileSpec(),
             FileSpec(GetInputFilePath(k_symbol_file)));
-  CheckUnstrippedSymbol(module_sp);
+  CheckUnstrippedSymbol(m_module_sp);
+  ModuleList::RemoveSharedModule(m_module_sp);
 }
 
 TEST_F(LocateModuleCallbackTest,
@@ -608,13 +597,13 @@ TEST_F(LocateModuleCallbackTest,
     return Status();
   });
 
-  ModuleSP module_sp =
-      m_target_sp->GetOrCreateModule(m_module_spec, /*notify=*/false);
-  CheckModule(module_sp);
-  ASSERT_EQ(module_sp->GetFileSpec(), uuid_view);
-  ASSERT_EQ(module_sp->GetSymbolFileFileSpec(),
+  m_module_sp = m_target_sp->GetOrCreateModule(m_module_spec, /*notify=*/false);
+  CheckModule(m_module_sp);
+  ASSERT_EQ(m_module_sp->GetFileSpec(), uuid_view);
+  ASSERT_EQ(m_module_sp->GetSymbolFileFileSpec(),
             FileSpec(GetInputFilePath(k_breakpad_symbol_file)));
-  CheckUnstrippedSymbol(module_sp);
+  CheckUnstrippedSymbol(m_module_sp);
+  ModuleList::RemoveSharedModule(m_module_sp);
 }
 
 TEST_F(LocateModuleCallbackTest,
@@ -631,9 +620,8 @@ TEST_F(LocateModuleCallbackTest,
     return Status();
   });
 
-  ModuleSP module_sp =
-      m_target_sp->GetOrCreateModule(m_module_spec, /*notify=*/false);
-  ASSERT_FALSE(module_sp);
+  m_module_sp = m_target_sp->GetOrCreateModule(m_module_spec, /*notify=*/false);
+  ASSERT_FALSE(m_module_sp);
 }
 
 TEST_F(LocateModuleCallbackTest,
@@ -650,7 +638,6 @@ TEST_F(LocateModuleCallbackTest,
     return Status();
   });
 
-  ModuleSP module_sp =
-      m_target_sp->GetOrCreateModule(m_module_spec, /*notify=*/false);
-  ASSERT_FALSE(module_sp);
-}
\ No newline at end of file
+  m_module_sp = m_target_sp->GetOrCreateModule(m_module_spec, /*notify=*/false);
+  ASSERT_FALSE(m_module_sp);
+}


        


More information about the lldb-commits mailing list