1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-03-11 20:58:50 +03:00

test: Update brick-shelltest (configurable timeout, better banner, exit code).

This commit is contained in:
Petr Rockai 2014-09-14 11:15:51 +02:00
parent b6884f8a87
commit c82c69bb56

View File

@ -64,8 +64,9 @@
#include <algorithm> #include <algorithm>
#include <stdexcept> #include <stdexcept>
#ifdef __unix
#include <dirent.h> #include <dirent.h>
#ifdef __unix
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/resource.h> /* rusage */ #include <sys/resource.h> /* rusage */
#include <sys/select.h> #include <sys/select.h>
@ -262,7 +263,10 @@ struct Journal {
void banner() { void banner() {
std::cout << std::endl << "### " << status.size() << " tests: " std::cout << std::endl << "### " << status.size() << " tests: "
<< count( PASSED ) << " passed" << std::endl; << count( PASSED ) << " passed, "
<< count( SKIPPED ) << " skipped, "
<< count( TIMEOUT ) + count( WARNED ) << " broken, "
<< count( FAILED ) << " failed" << std::endl;
} }
void details() { void details() {
@ -442,7 +446,6 @@ struct FileSink : FdSink {
} }
}; };
#define BRICK_SYSLOG_ACTION_READ 2
#define BRICK_SYSLOG_ACTION_READ_CLEAR 4 #define BRICK_SYSLOG_ACTION_READ_CLEAR 4
#define BRICK_SYSLOG_ACTION_CLEAR 5 #define BRICK_SYSLOG_ACTION_CLEAR 5
@ -619,8 +622,10 @@ struct Options {
std::string testdir, outdir, workdir, heartbeat; std::string testdir, outdir, workdir, heartbeat;
std::vector< std::string > flavours, filter, watch; std::vector< std::string > flavours, filter, watch;
std::string flavour_envvar; std::string flavour_envvar;
int timeout;
Options() : verbose( false ), batch( false ), interactive( false ), Options() : verbose( false ), batch( false ), interactive( false ),
cont( false ), fatal_timeouts( false ), kmsg( false ) {} cont( false ), fatal_timeouts( false ), kmsg( false ),
timeout( 60 ) {}
}; };
struct TestProcess struct TestProcess
@ -718,7 +723,7 @@ struct TestCase {
/* kill off tests after a minute of silence */ /* kill off tests after a minute of silence */
if ( !options.interactive ) if ( !options.interactive )
if ( end - silent_start > 60 ) { if ( end - silent_start > options.timeout ) {
kill( pid, SIGINT ); kill( pid, SIGINT );
sleep( 5 ); /* wait a bit for a reaction */ sleep( 5 ); /* wait a bit for a reaction */
if ( waitpid( pid, &status, WNOHANG ) == 0 ) { if ( waitpid( pid, &status, WNOHANG ) == 0 ) {
@ -982,7 +987,7 @@ struct Main {
if ( die || fatal_signal ) if ( die || fatal_signal )
return 1; return 1;
return 0; return journal.count( Journal::FAILED ) ? 1 : 0;
} }
Main( Options o ) : die( false ), journal( o.outdir ), options( o ) {} Main( Options o ) : die( false ), journal( o.outdir ), options( o ) {}
@ -1099,6 +1104,9 @@ int run( int argc, const char **argv, std::string fl_envvar = "TEST_FLAVOUR" )
if ( args.has( "--watch" ) ) if ( args.has( "--watch" ) )
split( args.opt( "--watch" ), opt.watch ); split( args.opt( "--watch" ), opt.watch );
if ( args.has( "--timeout" ) )
opt.timeout = atoi( args.opt( "--timeout" ).c_str() );
if ( args.has( "--kmsg" ) ) if ( args.has( "--kmsg" ) )
opt.kmsg = true; opt.kmsg = true;
@ -1128,7 +1136,7 @@ int run( int argc, const char **argv, std::string fl_envvar = "TEST_FLAVOUR" )
#ifdef BRICK_DEMO #ifdef BRICK_DEMO
int main( int argc, const char **argv ) { int main( int argc, const char **argv ) {
brick::shelltest::run( argc, argv ); return brick::shelltest::run( argc, argv );
} }
#endif #endif