[lldb-dev] pexpect and getting tests working on Windows

Zachary Turner zturner at google.com
Wed Jul 9 16:11:31 PDT 2014


On Wed, Jul 9, 2014 at 3:18 PM, <jingham at apple.com> wrote:

> Generally lldb commands can be synchronous or not depending on context.
>  For instance if I attach to a program, then "continue" will return control
> to the user as soon as the process continues and won't wait till it stops.
>  But I don't think many tests use this feature.
>
> Anyway, that's not the real issue.  The times that the testsuite is
> actually using pexpect, it isn't directly "running a command" in a way that
> you could know when it is done.  Rather, it just funnels some text at an
> externally spawned lldb, and reads output till it see the "stop condition"
> which in our case is generally the prompt.  That tells you you're done.
>  Then you take the text before the prompt, and that's what you compare to.
>  That's a very simple use of expect, but that's pretty much all we do.
>  Anyway, so "wait till you see the stop condition" and all that that
> entails is what expect is doing for you.
>

> OTOH, by my (admittedly quick) reading, the lldb test suite doesn't use
> pexpect very much at all.  For instance, lldbtest.runCmd and
> lldbtest.expect don't actually use pexpect, they just run a command with
> SBCommandInterpreter::HandleCommand and grab output from the command result
> object.  The benchmarks tests do use pexpect and just a few others.  You
> could probably switch around the "import pexpect" statements in the main
> lldbtest.py if you are on windows, and then skip the few tests that
> actually import it, and you'd be losing only 7 or 8 tests.
>

Yes, something like this is exactly what I had in mind in regards to how I
thought many tests could be written (SBCommandInterpreter.HandleCommand and
grab the result object).  It's good to know that this is already a
supported way of writing tests.  I see at least a few places where pexpect
is currently used when it appears SBCommandInterpreter.HandleCommand would
suffice.  So perhaps some of these could even be converted.  I'm still
working through a few other issues regarding getting script integration
working on Windows, but hopefully I'll figure it out soon enough.  Thanks!

Zach
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-dev/attachments/20140709/7f5c6634/attachment.html>


More information about the lldb-dev mailing list