I am trying to check for a running server process in a Boost UTF global fixture. I am doing this with a call to system in my fixture constructor like this...
class MyTestFixture
{
public:
MyTestFixture();
~MyTestFixture() ;
};
MyTestFixture::MyTestFixture()
{
int rc = system("pidof myserver > /dev/null");
if ( rc != 0 )
{
cout << "myserver not running so cannot continue" << endl;
fflush (stdout) ;
sleep(10);
exit(4) ;
}
cout << "fixture setup ok!" << endl ;
}
BOOST_GLOBAL_FIXTURE( MyTestFixture );
BOOST_AUTO_TEST_CASE( pgmiia_main_test1 )
{
// some test code...
}
When "myserver" is running ok everything is fine, but when it isnt I get a crash. and it doesnt go into the if section and exit. Strangely if I run it in gdb with myserver not running, it does go into my exit branch as I expect.
I'm a bit new to Boost UTF. I am doing this with a dynamic link. Any ideas?
Jon