// clientgremlin.cpp: implementation of the ClientGremlin class. // ////////////////////////////////////////////////////////////////////// #include "clientapi.h" #include "clientgremlin.h" ////////////////////////////////////////////////////////////////////// // Construction/Destruction ////////////////////////////////////////////////////////////////////// ClientGremlin::ClientGremlin( ClientApi* cli, char* op ) : ClientUser(), client( cli ), cmd( op ), arg1( StrBuf() ), arg2( StrBuf() ) { } ClientGremlin::~ClientGremlin() { } void ClientGremlin::HandleError( Error* err ) { StrBuf out; out = client->GetClient(); StrBuf buf; err->Fmt( buf, EF_INDENT ); out.Append( ": " ); out.Append( cmd ); out.Append( ":\n" ); out.Append( &buf ); if ( !buf.Contains( StrRef( "exceeded" ) ) && !err->IsFatal() ) return; OutputError( out.Text() ); } void ClientGremlin::InputData( StrBuf* strbuf, Error* e ) { strbuf->Set( input ); } void ClientGremlin::OutputInfo( char level, const_char* data ) { //default implementation is whisper-quiet input.Set( data ); } void ClientGremlin::Run() { Error e; client->Init( &e ); if ( e.IsFatal() ) { HandleError( &e ); return; } int args = 0; char* argv[3]; if ( arg1.Length() ) { args = 1; argv[0] = arg1.Text(); } if ( arg2.Length() ) { args = 2; argv[1] = arg2.Text(); } if ( arg3.Length() ) { args = 3; argv[2] = arg3.Text(); } client->SetArgv( args, argv ); client->Run( cmd, this ); client->Final( &e ); HandleError( &e ); }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#1 | 2041 | Sam Stafford |
P4GREMLIN, a stress testing utility. Requires the P4 Client API to build. |