[LLVMdev] Private headers and testing

Chris Lattner clattner at apple.com
Sat Jan 3 17:23:16 PST 2009


On Jan 2, 2009, at 1:48 PM, Misha Brukman wrote:

> 2009/1/2 Chris Lattner <clattner at apple.com>
> On Jan 2, 2009, at 12:21 PM, Misha Brukman wrote:
> Do you have a specific example of a unit test that would need  
> these?  I really think these should stay private.
>
> Let's take lib/Transforms/Utils/CodeExtractor.cpp .  The public  
> interface for it is in include/llvm/Transform/Utils/FunctionUtils.h,  
> with only the high-level API.
>
> If I want to test some corner-case (consider the number of code  
> paths in that code), I have to strain to come up with some  
> combination of a Function and input BasicBlocks that will fit all  
> the conditions from the outset.  Or, I can just feed each individual  
> method in the class exactly the corner cases I will want it to  
> handle, and verify its output (or side effects) exactly, to make  
> sure I pin-pointed the issue.

Sure, ok.  But that is a public API, I'm specifically interested in  
cases you need private API.

> Or, let's say I want to write some tests for the LLParser -- the  
> only public API is "ParseAssemblyString", I can't unittest each  
> individual method.  The unittest for this using the public API will  
> be very brittle as it would have to check the contents of the  
> returned error message, instead of calling each Parse*() function  
> directly and analyzing its output.

The code is structured so that it is trivially easy to construct  
testcases for anything you're concerned with.  If you give me an  
example, I'll give you a testcase (in .ll form).  I don't see the need  
for unittests for LLParser.

-Chris
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20090103/34ab5a6f/attachment.html>


More information about the llvm-dev mailing list