[lldb] Fixup af921006d3792f for non-linux platforms
authorPavel Labath <pavel@labath.sk>
Wed, 13 Apr 2022 13:37:44 +0000 (15:37 +0200)
committerPavel Labath <pavel@labath.sk>
Wed, 13 Apr 2022 13:38:36 +0000 (15:38 +0200)
lldb/test/API/python_api/debugger/TestDebuggerAPI.py
lldb/unittests/Platform/PlatformAppleSimulatorTest.cpp

index f0ba1d1e20aaef7e8de7f9dbf8cebc4422a218ff..ff1ebd96d401b769fa7fb247691c3465a941feb8 100644 (file)
@@ -108,7 +108,8 @@ class DebuggerAPITestCase(TestBase):
                 False, error)
         self.assertSuccess(error)
         platform2 = target2.GetPlatform()
-        self.assertEqual(platform2.GetWorkingDirectory(), "/foo/bar")
+        self.assertTrue(platform2.GetWorkingDirectory().endswith("bar"),
+                platform2.GetWorkingDirectory())
 
         # ... but create a new one if it doesn't.
         self.dbg.SetSelectedPlatform(lldb.SBPlatform("remote-windows"))
@@ -123,9 +124,11 @@ class DebuggerAPITestCase(TestBase):
         if lldbplatformutil.getHostPlatform() == 'linux':
             self.yaml2obj("macho.yaml", exe)
             arch = "x86_64-apple-macosx"
+            expected_platform = "remote-macosx"
         else:
             self.yaml2obj("elf.yaml", exe)
             arch = "x86_64-pc-linux"
+            expected_platform = "remote-linux"
 
         fbsd = lldb.SBPlatform("remote-freebsd")
         self.dbg.SetSelectedPlatform(fbsd)
@@ -134,7 +137,7 @@ class DebuggerAPITestCase(TestBase):
         target1 = self.dbg.CreateTarget(exe, arch, None, False, error)
         self.assertSuccess(error)
         platform1 = target1.GetPlatform()
-        self.assertEqual(platform1.GetName(), "remote-macosx")
+        self.assertEqual(platform1.GetName(), expected_platform)
         platform1.SetWorkingDirectory("/foo/bar")
 
         # Reuse a platform even if it is not currently selected.
@@ -142,5 +145,6 @@ class DebuggerAPITestCase(TestBase):
         target2 = self.dbg.CreateTarget(exe, arch, None, False, error)
         self.assertSuccess(error)
         platform2 = target2.GetPlatform()
-        self.assertEqual(platform2.GetName(), "remote-macosx")
-        self.assertEqual(platform2.GetWorkingDirectory(), "/foo/bar")
+        self.assertEqual(platform2.GetName(), expected_platform)
+        self.assertTrue(platform2.GetWorkingDirectory().endswith("bar"),
+                platform2.GetWorkingDirectory())
index 410c104299cbea5298d675dd52f9a9072dc8293f..7cb07cbe55d35e8d0ec7e1ac1725204f4a5320d2 100644 (file)
@@ -25,8 +25,7 @@ class PlatformAppleSimulatorTest : public ::testing::Test {
 #ifdef __APPLE__
 
 static void testSimPlatformArchHasSimEnvironment(llvm::StringRef name) {
-  Status error;
-  auto platform_sp = Platform::Create(ConstString(name), error);
+  auto platform_sp = Platform::Create(name);
   ASSERT_TRUE(platform_sp);
   int num_arches = 0;
 
@@ -55,12 +54,12 @@ TEST_F(PlatformAppleSimulatorTest, TestHostPlatformToSim) {
   };
 
   for (auto sim : sim_platforms) {
+    PlatformList list;
     ArchSpec arch = platform_arch;
     arch.GetTriple().setOS(sim);
     arch.GetTriple().setEnvironment(llvm::Triple::Simulator);
 
-    Status error;
-    auto platform_sp = Platform::Create(arch, {}, nullptr, error);
+    auto platform_sp = list.GetOrCreate(arch, {}, nullptr);
     EXPECT_TRUE(platform_sp);
   }
 }