brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.2 KiB · e23ef8c Raw
54 lines · python
1"""Test the SBPlatform APIs."""2 3from lldbsuite.test.decorators import *4from lldbsuite.test.lldbtest import *5 6 7class SBPlatformAPICase(TestBase):8    NO_DEBUG_INFO_TESTCASE = True9 10    @skipIfRemote  # Remote environment not supported.11    def test_run(self):12        self.build()13        plat = lldb.SBPlatform.GetHostPlatform()14 15        os.environ["MY_TEST_ENV_VAR"] = "SBPlatformAPICase.test_run"16 17        def cleanup():18            del os.environ["MY_TEST_ENV_VAR"]19 20        self.addTearDownHook(cleanup)21        cmd = lldb.SBPlatformShellCommand(self.getBuildArtifact("a.out"))22        self.assertSuccess(plat.Run(cmd))23        self.assertIn("MY_TEST_ENV_VAR=SBPlatformAPICase.test_run", cmd.GetOutput())24 25    def test_SetSDKRoot(self):26        plat = lldb.SBPlatform("remote-linux")  # arbitrary choice27        self.assertTrue(plat)28        plat.SetSDKRoot(self.getBuildDir())29        self.dbg.SetSelectedPlatform(plat)30        self.expect("platform status", substrs=["Sysroot:", self.getBuildDir()])31 32    def test_SetCurrentPlatform_floating(self):33        # floating platforms cannot be referenced by name until they are34        # associated with a debugger35        floating_platform = lldb.SBPlatform("remote-netbsd")36        floating_platform.SetWorkingDirectory(self.getBuildDir())37        self.assertSuccess(self.dbg.SetCurrentPlatform("remote-netbsd"))38        dbg_platform = self.dbg.GetSelectedPlatform()39        self.assertEqual(dbg_platform.GetName(), "remote-netbsd")40        self.assertIsNone(dbg_platform.GetWorkingDirectory())41 42    def test_SetCurrentPlatform_associated(self):43        # associated platforms are found by name-based lookup44        floating_platform = lldb.SBPlatform("remote-netbsd")45        floating_platform.SetWorkingDirectory(self.getBuildDir())46        orig_platform = self.dbg.GetSelectedPlatform()47 48        self.dbg.SetSelectedPlatform(floating_platform)49        self.dbg.SetSelectedPlatform(orig_platform)50        self.assertSuccess(self.dbg.SetCurrentPlatform("remote-netbsd"))51        dbg_platform = self.dbg.GetSelectedPlatform()52        self.assertEqual(dbg_platform.GetName(), "remote-netbsd")53        self.assertEqual(dbg_platform.GetWorkingDirectory(), self.getBuildDir())54