[Lldb-commits] [lldb] r369506 - [lldb][NFC] Add tests for invalid command invocations

Raphael Isemann via lldb-commits lldb-commits at lists.llvm.org
Wed Aug 21 02:15:44 PDT 2019


Author: teemperor
Date: Wed Aug 21 02:15:44 2019
New Revision: 369506

URL: http://llvm.org/viewvc/llvm-project?rev=369506&view=rev
Log:
[lldb][NFC] Add tests for invalid command invocations

Added:
    lldb/trunk/packages/Python/lldbsuite/test/functionalities/apropos/
    lldb/trunk/packages/Python/lldbsuite/test/functionalities/apropos/TestApropos.py
    lldb/trunk/packages/Python/lldbsuite/test/functionalities/reproducer/TestReproducer.py
    lldb/trunk/packages/Python/lldbsuite/test/functionalities/version/
    lldb/trunk/packages/Python/lldbsuite/test/functionalities/version/TestVersion.py
Modified:
    lldb/trunk/packages/Python/lldbsuite/test/functionalities/completion/TestCompletion.py
    lldb/trunk/packages/Python/lldbsuite/test/functionalities/plugins/commands/TestPluginCommands.py
    lldb/trunk/packages/Python/lldbsuite/test/help/TestHelp.py

Added: lldb/trunk/packages/Python/lldbsuite/test/functionalities/apropos/TestApropos.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/apropos/TestApropos.py?rev=369506&view=auto
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/apropos/TestApropos.py (added)
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/apropos/TestApropos.py Wed Aug 21 02:15:44 2019
@@ -0,0 +1,19 @@
+import lldb
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test.decorators import *
+
+class AproposTestCase(TestBase):
+
+    mydir = TestBase.compute_mydir(__file__)
+
+    def setUp(self):
+        TestBase.setUp(self)
+
+    @no_debug_info_test
+    def test_apropos(self):
+        self.expect("apropos", error=True,
+                    substrs=[' must be called with exactly one argument'])
+        self.expect("apropos a b", error=True,
+                    substrs=[' must be called with exactly one argument'])
+        self.expect("apropos ''", error=True,
+                    substrs=['\'\' is not a valid search word'])

Modified: lldb/trunk/packages/Python/lldbsuite/test/functionalities/completion/TestCompletion.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/completion/TestCompletion.py?rev=369506&r1=369505&r2=369506&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/completion/TestCompletion.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/completion/TestCompletion.py Wed Aug 21 02:15:44 2019
@@ -91,6 +91,10 @@ class CommandLineCompletionTestCase(Test
                                'arm64'])
 
     @skipIfFreeBSD  # timing out on the FreeBSD buildbot
+    def test_plugin_load(self):
+        self.complete_from_to('plugin load ', [])
+
+    @skipIfFreeBSD  # timing out on the FreeBSD buildbot
     def test_quoted_command(self):
         self.complete_from_to('"set',
                               ['"settings" '])

Modified: lldb/trunk/packages/Python/lldbsuite/test/functionalities/plugins/commands/TestPluginCommands.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/plugins/commands/TestPluginCommands.py?rev=369506&r1=369505&r2=369506&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/plugins/commands/TestPluginCommands.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/plugins/commands/TestPluginCommands.py Wed Aug 21 02:15:44 2019
@@ -64,3 +64,15 @@ class PluginCommandTestCase(TestBase):
             print(retobj.GetOutput())
 
         self.expect(retobj, substrs=['abc def ghi'], exe=False)
+
+    @no_debug_info_test
+    def test_invalid_plugin_invocation(self):
+        self.expect("plugin load a b",
+                    error=True, startstr="error: 'plugin load' requires one argument")
+        self.expect("plugin load",
+                    error=True, startstr="error: 'plugin load' requires one argument")
+
+    @no_debug_info_test
+    def test_invalid_plugin_target(self):
+        self.expect("plugin load ThisIsNotAValidPluginName",
+                    error=True, startstr="error: no such file")

Added: lldb/trunk/packages/Python/lldbsuite/test/functionalities/reproducer/TestReproducer.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/reproducer/TestReproducer.py?rev=369506&view=auto
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/reproducer/TestReproducer.py (added)
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/reproducer/TestReproducer.py Wed Aug 21 02:15:44 2019
@@ -0,0 +1,20 @@
+import lldb
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test.decorators import *
+
+class ReproducerTestCase(TestBase):
+
+    mydir = TestBase.compute_mydir(__file__)
+
+    def setUp(self):
+        TestBase.setUp(self)
+
+    @no_debug_info_test
+    def test_reproducer_generate_invalid_invocation(self):
+        self.expect("reproducer generate f", error=True,
+                    substrs=["'reproducer generate' takes no arguments"])
+
+    @no_debug_info_test
+    def test_reproducer_status_invalid_invocation(self):
+        self.expect("reproducer status f", error=True,
+                    substrs=["'reproducer status' takes no arguments"])

Added: lldb/trunk/packages/Python/lldbsuite/test/functionalities/version/TestVersion.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/version/TestVersion.py?rev=369506&view=auto
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/version/TestVersion.py (added)
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/version/TestVersion.py Wed Aug 21 02:15:44 2019
@@ -0,0 +1,22 @@
+import lldb
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test.decorators import *
+
+class VersionTestCase(TestBase):
+
+    mydir = TestBase.compute_mydir(__file__)
+
+    def setUp(self):
+        TestBase.setUp(self)
+
+    @no_debug_info_test
+    def test_version(self):
+        # Should work even when people patch the output,
+        # so let's just assume that every vendor at least mentions
+        # 'lldb' in their version string.
+        self.expect("version", substrs=['lldb'])
+
+    @no_debug_info_test
+    def test_version_invalid_invocation(self):
+        self.expect("version a", error=True,
+                    substrs=['the version command takes no arguments.'])

Modified: lldb/trunk/packages/Python/lldbsuite/test/help/TestHelp.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/help/TestHelp.py?rev=369506&r1=369505&r2=369506&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/help/TestHelp.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/help/TestHelp.py Wed Aug 21 02:15:44 2019
@@ -240,6 +240,22 @@ class HelpCommandTestCase(TestBase):
                     substrs=["'alongaliasna' is an abbreviation for 'help'"])
 
     @no_debug_info_test
+    def test_hidden_help(self):
+        self.expect("help -h",
+                    substrs=["_regexp-bt"])
+
+    @no_debug_info_test
+    def test_help_ambiguous(self):
+        self.expect("help g",
+                    substrs=["Help requested with ambiguous command name, possible completions:",
+                             "gdb-remote", "gui"])
+
+    @no_debug_info_test
+    def test_help_unknown_flag(self):
+        self.expect("help -z", error=True,
+                    substrs=["unknown or ambiguous option"])
+
+    @no_debug_info_test
     def test_help_format_output(self):
         """Test that help output reaches TerminalWidth."""
         self.runCmd(




More information about the lldb-commits mailing list