#include <stdlib.h> #include "clientapi.h" #include "globals.h" #include "clientgremlin.h" #include "clientgremlindesc.h" #include "clientgremlinpending.h" void run_pending_submit( ClientApi* client, char* change ); void run_pending_resolve( ClientApi* client ); void run_pending_revert( ClientApi* client, char* change ); void task_pending( ClientApi* client ) { changes.Clear(); ClientGremlinPending grem = ClientGremlinPending( client ); grem.Run(); char* change; if ( !changes.GetCount() ) change = NULL; else { StrPtr* p = changes.GetVar( StrNum( rand() % changes.GetCount() ) ); change = p->Text(); } if ( !( rand() % 10 ) ) change = NULL; int rnd = rand() % 100; if ( rnd < 50 ) run_pending_submit( client, change ); else if ( rnd < 80 ) run_pending_resolve( client ); else run_pending_revert( client, change ); } void run_pending_submit( ClientApi* client, char* change ) { ClientGremlinDesc grem = ClientGremlinDesc( client ); if ( files.GetCount() ) { StrPtr* p = files.GetVar( StrNum( rand() % files.GetCount() ) ); if ( change ) { grem.arg1.Set( "-c" ); grem.arg2.Set( change ); grem.arg3.Set( p ); } else { grem.arg1.Set( p ); } grem.cmd = "edit"; grem.Run(); grem.input.Clear(); grem.arg3.Clear(); grem.arg2.Clear(); } grem.cmd = "change"; grem.arg1.Set( "-o" ); if ( change ) grem.arg2.Set( change ); grem.Run(); grem.cmd = "submit"; grem.arg1.Set( "-i" ); grem.arg2.Clear(); grem.Run(); } void run_pending_resolve( ClientApi* client ) { ClientGremlin grem = ClientGremlin( client, "resolve" ); grem.arg1.Set( "-am" ); grem.Run(); if ( rand() % 2 ) grem.arg1.Set( "-ay" ); else grem.arg1.Set( "-at" ); grem.Run(); } void run_pending_revert( ClientApi* client, char* change ) { ClientGremlin grem = ClientGremlin( client, "revert" ); if ( change ) { grem.arg1.Set( "-c" ); grem.arg2.Set( change ); grem.arg3.Set( "//depot/..." ); } else { grem.arg1.Set( "//depot/..." ); } grem.Run(); }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#1 | 2041 | Sam Stafford |
P4GREMLIN, a stress testing utility. Requires the P4 Client API to build. |