================ @@ -18,6 +18,26 @@ def tearDown(self): if self.background_pid: os.kill(self.background_pid, signal.SIGKILL) + def test_getname(self): + """Test the SBModule::GetName() method""" + self.build() + target, _, _, _ = lldbutil.run_to_source_breakpoint( + self, "// break here", lldb.SBFileSpec("main.c") + ) + + self.assertGreater(target.GetNumModules(), 0) + for i in range(target.GetNumModules()): + module = target.GetModuleAtIndex(i) + file_spec = module.GetFileSpec() + name = module.GetName() + if file_spec.IsValid() and file_spec.exists: +#If file is valid and file exist, expect GetName() to be None + self.assertIsNone(name, f"Expected None for module with valid file {file_spec.GetFilename()}, got {name!r}") + else: +#If no valid file, expect GetName() to be a non - empty string + self.assertIsInstance(name, str) + self.assertTrue(name, "Expected a non-empty name for module without a valid file") ---------------- labath wrote:
Why should that be true? I think we need to start by defining what exactly do you expect this function to return. https://github.com/llvm/llvm-project/pull/150331 _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits