[lldb-dev] [Bug 48049] New: platform shell doesn't fail if the shell command fails

via lldb-dev lldb-dev at lists.llvm.org
Mon Nov 2 07:48:40 PST 2020


            Bug ID: 48049
           Summary: platform shell doesn't fail if the shell command fails
           Product: lldb
           Version: 11.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: All Bugs
          Assignee: lldb-dev at lists.llvm.org
          Reporter: david.spickett at linaro.org
                CC: jdevlieghere at apple.com, llvm-bugs at lists.llvm.org

In an interactive shell we get all the output you'd expect:
$ ./bin/lldb
(lldb) platform shell not_a_cmd
/bin/bash: not_a_cmd: command not found
error: command returned with status 127

But when using the API (via the test framework) the command is marked as
succeeded even though it failed on the platform:
+    def test_shell_command_failure(self):
+        """ Test that the platform shell command passes on command failures"""
+        triple = self.dbg.GetSelectedPlatform().GetTriple()
+        # TODO: windows/android like above
+        self.runCmd("platform shell definitley_not_a_command", check=False)
+        self.assertFalse(self.res.Succeeded())

FAIL: test_shell_command_failure (TestPlatformCommand.PlatformCommandTestCase)
    Test that the platform shell command passes on command failures
Traceback (most recent call last):
line 346, in wrapper
    return func(self, *args, **kwargs)
line 85, in test_shell_command_failure
AssertionError: True is not False

I can see some logic in saying it's a success because lldb successfully sent
the command text to and from the platform. Whether the command itself was
successful is the user's business. Is that intentional or just how "platform
shell" happens to act?

I initially assumed that a failed shell command would be a failed lldb command.
I couldn't find mention of this in the docs.

The one existing test using SBPlatformCommand is:
Which also checks that the command output contains the expected text.

You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-dev/attachments/20201102/13d82b04/attachment.html>

More information about the lldb-dev mailing list