diff options
author | Petr Rockai <prockai@redhat.com> | 2014-10-01 11:27:44 +0200 |
---|---|---|
committer | Petr Rockai <prockai@redhat.com> | 2015-02-05 13:51:06 +0100 |
commit | c96e42006d3bbbcc21cf952c96bf1fc7b15f1bd0 (patch) | |
tree | e47eb3fbd144e6c82aeed4b6af8d83468732daa0 | |
parent | 72ee3f920b235c516328e92757571d311308f439 (diff) | |
download | lvm2-c96e42006d3bbbcc21cf952c96bf1fc7b15f1bd0.tar.gz |
test: Only force an IO sync when the testcase has finished.
-rw-r--r-- | test/lib/brick-shelltest.h | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/test/lib/brick-shelltest.h b/test/lib/brick-shelltest.h index 7c6a0219b..71194cfc3 100644 --- a/test/lib/brick-shelltest.h +++ b/test/lib/brick-shelltest.h @@ -339,7 +339,7 @@ struct TimedBuffer { struct Sink { virtual void outline( bool ) {} virtual void push( std::string x ) = 0; - virtual void sync() {} + virtual void sync( bool ) {} virtual ~Sink() {} }; @@ -410,11 +410,11 @@ struct FdSink : Sink { write( fd, out.c_str(), out.length() ); } - virtual void sync() { + virtual void sync( bool force ) { if ( killed ) return; - while ( !stream.empty( true ) ) - outline( true ); + while ( !stream.empty( force ) ) + outline( force ); } virtual void push( std::string x ) { @@ -429,13 +429,13 @@ struct FileSink : FdSink { std::string file; FileSink( std::string n ) : FdSink( -1 ), file( n ) {} - void sync() { + void sync( bool force ) { if ( fd < 0 && !killed ) { fd = open( file.c_str(), O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC, 0644 ); if ( fd < 0 ) killed = true; } - FdSink::sync(); + FdSink::sync( force ); } ~FileSink() { @@ -561,12 +561,12 @@ struct IO : Sink { (*i)->push( x ); } - void sync() { + void sync( bool force ) { for ( Sources::iterator i = sources.begin(); i != sources.end(); ++i ) (*i)->sync( this ); for ( Sinks::iterator i = sinks.begin(); i != sinks.end(); ++i ) - (*i)->sync(); + (*i)->sync( force ); } void close() { @@ -717,7 +717,7 @@ struct TestCase { } if ( wait4(pid, &status, WNOHANG, &usage) != 0 ) { - io.sync(); + io.sync( true ); return false; } @@ -732,7 +732,7 @@ struct TestCase { waitpid( pid, &status, 0 ); } timeout = true; - io.sync(); + io.sync( true ); return false; } @@ -755,7 +755,7 @@ struct TestCase { if ( select( nfds, &set, NULL, NULL, &wait ) > 0 ) silent_start = end; /* something happened */ - io.sync(); + io.sync( false ); return true; } |