[LLVMdev] [Patch] Adding unit tests to LLVM

Mark Kromis greybird at mac.com
Sat Dec 27 18:56:44 PST 2008


On Dec 27, 2008, at 7:41 PM, Misha Brukman wrote:

> 2008/12/27 Mark Kromis <greybird at mac.com>
> Just a curiosity question, why push for gtest vs Boost Test or a  
> different test suite?
> I normally use Boost, and their test suite, so I'm more familiar  
> with that. So I was wondering is one better then the other, or is it  
> just that someone makes a patch for it?
>
> I looked more into Boost.Test to see what's in it.  Boost.Test  
> doesn't seem to be stand-alone -- I don't see a way to use  
> Boost.Test without importing some other chunks of Boost that the  
> testing library depends on.  While Boost is a fine set of libraries,  
> I don't think we want to increase the LLVM distribution by  
> sizeof(Boost) just to enable unittesting, nor do we want to spend  
> the time on maintaining a subset of Boost that's "just enough" to  
> build and use the unittest library, along a modified configure/build  
> process that Boost wants to use (Boost.Build? Boost.Jam?).

So are you planning on maintaining whatever test system, or just have  
them as a pre-requisite. For example are you going to have the gtest  
incorporated, or have them install it separately first? I was under  
the impression that the user would have to install gtest first.

>
> Boost also seems to want to use exceptions, and LLVM does not want  
> to.  I'm not sure if there would be some difficulties in running a  
> build where some libraries are compiled with no exceptions, some  
> with, and the results are linked together.  At the best case, it  
> would complicate our build system to be able to support different  
> set of flags for building LLVM libraries vs. Boost.Test (and the  
> rest of Boost that we import).

http://www.boost.org/doc/libs/1_37_0/libs/utility/throw_exception.html
#define BOOST_NO_EXCEPTIONS

>
> Sample usage of Boost.Test: http://svn.boost.org/svn/boost/trunk/libs/test/example/unit_test_example_12.cpp
> Note the code at the end setting up the test suite -- this is  
> boilerplate code that I think shouldn't be necessary to setup and  
> run tests.
>


http://svn.boost.org/svn/boost/trunk/libs/test/example/unit_test_example_01.cpp
My test cases are not that in-depth, I'm much closer to sample 1. I  
haven't found a reason to go that crazy yet.


> Google Test, on the other hand, has no external dependencies, and is  
> distributed as a dozen of .h/.cc files; supports Makefile, SCons,  
> and Xcode; and doesn't use exceptions or RTTI.
>

Gtest is much more lightweight, no comparison there. I know that llvm  
is not very good with exceptions, but should a test case system  
support that?


> Sample usage of GTest: http://code.google.com/p/googletest/source/browse/trunk/samples/sample5_unittest.cc
> GTest-specific LOC besides the #include statement: 0.

I think it links to a library as well.

> Note that I'm not counting main() for either Boost or GTest, because  
> both provide a standard main() for use with almost all test files.
>
> Misha
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev

Also for a note of reference, your links to the examples are the most  
advanced samples. So boost can do more, thus has more weight/bloat  
behind it.

Were the other test kits looked at? Is gtest the best solution for the  
project.

Is this something your planning as putting in the tree, thus require  
pulling in changes from google (license allowing), or does user need  
to have the libraries/headers pre-installed?

My question was not to cause a battle, but I wanted to be sure we were  
using the right test kit, and not just picking one just because.  For  
example gtest is very light weight test kit, that can do the job, but  
will the tests outgrow what the test kit can do, and cause a  
conversion to a more advanced one later?

Regards,
Mark Kromis
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20081227/398a6713/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PGP.sig
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20081227/398a6713/attachment.sig>


More information about the llvm-dev mailing list