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

tests: update runner

Avoid busy-looping on CPU while reading socket pipe
and always call read only when select tells there is
something for read.

Change the batch output to old nicer output.
This commit is contained in:
Zdenek Kabelac 2015-03-11 21:13:41 +01:00
parent 1ad9677cb3
commit 26f5ec0e98

View File

@ -461,7 +461,7 @@ struct Source {
virtual void sync( Sink *sink ) {
ssize_t sz;
char buf[ 128 * 1024 ];
while ( (sz = read(fd, buf, sizeof(buf) - 1)) > 0 )
if ( (sz = read(fd, buf, sizeof(buf) - 1)) > 0 )
sink->push( std::string( buf, sz ) );
if ( sz < 0 && errno != EAGAIN )
throw syserr( "reading pipe" );
@ -720,10 +720,12 @@ struct TestCase {
exit(201);
}
#if 0
if (fcntl( fds[0], F_SETFL, O_NONBLOCK ) == -1) {
perror("fcntl on socket");
exit(202);
}
#endif
io.sources.push_back( new Source( fds[0] ) );
child.fd = fds[1];
@ -747,7 +749,7 @@ struct TestCase {
return false;
}
/* kill off tests after a minute of silence */
/* kill off tests after a timeout silence */
if ( !options.interactive )
if ( end - silent_start > options.timeout ) {
kill( pid, SIGINT );
@ -777,11 +779,10 @@ struct TestCase {
last_update = end;
}
}
if ( select( nfds, &set, NULL, NULL, &wait ) > 0 )
if ( select( nfds, &set, NULL, NULL, &wait ) > 0 ) {
silent_start = end; /* something happened */
io.sync( false );
}
return true;
}
@ -890,9 +891,10 @@ struct TestCase {
if ( options.batch ) {
int spaces = std::max( 64 - int(pretty().length()), 0 );
progress( Last ) << " " << std::string( spaces, '.' ) << " " << r << std::endl;
progress( Last ) << " " << std::string( spaces, '.' ) << " " << r;
if ( r == Journal::PASSED )
progress( First ) << " " << rusage() << std::endl;
progress( First ) << " " << rusage();
progress( Last ) << std::endl;
} else
progress( Last ) << tag( r ) << pretty() << std::endl;