diff options
author | Raphael Isemann <teemperor@gmail.com> | 2019-09-01 09:12:37 +0000 |
---|---|---|
committer | Raphael Isemann <teemperor@gmail.com> | 2019-09-01 09:12:37 +0000 |
commit | 29872606d220420d53fde7cc5e3bea15f8da62e7 (patch) | |
tree | 47d7a82ccea48a6dd10a2d8ecb6b3c3127724131 /lldb/packages/Python/lldbsuite/test/commands/platform | |
parent | adfdcb9c2652aeee585b9005fd6c67be06af8ea9 (diff) | |
download | bcm5719-llvm-29872606d220420d53fde7cc5e3bea15f8da62e7.tar.gz bcm5719-llvm-29872606d220420d53fde7cc5e3bea15f8da62e7.zip |
[lldb] Restructure test folders to match LLDB command hierarchy
Summary:
As discussed on lldb-dev, this patch moves some LLDB tests into a hierarchy that more closely
resembles the commands we use in the LLDB interpreter. This patch should only move tests
that use the command interpreter and shouldn't touch any tests that primarily test the SB API.
Reviewers: #lldb, jfb, JDevlieghere
Reviewed By: #lldb, JDevlieghere
Subscribers: dexonsmith, arphaman, JDevlieghere, lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D67033
llvm-svn: 370605
Diffstat (limited to 'lldb/packages/Python/lldbsuite/test/commands/platform')
-rw-r--r-- | lldb/packages/Python/lldbsuite/test/commands/platform/basic/TestPlatformCommand.py | 80 | ||||
-rw-r--r-- | lldb/packages/Python/lldbsuite/test/commands/platform/basic/TestPlatformPython.py | 82 |
2 files changed, 162 insertions, 0 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/commands/platform/basic/TestPlatformCommand.py b/lldb/packages/Python/lldbsuite/test/commands/platform/basic/TestPlatformCommand.py new file mode 100644 index 00000000000..2e1deefe90e --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/commands/platform/basic/TestPlatformCommand.py @@ -0,0 +1,80 @@ +""" +Test some lldb platform commands. +""" + +from __future__ import print_function + + +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + + +class PlatformCommandTestCase(TestBase): + + mydir = TestBase.compute_mydir(__file__) + + @no_debug_info_test + def test_help_platform(self): + self.runCmd("help platform") + + @no_debug_info_test + def test_list(self): + self.expect("platform list", + patterns=['^Available platforms:']) + + @no_debug_info_test + def test_process_list(self): + self.expect("platform process list", + substrs=['PID', 'TRIPLE', 'NAME']) + + @no_debug_info_test + def test_process_info_with_no_arg(self): + """This is expected to fail and to return a proper error message.""" + self.expect("platform process info", error=True, + substrs=['one or more process id(s) must be specified']) + + @no_debug_info_test + def test_status(self): + self.expect( + "platform status", + substrs=[ + 'Platform', + 'Triple', + 'OS Version', + 'Kernel', + 'Hostname']) + + @expectedFailureAll(oslist=["windows"]) + @no_debug_info_test + def test_shell(self): + """ Test that the platform shell command can invoke ls. """ + triple = self.dbg.GetSelectedPlatform().GetTriple() + if re.match(".*-.*-windows", triple): + self.expect( + "platform shell dir c:\\", substrs=[ + "Windows", "Program Files"]) + elif re.match(".*-.*-.*-android", triple): + self.expect( + "platform shell ls /", + substrs=[ + "cache", + "dev", + "system"]) + else: + self.expect("platform shell ls /", substrs=["dev", "tmp", "usr"]) + + @no_debug_info_test + def test_shell_builtin(self): + """ Test a shell built-in command (echo) """ + self.expect("platform shell echo hello lldb", + substrs=["hello lldb"]) + + # FIXME: re-enable once platform shell -t can specify the desired timeout + @no_debug_info_test + def test_shell_timeout(self): + """ Test a shell built-in command (sleep) that times out """ + self.skipTest("due to taking too long to complete.") + self.expect("platform shell sleep 15", error=True, substrs=[ + "error: timed out waiting for shell command to complete"]) diff --git a/lldb/packages/Python/lldbsuite/test/commands/platform/basic/TestPlatformPython.py b/lldb/packages/Python/lldbsuite/test/commands/platform/basic/TestPlatformPython.py new file mode 100644 index 00000000000..f105847d0bb --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/commands/platform/basic/TestPlatformPython.py @@ -0,0 +1,82 @@ +""" +Test the lldb platform Python API. +""" + +from __future__ import print_function + + +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + + +class PlatformPythonTestCase(TestBase): + + mydir = TestBase.compute_mydir(__file__) + + @add_test_categories(['pyapi']) + @no_debug_info_test + def test_platform_list(self): + """Test SBDebugger::GetNumPlatforms() & GetPlatformAtIndex() API""" + # Verify the host platform is present by default. + initial_num_platforms = self.dbg.GetNumPlatforms() + self.assertGreater(initial_num_platforms, 0) + host_platform = self.dbg.GetPlatformAtIndex(0) + self.assertTrue(host_platform.IsValid() and + host_platform.GetName() == 'host', + 'The host platform is present') + # Select another platform and verify that the platform is added to + # the platform list. + platform_idx = self.dbg.GetNumAvailablePlatforms() - 1 + if platform_idx < 1: + self.fail('No platforms other than host are available') + platform_data = self.dbg.GetAvailablePlatformInfoAtIndex(platform_idx) + platform_name = platform_data.GetValueForKey('name').GetStringValue(100) + self.assertNotEqual(platform_name, 'host') + self.dbg.SetCurrentPlatform(platform_name) + selected_platform = self.dbg.GetSelectedPlatform() + self.assertTrue(selected_platform.IsValid()) + self.assertEqual(selected_platform.GetName(), platform_name) + self.assertEqual(self.dbg.GetNumPlatforms(), initial_num_platforms + 1) + platform_found = False + for platform_idx in range(self.dbg.GetNumPlatforms()): + platform = self.dbg.GetPlatformAtIndex(platform_idx) + if platform.GetName() == platform_name: + platform_found = True + break + self.assertTrue(platform_found) + + @add_test_categories(['pyapi']) + @no_debug_info_test + def test_host_is_connected(self): + # We've already tested that this one IS the host platform. + host_platform = self.dbg.GetPlatformAtIndex(0) + self.assertTrue(host_platform.IsConnected(), "The host platform is always connected") + + + @add_test_categories(['pyapi']) + @no_debug_info_test + def test_available_platform_list(self): + """Test SBDebugger::GetNumAvailablePlatforms() and GetAvailablePlatformInfoAtIndex() API""" + num_platforms = self.dbg.GetNumAvailablePlatforms() + self.assertGreater( + num_platforms, 0, + 'There should be at least one platform available') + + for i in range(num_platforms): + platform_data = self.dbg.GetAvailablePlatformInfoAtIndex(i) + name_data = platform_data.GetValueForKey('name') + desc_data = platform_data.GetValueForKey('description') + self.assertTrue( + name_data and name_data.IsValid(), + 'Platform has a name') + self.assertEqual( + name_data.GetType(), lldb.eStructuredDataTypeString, + 'Platform name is a string') + self.assertTrue( + desc_data and desc_data.IsValid(), + 'Platform has a description') + self.assertEqual( + desc_data.GetType(), lldb.eStructuredDataTypeString, + 'Platform description is a string') |