Subject: Re: Proposal for unittests

Re: Proposal for unittests

From: Patrick Valsecchi <pvalsecc_at_cisco.com>
Date: Mon, 29 Apr 2013 08:13:38 +0200

On 04/28/2013 11:50 PM, Daniel Stenberg wrote:
> I think it is a fine direction indeed! I've never used 'CuTest' myself
> before and I've noticed that there's no package in Debian for it and
> it makes me a little concerned.
>

I've never used it myself either. I'm more a C++ guy...

No need of external dependency. That's the beauty of the thing. You just
drop 3 files in the test directory (AllTests.c, CuTest.c, CuTest.h) and
you're all set.

I don't think a test framework needs to be fancy. It must just avoid
being in the way. That is the simplest I've found.

> Is it easy to run just one of the (many) tests with gdb or valgrind?
So far it can only run all the tests at once, but it would be easy to
change the main to accept a test name as parameter, I guess. I'll give
it a try.

>
> With this framework, will be basically get/use a single source file
> for each function we test?
>
It's the direction I've taken, but it is not mandatory. The structure of
tests is flat. There is no hierarchy.

> Another little thing I would like, which is a bit indepdent from which
> framework we use, is making generic DNS-fields avaiable as defines so
> that we can define new test cases with incoming DNS frames easier and
> make them more readable in the test case source code.
>
> Several of your UDP frames in parse_txt_suite.c for example start with
>
> "accf85800001"
> "0001000100020566697273740d5f6d65"
> "6469616e65742d6e6d73045f74637007"
> "6578616d706c6503636f6d0000100001"
> "c00c0010000100000e10"
>

Yes, all my TXT tests are based on the same DNS packet. Each test has a
slightly modified packet to test different error cases. The first test
only has the original packet which I've split logically and documented a
bit the relevant parts. I prefered to copy it in each test and modified
them directly inline instead of starting from the same pristine copy
each time and modify it with stuff like udp_packet[34]=0xFF. I think
it's easier to understand what is modified my way.
Received on 2013-04-29