diff options
author | Petr Rockai <prockai@redhat.com> | 2014-07-01 21:22:58 +0200 |
---|---|---|
committer | Petr Rockai <prockai@redhat.com> | 2014-11-20 12:36:45 +0100 |
commit | 52180afb0f79a08e1928a7e71c1f0415a38ad6e3 (patch) | |
tree | a39f64ef845ee7c6f03fdfb04f64bcf95d5956e6 | |
parent | ed78429e16d9ba572b1b6db364b48a11644be77a (diff) | |
download | lvm2-52180afb0f79a08e1928a7e71c1f0415a38ad6e3.tar.gz |
test: Make the runner's heartbeat more reliable.
-rw-r--r-- | test/lib/runner.cpp | 24 |
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 ) { } }; |