Re: [libposix-development] [PATCH] strncpy implementation and tests
Status: Pre-Alpha
Brought to you by:
hdante
From: Henrique A. <hd...@gm...> - 2009-07-04 04:21:39
|
I have reviewed the tests and the problem is that there's not enough coverage. Whenever the functions are easy to implement, a single file is enough to cover all tests we could possibly do for the function. In the case, there were missing tests for out of bounds overwriting, some border cases, like zero or one length strings, testing strncpy return value and copies of strings that are more general, like binary strings. The problem with partial tests is that they give the false sense that the code is conformant. If the function were more complicated, multiple tests could be made, so that the implementation gradually passed the tests. It's not a problem if the functions don't pass the tests. Actually, tests can be made before the functions. I've applied the patch and added those tests for a reference of a more complete coverage. Note that with the improved coverage, an out of bounds error was found: Assertion failed in file /home/hdante/código/libposix/libposix/tests/strncpy.c, function main, line 128: d[i] == r[i] So, remember to fix that bug in the strncpy implementation. I'll add an article in the wiki explaining the recommended way to write tests for libposix. 2009/7/1 Henrique Almeida <hd...@gm...>: > 2009/6/30 Tordek <ke...@gm...>: >> Henrique Almeida wrote: >>> Hello. :-) Thanks for the patch. The test file is missing (also it >>> can go in the "tests" directory, strncpy is a standard function). >> >> Heh, I was bound to miss something in my first patch :P. >> >> I'll get cracking writing tests, I guess. There's a trivial version >> of assert in the test file. >> >> (BTW, what's the proper way to send patches? Attachments ok?) > > Attachments are ok. I just need to review the coverage for the > strncpy test, then I'll merge it. I'll also write recomendations for > tests in libposix. > >> >> -- >> Guillermo O. «Tordek» Freschi. Programador, Escritor, Genio Maligno. >> http://tordek.com.ar :: http://twitter.com/tordek >> http://www.arcanopedia.com.ar - Juegos de Rol en Argentina >> >> ------------------------------------------------------------------------------ >> >> _______________________________________________ >> Libposix-development mailing list >> Lib...@li... >> https://lists.sourceforge.net/lists/listinfo/libposix-development >> >> > > > > -- > Henrique Dante de Almeida > hd...@gm... > -- Henrique Dante de Almeida hd...@gm... |