summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPetr Rockai <prockai@redhat.com>2014-07-01 21:22:58 +0200
committerPetr Rockai <prockai@redhat.com>2014-11-18 19:01:30 +0100
commitaea40fc9460b6294619210aa79c60b83b9472a5f (patch)
tree0b0f3416a0c5b4b8ccec25eaf11407499a1d2fb3
parent6c11c2b90ee257d469b194a1b62464157cd3cd1f (diff)
downloadlvm2-aea40fc9460b6294619210aa79c60b83b9472a5f.tar.gz
test: Make the runner's heartbeat more reliable.
-rw-r--r--test/lib/runner.cpp24
1 files changed, 13 insertions, 11 deletions
diff --git a/test/lib/runner.cpp b/test/lib/runner.cpp
index 1522fd51f..ffc5398a3 100644
--- a/test/lib/runner.cpp
+++ b/test/lib/runner.cpp
@@ -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 )
{
}
};