Re: [libposix-development] [PATCH] strncpy implementation and tests
Status: Pre-Alpha
Brought to you by:
hdante
From: Henrique A. <hd...@gm...> - 2009-07-16 03:10:30
|
If I understood correctly, CTest is already providing that functionallity. For TEST(), we have add_libposix_test(), which works the same way. The test script is automatically provided by CTest. For example, if I run "make test" on my system I get: Running tests... Start processing tests Test project /home/hdante/código/libposix/libposix.build 1/ 6 Testing puts_hello Passed 2/ 6 Testing hello Passed 3/ 6 Testing printf_scanner Passed 4/ 6 Testing print_parser Passed 5/ 6 Testing strncpy Passed 6/ 6 Testing stdlib_test ***Failed 83% tests passed, 1 tests failed out of 6 The following tests FAILED: 6 - stdlib_test (Failed) Errors while running CTest make: ** [test] Erro 8 I have written some comments about CTest in: https://sourceforge.net/apps/mediawiki/libposix/index.php?title=How_to_write_tests The only thing that is missing now is the ability of detecting correct standard output on certain tests (like hello world). I have already found a recipe for that (bizarrely, it's not trivial to do that with CTest) and I expect to include the functionality in a few weeks (and also complete the CTest documentation in the wiki). I'll put those in the task page as soon as possible. 2009/7/15 Chris Forbes <ch...@fa...>: > I have no idea about cmake/ctest; I don't use them for my own stuff, since I try to avoid needing a C++ compiler. > Anyway, here's what I use for an embedded project. It's probably horrible in lots of ways, but it allows you to write tests like: > > TEST( my_test_name ) > { > assert( blah ); > } > > or > > TEST( my_other_test, "somestubs.c", "someotherstubs.c" ) > { > assert( blah blah ); > } > > It's just two files: > > $(PROJECT)/gentests.sh: > > #!/bin/bash > > # generate and run test wrappers > # c. forbes (ch...@fa...) > > testsources=`grep -l "TEST(" *.c` > succeeded=0 > failed=0 > > for f in $testsources > do > echo -n "Searching for tests in \`$f\`... " > tests=`grep "TEST(" $f | cut -d'(' -f 2 | cut -d, -f1 | cut -d')' -f1` > echo `echo $tests | wc -w` found. > > for t in $tests > do > deps=`grep "$t" $f | cut -sd, -f2- | cut -d')' -f1` > deps=`echo $deps | sed -e 's/[,\"]//g'` > # echo $t deps: $deps > > testbin=.test-$f-$t > tmpsrc=`mktemp`.c > cat > $tmpsrc << EOT > extern void __test__{{}}( void ); > > int main( int argc, char ** argv ) > { > __test__{{}}(); > return 0; > } > EOT > cat $tmpsrc | sed -e "s/{{}}/$t/g" > $testbin.c > gcc -DTEST_FRAMEWORK -o $testbin.elf -pipe $testbin.c $f $deps > > if ./$testbin.elf; then > # echo SUCCESS > let "succeeded=succeeded+1" > else > # echo FAILED > let "failed=failed+1" > fi > done > done > > rm .test* > if [ $failed = 0 ]; then > echo "$succeeded tests passed." > else > echo "FAILURES!!!" > echo "$failed failed $succeeded ok" > fi > > > > $(INCLUDE)/testfx.h: > > #ifndef _TESTFX_H > #define _TESTFX_H > > #define TEST( test_name, ... )\ > void __test__ ## test_name( void ) > > #endif > > -----Original Message----- > From: Henrique Almeida [mailto:hd...@gm...] > Sent: Thursday, 16 July 2009 11:23 a.m. > To: lib...@li... > Subject: Re: [libposix-development] [PATCH] strncpy implementation and tests > > 2009/7/15 Chris Forbes <ch...@fa...>: >> What are people's thoughts on using a "real" testing framework, to avoid the need to manually specify > > What do you have in mind ? > > things in various places? The required plumbing can be done with just > sh+coreutils. > > But can it be done with CMake/CTest too ? > >> >> -----Original Message----- >> From: Henrique Almeida [mailto:hd...@gm...] >> Sent: Monday, 13 July 2009 4:16 a.m. >> To: lib...@li... >> Subject: Re: [libposix-development] [PATCH] strncpy implementation and tests >> >> I've added a macro, available to the build system to add tests: >> >> add_libposix_test(test_name source1 source2 ...) >> >> CMakeLists.txt now can add tests with a single line rule. >> >> 2009/7/8 Henrique Almeida <hd...@gm...>: >>> 2009/7/4 Henrique Almeida <hd...@gm...>: >>>> >>>> I'll add an article in the wiki explaining the recommended way to >>>> write tests for libposix. >>> >>> A small guide to writing tests for libposix is now available at: >>> >>> https://sourceforge.net/apps/mediawiki/libposix/index.php?title=How_to_write_tests >>> >>>> >>>> Henrique Dante de Almeida >>>> hd...@gm... >>>> >>> >>> >>> >>> -- >>> Henrique Dante de Almeida >>> hd...@gm... >>> >> >> >> >> -- >> Henrique Dante de Almeida >> hd...@gm... >> >> ------------------------------------------------------------------------------ >> Enter the BlackBerry Developer Challenge >> This is your chance to win up to $100,000 in prizes! For a limited time, >> vendors submitting new applications to BlackBerry App World(TM) will have >> the opportunity to enter the BlackBerry Developer Challenge. See full prize >> details at: http://p.sf.net/sfu/Challenge >> _______________________________________________ >> Libposix-development mailing list >> Lib...@li... >> https://lists.sourceforge.net/lists/listinfo/libposix-development >> ------------------------------------------------------------------------------ >> Enter the BlackBerry Developer Challenge >> This is your chance to win up to $100,000 in prizes! For a limited time, >> vendors submitting new applications to BlackBerry App World(TM) will have >> the opportunity to enter the BlackBerry Developer Challenge. See full prize >> details at: http://p.sf.net/sfu/Challenge >> _______________________________________________ >> Libposix-development mailing list >> Lib...@li... >> https://lists.sourceforge.net/lists/listinfo/libposix-development >> > > > > -- > Henrique Dante de Almeida > hd...@gm... > > ------------------------------------------------------------------------------ > Enter the BlackBerry Developer Challenge > This is your chance to win up to $100,000 in prizes! For a limited time, > vendors submitting new applications to BlackBerry App World(TM) will have > the opportunity to enter the BlackBerry Developer Challenge. See full prize > details at: http://p.sf.net/sfu/Challenge > _______________________________________________ > Libposix-development mailing list > Lib...@li... > https://lists.sourceforge.net/lists/listinfo/libposix-development > ------------------------------------------------------------------------------ > Enter the BlackBerry Developer Challenge > This is your chance to win up to $100,000 in prizes! For a limited time, > vendors submitting new applications to BlackBerry App World(TM) will have > the opportunity to enter the BlackBerry Developer Challenge. See full prize > details at: http://p.sf.net/sfu/Challenge > _______________________________________________ > Libposix-development mailing list > Lib...@li... > https://lists.sourceforge.net/lists/listinfo/libposix-development > -- Henrique Dante de Almeida hd...@gm... |