cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: thought on testing function in select.c

From: Julien Chaffraix <julien.chaffraix_at_gmail.com>
Date: Mon, 11 Jul 2011 21:42:21 -0700

>> have a the test to pass file descriptors to Curl_poll. run a separate
>> thread/process that will write to specified files. make sure Curl_poll
>> returned and has the correct info set.
>>
>> I do feel though that this test is a bit complex, if there are better
>> ideas please share them.
>
> They're really hard to unit test sensibly, yes. The hard part about using
> threads is that we need to detect and use a threading lib that libcurl may
> not use by itself.

Also it opens a can of worms as now your tests can easily be flakey
and / or timing depend.

> I guess an alternative approach is to simply use the functions when
> connecting to a test server using sockets, as we already have such test
> servers but that's still a pretty complicated setup for a unit test.

Usually the solution to that is to mock your objects. As we are not
using an object-oriented language, we may want to put replacement for
the standard library functions and use them instead for the unit
tests. That should enable us to get good coverage of those.

Julien
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2011-07-12