<div dir="ltr">Not at this point. I went for proof of concept first, and since I primarily develop on MacOSX/Xcode and rsync/remote build to Linux & FreeBSD, starting with cmake would have prevented me from working in my primary environment.<div><br></div><div>I'm all for making it robust now that I've proven out the workflow. Please have at it if you want to get it working with cmake - I think that's totally valid. And with Dawn doing some work on getting cmake building better on MacOSX (my my team interested in it as well for matrix testing), I think that'd be a great improvement.</div><div><br></div><div>At the very least, the existing Makefile-based system has to be extended to be smarter about figuring out where llvm source, llvm build directories and lldb source is located, and once we need to include the whole shebang of lldb in with it, it'll need to become a bit smarter for that as well.</div><div><br></div><div>Net: have at it and make it better if you see ways to do so. We're definitely going to want to hook it into our Linux build, which will mean cmake as a preference.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Oct 2, 2014 at 10:50 PM, Zachary Turner <span dir="ltr"><<a href="mailto:zturner@google.com" target="_blank">zturner@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Does CMake build it?</div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Oct 2, 2014 at 9:27 PM, Todd Fiala <span dir="ltr"><<a href="mailto:tfiala@google.com" target="_blank">tfiala@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hey Sean!<div><br></div><div>Yeah I've got a gtest subproject in lldb now. It's not wired into any main test process (i.e. check-lldb or test targets don't run it, but if you run the "gtest" project in the lldb workspace in Xcode, or go to the gtest dir and run "do-gtest.py", you'll get it running).</div><div><br></div><div>I've got it rigged up to put Xcode error markers at the point in gtests that fail at the failing assertion point after doing some output munging to make it work.</div><div><br></div><div>The actual gtest build/runner works on MacOSX and Linux. It *should* work on all platforms since I'm actually using the llvm-embedded gtest framework, so technically if llvm builds, so should the gtest setup.</div><div><br></div><div>However, I do some weak (and need to be improved) inference of directory structure/build structure to find some necessary files in the gtest/make/Makefile.rules. They can be overridden by environment or make variable settings, but they're definitely not going to work for everyone and there are probably more robust methods for figuring out certain directory locations.</div><div><br></div><div>I run it fine on MacOSX with the canonical Xcode directory layout and using the Xcode Preferences | Locations set to put project output in a project-relative DerivedData directory.</div><div><br></div><div>On Linux, I assume the build directory is a sibling directory to a llvm, llvm/tools/clang, llvm/tools/lldb directory structure and (here's the not-reasonable-default) I assume the build directory is called build-debug. (So, I have a build-drectory alongside the top-level llvm directory). Again, all these can be overridden by environment variable/make variable settings, and I think I have the Makefile emit an error if it can't resolve the directories it uses and tells what variable to override to fix it. But, likely it needs some love.</div><div><br></div><div>For me, the source/Plugins/Process/Linux/ThreadStateCoordinator.{h/cpp} was my guinea pig. I'm using that to replace some guts in the llgs signal state transition logic that requires putting threads through some ptrace state magic before it should tell lldb about some thread stops. And so I'm testing that all the deferred callbacks (i.e. essentially GCD-like constructs) fire off in the right circumstances. That's an example of a small piece of code in C++ that I just need to know is working right and so I introduced the gtest framework around it.</div><div><br></div><div>Hope that gets you started! Feel free to improve and/or offer suggestions.</div><div><br></div><div>For now, we had settled on using gtest/unittest as the root of 1-1 correspondence directory structure mirroring for testing single classes.</div><div><br></div><div>If we want to do collaboration tests (integration tests, etc.), we're probably into the "should be in python category", but we might have a few low-level multi-class testing scenarios where we might want a different gtest/functional, gtest/integration or something similar directory structure to handle those. Would be good to have discussion around that if we find a valid use for it.</div><span><font color="#888888"><div><br></div><div>-Todd</div></font></span></div><div><div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Oct 2, 2014 at 7:02 PM, Sean Callanan <span dir="ltr"><<a href="mailto:scallanan@apple.com" target="_blank">scallanan@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">Waaaaitasecond, I’m seeing the gtest subproject…<div>it’s a bit embarrassing that I haven’t checked out top of tree in so long!</div><div>I’m going to take a look around. Still interested in collaborating on this.</div><span><font color="#888888"><div><br></div><div>Sean</div></font></span><div><div><div><br><div><blockquote type="cite"><div>On Oct 2, 2014, at 6:11 PM, Zachary Turner <<a href="mailto:zturner@google.com" target="_blank">zturner@google.com</a>> wrote:</div><br><div><div dir="ltr">I gave it a brief look, but I didn't get it working. Clang and LLD both already do this, so I figured it would be as simple as copying their CMake for the gtest stuff and fixing it up with LLDB paths. Unfortunately, I was getting tons of linker errors, and I'm not really sure why, as there didn't appear to be much magic there. I didn't investigate it further after that, but it would definitely be a good thing to tackle.</div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Oct 2, 2014 at 2:01 PM, Sean Callanan <span dir="ltr"><<a href="mailto:scallanan@apple.com" target="_blank">scallanan@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div>At risk of being burnt at the stake for practicing the the necromantic arts:</div><div>Jim’s point that internal APIs are somewhat fragile is well taken, and I don’t think there’s much value in using internal tests as “more convenient” substitutes for external tests.</div><div><br></div><div>That said, I think internal unit tests add several benefits that improve code:</div><div><br></div><div><ul><li><i>Modular design</i>. If clients of an internal object have to do a lot of extra work to make the object work properly, this may indicate a design issue.</li><li><i>State encapsulation</i>. If an object changes behaviors depending on outside state, then that makes it much harder to use.</li><li><i>Code readability</i>. Test cases can demonstrate how an object is intended to be used, and act as compelling witnesses that that use case works.</li></ul><div><br></div></div><div>I would be interested in using the expression parser as a guinea pig to introduce test-driven methods.</div><div>Todd/Zach, did you ever get a gtest-based unit test system working?</div><span><font color="#888888"><div><br></div><div>Sean</div></font></span><div><div><br><div><blockquote type="cite"><div>On Jul 18, 2014, at 6:14 PM, Zachary Turner <<a href="mailto:zturner@google.com" target="_blank">zturner@google.com</a>> wrote:</div><br><div><div dir="ltr">FWIW I'm kind of in favor of bringing in gtest with limited use. When I first started digging into LLDB, probably the first 3-4 bugs I fixed were all in IRMemoryMap, and they would all have been caught if the class were unit tested properly. </div>
<div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Jul 18, 2014 at 4:03 PM, Greg Clayton <span dir="ltr"><<a href="mailto:gclayton@apple.com" target="_blank">gclayton@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
We could expose a new static function in SBDebugger:<br>
<br>
class SBDebugger {<br>
<br>
static void<br>
UnitTest (const char *args);<br>
<br>
};<br>
<br>
Then internally it can parse any arguments and run tests as needed? Each class that wants to register unit tests with the debugger during SBDebugger::Initialize() which must be called prior to doing anything with the LLDB API:<br>
<br>
<br>
SBDebugger::Initialize()<br>
{<br>
Debugger::Intialize();<br>
}<br>
<br>
Debugger::Initialize()<br>
{<br>
....<br>
NamedPipe:: Initialize();<br>
}<br>
<br>
<br>
Then in the static NamedPipe::Initiazize() you could register your unit tests:<br>
<br>
void<br>
NamedPipe::Initialiaze()<br>
{<br>
Debugger::RegisterUnitTest(NamedPipe::InitTest1, "NamedPipe::InitTest1"));<br>
}<br>
<br>
<br>
Then you could just run:<br>
<br>
SBDebugger::Initialize();<br>
SBDebugger::UnitTest(NULL); // Run all tests<br>
<br>
Or run individual ones:<br>
<br>
SBDebugger::Initialize();<br>
SBDebugger::UnitTest("--test NamedPipe::InitTest1"); // Run just "NamedPipe::InitTest1"<br>
<br>
Of course then the LLDB test suite could run these unit tests first to make sure everything is good.<br>
<div><div><br>
<br>
<br>
> On Jul 16, 2014, at 3:59 PM, Zachary Turner <<a href="mailto:zturner@google.com" target="_blank">zturner@google.com</a>> wrote:<br>
><br>
> If it makes you feel any better LLVM is leery of it too, and it's only used, as you said, in specialized circumstances. It's especially useful for testing abstract data types, where you just want to test the interface to a self-contained, reusable class.<br>
><br>
><br>
> On Wed, Jul 16, 2014 at 2:25 PM, <<a href="mailto:jingham@apple.com" target="_blank">jingham@apple.com</a>> wrote:<br>
> I'm a little leery about this. We don't test at the lldb_private layer because those tests are likely to be fragile and easily broken. For utility classes like NamedPipe I guess I don't so much mind, but I'm not sure its a great idea to do this more generally.<br>
><br>
> Jim<br>
><br>
> > On Jul 16, 2014, at 9:40 AM, Todd Fiala <<a href="mailto:tfiala@google.com" target="_blank">tfiala@google.com</a>> wrote:<br>
> ><br>
> > Hey guys,<br>
> ><br>
> > Sometimes I have smaller bits of code I'd like to test in LLDB as I'm developing them (i.e. TDD-style) that are C++ and won't be exposed directly via Python. I'm not sure I've seen any facilities in the LLDB tests for adding such tests. Essentially I'd want to do something like a gtest or cppunit test.<br>
> ><br>
> > Do we have any mechanism for doing that currently? If we do, what is it? If we don't, how about adding some mechanism to do it after we figure out how we'd like to approach it? Or, if you have thoughts on a good, simple way to do it from Python that doesn't require extra Python bindings just to do it, that'd be fine by me as well.<br>
> ><br>
> > If we want to take a concrete example, here is one: I'm adding a NamedPipe class under the host dir. I'd like to make some simple tests for it, and test it under Linux, Windows and MacOSX. In the case of Windows, it would be the only real way for me to test that it's behaving exactly as I want at this point. This isn't the only time I've wanted C++-level tests at a fairly fine granularity, but it's a good example of it.<br>
> ><br>
> > Any thoughts?<br>
> > --<br>
> > Todd Fiala | Software Engineer | <a href="mailto:tfiala@google.com" target="_blank">tfiala@google.com</a> | <a href="tel:650-943-3180" value="+16509433180" target="_blank">650-943-3180</a><br>
> ><br>
> > _______________________________________________<br>
> > lldb-dev mailing list<br>
> > <a href="mailto:lldb-dev@cs.uiuc.edu" target="_blank">lldb-dev@cs.uiuc.edu</a><br>
> > <a href="http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev</a><br>
><br>
> _______________________________________________<br>
> lldb-dev mailing list<br>
> <a href="mailto:lldb-dev@cs.uiuc.edu" target="_blank">lldb-dev@cs.uiuc.edu</a><br>
> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev</a><br>
><br>
> _______________________________________________<br>
> lldb-dev mailing list<br>
> <a href="mailto:lldb-dev@cs.uiuc.edu" target="_blank">lldb-dev@cs.uiuc.edu</a><br>
> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev</a><br>
<br>
</div></div></blockquote></div><br></div>
_______________________________________________<br>lldb-dev mailing list<br><a href="mailto:lldb-dev@cs.uiuc.edu" target="_blank">lldb-dev@cs.uiuc.edu</a><br><a href="http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev</a><br></div></blockquote></div><br></div></div></div></blockquote></div><br></div>
</div></blockquote></div><br></div></div></div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div dir="ltr"><table cellspacing="0" cellpadding="0" style="color:rgb(136,136,136);font-family:'Times New Roman'"><tbody><tr style="color:rgb(85,85,85);font-family:sans-serif;font-size:small"><td nowrap style="border-top-style:solid;border-top-color:rgb(213,15,37);border-top-width:2px">Todd Fiala |</td><td nowrap style="border-top-style:solid;border-top-color:rgb(51,105,232);border-top-width:2px"> Software Engineer |</td><td nowrap style="border-top-style:solid;border-top-color:rgb(0,153,57);border-top-width:2px"> <a href="mailto:tfiala@google.com" style="color:rgb(17,85,204)" target="_blank"><span style="background-color:rgb(255,255,204);color:rgb(34,34,34);background-repeat:initial initial">tfiala@google.com</span></a></td><td nowrap style="border-top-style:solid;border-top-color:rgb(238,178,17);border-top-width:2px"><br></td></tr></tbody></table><br></div>
</div>
</div></div></blockquote></div><br></div>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div dir="ltr"><table cellspacing="0" cellpadding="0" style="color:rgb(136,136,136);font-family:'Times New Roman'"><tbody><tr style="color:rgb(85,85,85);font-family:sans-serif;font-size:small"><td nowrap style="border-top-style:solid;border-top-color:rgb(213,15,37);border-top-width:2px">Todd Fiala |</td><td nowrap style="border-top-style:solid;border-top-color:rgb(51,105,232);border-top-width:2px"> Software Engineer |</td><td nowrap style="border-top-style:solid;border-top-color:rgb(0,153,57);border-top-width:2px"> <a href="mailto:tfiala@google.com" style="color:rgb(17,85,204)" target="_blank"><span style="background-color:rgb(255,255,204);color:rgb(34,34,34);background-repeat:initial initial">tfiala@google.com</span></a></td><td nowrap style="border-top-style:solid;border-top-color:rgb(238,178,17);border-top-width:2px"><br></td></tr></tbody></table><br></div>
</div>