Subject: Re: Proposal for unittests

Re: Proposal for unittests

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Sun, 28 Apr 2013 23:50:35 +0200 (CEST)

On Fri, 26 Apr 2013, Patrick Valsecchi wrote:

> In attachment, you'll find a small prototype of a unittest suite for c-ares.
> I didn't integrate it with the autotools stuff, since I don't know it (we
> use cmake). For the moment, it is only testing the ares_parse_txt_reply
> function.
>
> I've used the simplest C testing framework I've found (CuTest) and I've
> fixed it a bit to remove a few memory leaks that were detected by valgrind.
>
> What do you all think? Is the direction I'm taking OK with you?

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.

Is it easy to run just one of the (many) tests with gdb or valgrind?

With this framework, will be basically get/use a single source file for each
function we test?

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"

An idea at least!

-- 
  / daniel.haxx.se
Received on 2013-04-28