Re: [libposix-development] [PATCH] strncpy implementation and tests
Status: Pre-Alpha
Brought to you by:
hdante
From: Chris F. <ch...@fa...> - 2009-07-16 02:46:06
|
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 |