Experimental C unit test suite available for hacking

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Experimental C unit test suite available for hacking

Jacob Champion-2
Hi all,

Last week I had a personal hackathon since I couldn't make it out to
ApacheCon. As a result there is now a C-language unit test suite
available in branches/httpdunit (based on trunk). I've tested it with a
Windows+CMake toolchain as well as an Ubuntu+autoconf toolchain.

The suite itself is based on Check, which is a testing library I've had
some success with in the past. It's supported on a wide variety of
platforms and has a nice feature of running each test in a separate
process space, so a crash doesn't derail the entire suite. (Note: Check
is LGPL.) The build system has been augmented slightly to generate some
of the more tedious boilerplate code.

If you want to give it a try, just install Check (and, if using the
configure scripts, make sure Check is visible via pkg-config). The test
suite will then automatically be added to the default targets. Once
everything builds you just run the suite directly with

     $ ./test/httpdunit

As a Check binary, it has multiple knobs to control which tests run and
how the reporting is done, but by default it just runs all the tests and
prints TAP to stdout.

The example tests that are currently running are testing a new API for
strict Base64 decoding. Right now it's a feature without a client; I
included it here because it was a good showcase of the test suite (see
test/unit/base64.c for the test case code).

Let me know what you think!

--Jacob
Loading...