1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-01-03 05:18:29 +03:00

test: Make the runner's heartbeat more reliable.

This commit is contained in:
Petr Rockai 2014-07-01 21:22:58 +02:00
parent f0d314bd6d
commit 34e818042e

View File

@ -117,7 +117,7 @@ struct TestCase {
bool timeout;
pid_t pid;
time_t start, end, silent_start, last_update;
time_t start, end, silent_start, last_update, last_heartbeat;
Options options;
Journal *journal;
@ -152,6 +152,16 @@ struct TestCase {
bool monitor() {
end = time( 0 );
/* heartbeat */
if ( end - last_heartbeat >= 20 ) {
std::string stampfile( options.outdir + "/timestamp" );
std::ofstream stamp( stampfile.c_str() );
stamp << end;
stamp.close();
fsync_name( stampfile );
}
if ( wait4(pid, &status, WNOHANG, &usage) != 0 ) {
io.sync();
return false;
@ -192,15 +202,6 @@ struct TestCase {
io.sync();
/* heartbeat */
if ( time( 0 ) % 20 == 0 ) {
std::string stampfile( options.outdir + "/timestamp" );
std::ofstream stamp( stampfile.c_str() );
stamp << time( 0 );
stamp.close();
fsync_name( stampfile );
}
return true;
}
@ -347,7 +348,8 @@ struct TestCase {
}
TestCase( Journal &j, Options opt, std::string path, std::string name, std::string flavour )
: timeout( false ), child( path ), name( name ), flavour( flavour ), options( opt ), journal( &j )
: timeout( false ), child( path ), name( name ), flavour( flavour ), options( opt ), journal( &j ),
last_update( 0 ), last_heartbeat( 0 )
{
}
};