#include <stdlib.h> #include "clientapi.h" #include "globals.h" #include "clientgremlin.h" void run_super_oblit( ClientApi* client ); void run_super_verify( ClientApi* client ); void run_super_protect( ClientApi* client ); void task_super( ClientApi* client ) { int rnd = rand() % 100; if ( rnd < 33 ) run_super_protect( client ); else if ( rnd < 66 ) run_super_oblit( client ); else run_super_verify( client ); } void run_super_protect( ClientApi* client ) { ClientGremlin grem = ClientGremlin( client, "protect" ); grem.arg1.Set( "-o" ); grem.Run(); StrBuf fspec; if ( rand() % 2 ) fspec.Set( "-" ); fspec.Append( "//depot/" ); for ( int a = 0 ; a < 5 ; a++ ) { if ( rand() % 15 < 5 ) break; fspec.Append ( dirwords.GetVar( StrNum( rand() % dirwords.GetCount() ) ) ); fspec.Append( "/" ); } if ( rand() % 15 < 10 ) { fspec.Append( "..." ); } else { fspec.Append ( filewords.GetVar( StrNum( rand() % filewords.GetCount() ) ) ); } grem.input.Append( "\tsuper user * * " ); grem.input.Append( &fspec ); grem.input.Append( "\n" ); grem.arg1.Set( "-i" ); grem.Run(); } void run_super_verify( ClientApi* client ) { ClientGremlin grem = ClientGremlin( client, "verify" ); if ( rand() %2 ) grem.arg1.Set( "-qu" ); else grem.arg1.Set( "-q" ); grem.arg2.Set( "//depot/..." ); grem.Run(); } void run_super_oblit( ClientApi* client ) { ClientGremlin grem = ClientGremlin( client, "obliterate" ); grem.arg1.Set( "-y" ); StrBuf fspec; fspec.Append( "//depot/" ); for ( int a = 0 ; a < 5 ; a++ ) { fspec.Append ( dirwords.GetVar( StrNum( rand() % dirwords.GetCount() ) ) ); fspec.Append( "/" ); if ( rand() % 50 < a*5 ) break; } if ( rand() % 15 < 10 ) { fspec.Append( "..." ); } else { fspec.Append ( filewords.GetVar( StrNum( rand() % filewords.GetCount() ) ) ); } grem.arg2.Set( fspec ); grem.Run(); }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#1 | 2041 | Sam Stafford |
P4GREMLIN, a stress testing utility. Requires the P4 Client API to build. |