|
From: Stefan K. <en...@ho...> - 2005-03-05 17:54:45
|
Hi Nicholas, Some more explanation ;) the tests are written using the testing framework. One test-binary contains test suites, that in turn contains tests cases and these finally contain the tests. What I need is to make the test binary to be run under valgrind. The invokation of the test-binary can't be changed, as this is generated by the automake from Makefile.am. It just starts the binaries and depending on the return value, record a pass or a fail for the test. Thus I need a mechanism, that restarts the binary whne it not runs under valgrind. Thats what the code snipped should do. I'll try this out next week. Stefan > On Fri, 4 Mar 2005, Stefan Kost wrote: > >> sorry if this has been answered before ... >> I look for a way to integrate valgrind into my unit-test suite. >> The unit-tests are written using check (http://check.sf.net). The >> project uses the autotools. >> Thus 'make check' runns the binaries and scripts listed in the TESTS >> variable of the Makefile.am. >> >> Now it would be nice to run the tests under valgrind, use the macros >> from e.g. memcheck.h at the end of each test and make the test fail if >> there are leaks. >> The problem is that the program is started without valgrind. > > > Which program -- the test framework, or the individual tests? > >> One hack to solve it would be something like >> >> if(!RUNNING_ON_VALGRIND) { >> char cmd[FILENAME_MAX]; >> >> sprintf(cmd,"valgrind %s %s",valgrind_opts,argv[0]); >> argv[0]=cmd; >> execv(cmd, argv); >> } >> >> I've not yet tried it. Anyone a better idea? Commants? > > > It's unclear where that code goes -- in the programs being tested? In > the test framework? I also don't really see how it works. > > I would think that you need to find some way within the test framework > to augment the command lines used to run the individual tests, and > prefix them with "valgrind ...". > > N |