📄 staftest.cmd
字号:
end if external then do call autodoit 0 where dc "HELP" "version" call autodoit 0 where dc "HELP" "help" call autodoit 0 where dc "HELP" "error" call autodoit 0 where dc "HELP" "error" random(1,38) call autodoit 0 where dc "HELP" "error" random(4000,5000) call autodoit 0 where dc "MONITOR" "help" timestamp=date('w') date() time('l') msglen = length(timestamp) + 17 call autodoit 0 where dc "MONITOR" "log message :"msglen":"||"Monitor STAFTest" timestamp call autodoit 0 where dc "MONITOR" "query machine" origmachine "handle" STAFHandle call autodoit 7 where dc "MONITOR" "ask machine" origmachine "handle" STAFHandle call autodoit 17 where dc "MONITOR" "query machine" origmachine "handle HAN"||time('s') call autodoit 0 where dc "MONITOR" "list machines" call autodoit 0 where dc "MONITOR" "list machine" origmachine call autodoit 0 where dc "MONITOR" "refresh var" call autodoit 0 where dc "LOG" "help" call autodoit 0 where dc "LOG" "list global" call autodoit 0 where dc "LOG" "query global logname staftest last" random(1,10) call autodoit 0 where dc "LOG" "query global logname staftest contains Monday contains Tuesday first 2 levelbitstring" call autodoit 0 where dc "LOG" "query machine" origmachine "logname staftest from 19970101@08:30:45 to today first 5" call autodoit 0 where dc "LOG" "query global logname staftest total" timestamp=date('w') date() time('l') msglen = length(timestamp) + 26 level = substr('0', 1, 32, '0') level = overlay('1', level, random(1,8)) call autodoit 0 where dc "LOG" "query machine" origmachine "handle" STAFHandle "logname staftest levelmask 11111111111111111111111111111111 STATS" call autodoit 0 where dc "LOG" "query machine" origmachine "handle" STAFHandle "logname staftest total" if STAFResult > 10 then do call autodoit 0 where dc "LOG" "purge machine" origmachine "handle" STAFHandle "logname staftest first 5 confirm" call autodoit 0 where dc "LOG" "delete machine" origmachine "handle" STAFHandle "logname staftest confirm" end call autodoit 0 where dc "LOG" "log handle logname staftest level" level "message :"||msglen||":Log STAFTest Continues at" timestamp call autodoit 0 where dc "LOG" "query machine" origmachine "handle" STAFHandle "logname staftest qmachine" origmachine "qhandle" STAFHandle call autodoit 7 where dc "LOG" "ask global logname staftest last" random(1,10) call autodoit 17 where dc "LOG" "query machine" origmachine "handle HAN"||time('s')" logname LOG"||time('s') call autodoit 20 where dc "LOG" "delete machine" time('s') "logname" time('s') "confirm" call autodoit 4001 where dc "LOG" "query machine" origmachine "logname staftest first" origmachine call autodoit 4002 where dc "LOG" "query global logname staftest from "||time('s') call autodoit 4003 where dc "LOG" "query global logname staftest from today@"||time('s') call autodoit 4004 where dc "LOG" "query global logname staftest levelmask BADLEVEL" call autodoit 4008 where dc "LOG" "purge global logname staftest CONFIRM" call autodoit 0 where dc "LOG" "list machines" end loop = loop + 1 if error > 0 & loud then do say "###############################################################################" say "Error Count =" error say "###############################################################################" say "Errors (Timestamp|Handle|Where|Service|Request|STAFRC|STAFResult):" errortxt say "###############################################################################" say "Error Count =" error say "###############################################################################" endendcall Enditcall Cleanupexitautodoit: parse arg Aerrorok Awhere Aresult Aservice Arequest Aerror = 0 if loud then do say "..............................................................................." say "Service="Aservice " Where="Awhere " ExpectedSTAFRC="Aerrorok " TotalErrors="error say "LoopNum="loop " Handle="STAFHandle " Started="initiated " Elapsed="time('e') say "Request="Arequest if Aresult \= '*' then say "ExpectedRequest="||Aresult end STAFRC = STAFSubmit(Awhere, Aservice, Arequest) if STAFRC = Aerrorok then do if Aresult \= '*' & Aresult \= STAFResult then Aerror = 1 else do totok = totok + 1 if STAFRC > 0 & loud then say "STAFRC="||STAFRC if STAFResult \= 0 & STAFResult > '' & loud then say STAFResult else nop end end else Aerror = 1 if Aerror = 1 then do if loud then do say "###############################################################################" say "STAFRC="||STAFRC "STAFResult="||STAFResult say "###############################################################################" end errortxt = errortxt||time('l')||"|"||STAFHandle||"|"||Awhere||"|"||Aservice||"|"||Arequest||"|"||STAFRC||"|"||STAFResult||crlf error = error + 1 if cleanup = 0 & error >= maxerror then call STAFAbort endreturnSTAFAbort: call EndIt say "Are you sure you want to exit STAFTest (Y/N)?" parse upper pull response if response \= "Y" then return if error > 0 then do say "Do you want to append the errors to" logfile "(Y/N)?" parse upper pull response if response = "Y" then do status = FileStatus(logfile, 10, "write") if status \= errorNotReady then do rc = charout(logfile, "********************************************************") rc = charout(logfile, errortxt) end else say "Unable to write to" logfile end end call CleanupexitGENWLSetup: call autodoit 0 where dc "VAR" "resolve system string {STAF/Config/BootDrive}" GW_bootdrive = STAFResult GW_workload = "STAFTest Handle" STAFHandle "Time" time('l') if where = "LOCAL" then GW_machine = machine else GW_machine = where GW_data = "WORKLOAD STAFTest"||STAFHandle||crlf , 'VAR "STAFTest=Workload-Var"'||crlf , "MACHINE" GW_machine||crlf , " PROCESS"||crlf , " COMMAND" shellCommand||crlf , ' PARMS "/c dir"'||crlf , " WORKDIR " GW_bootdrive||delimit||crlf , ' ENV "STAFTest=Environment"'||crlf , ' VAR "STAFTest=Local-Var"'||crlf , " END"||crlf if optionTimes("GENWLONLY") > 0 then GW_data = GW_data||" PROCESS COMMAND pmseek.exe END"||crlf GW_data = GW_data||' VAR "STAFTest=Machine-Var"'||crlf||"END"||crlf do until rc = 1 gwlfile = "GW"||time('s')||random(1,9)||".gwl" rc = FileStatus(gwlfile, 10, "write") end rc = charout(gwlfile, GW_data, 1) if rc = 0 then call stream gwlfile, "c", "close"returnGENWLRun: call autogenwl 0 gwlfile "start" call autogenwl 0 gwlfile "query" call autogenwl 0 gwlfile "stop" call autogenwl 0 gwlfile "query" call autogenwl 0 gwlfile "free" call autogenwl 0 gwlfile "query" call autogenwl 1 "FILE"||time('s') "query"returnautogenwl: parse arg AG_errorok AG_file AG_opt if loud then do say "..............................................................................." say "Service=GENWL Where="where " ExpectedRC="AG_errorok " TotalErrors="error say "LoopNum="loop " Handle="STAFHandle " Started="initiated " Elapsed="time('e') say "Request="AG_opt end call genwl AG_file "-"||AG_opt "-usehandle" STAFHandle if RESULT = AG_errorok then totok = totok + 1 else do if loud then do say "###############################################################################" say "RC="||RC "Result="||Result say "###############################################################################" end errortxt = errortxt||time('l')||"|"||STAFHandle||"|"||where||"|GENWL|"||AG_opt||"|"||RC||"|"||Result||crlf error = error + 1 if cleanup = 0 & error >= maxerror then call STAFAbort endreturnCleanUp: cleanup = 1 say "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" say "Clean Up Time" say "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" if external then call autodoit 0 where dc "LOG" "delete machine" origmachine "handle" STAFHandle "logname staftest confirm" if internal then do call autodoit 0 where dc "VAR" "delete system var For"||testcase "delete Ever"||testcase||"" if genwl then '@del' gwlfile '>nul 2>nul' end call STAFUnRegister if error > 0 & loud then do say "###############################################################################" say "Error Count =" error say "###############################################################################" say "Errors (Timestamp|Handle|Where|Service|Request|STAFRC|STAFResult):" errortxt say "###############################################################################" say "Error Count =" error say "###############################################################################" endreturnEndIt: say "*******************************************************************************" say loop-1 "loops run. " totok "total test iterations run." say "A total of" error "errors encountered." say "*******************************************************************************"return/******************************************************************************//* From here on are imported functions, DO NOT CHANGE ANYTHING BELOW HERE *//******************************************************************************//******************************************************************************//* STAFWrapData - Wraps a REXX String using colon delimited STAF format *//* Arguments: REXX string *//* Returns : STAF formatted string *//******************************************************************************/STAFWrapData: PROCEDURE parse arg data RETURN ":"LENGTH(data)":"data/* End of STAFWrapData *//******************************************************************************//* MakeSTAFResult - Creates REXX STAFResult string *//* Arguments: The return code *//* The result string *//* Returns : STAFResult string *//******************************************************************************/MakeSTAFResult: PROCEDURE parse arg theRC, resultString RETURN REVERSE(D2C(theRC, 4)) || resultString/* End of MakeSTAFResult *//******************************************************************************//* STAFErrorText - STAF defined error codes and text. *//* Arguments: none *//* Returns : 0 *//******************************************************************************/STAFErrorText: PROCEDURE EXPOSE STAFError. STAFError.!Ok = 0 STAFError.!Ok.!Text = "No Error" STAFError.!InvalidAPI = 1 STAFError.!InvalidAPI.!Text = "Invalid API" STAFError.!UnknownService = 2 STAFError.!UnknownService.!Text = "Unknown Service" STAFError.!InvalidHandle = 3 STAFError.!InvalidHandle.!Text = "Invalid Handle" STAFError.!HandleAlreadyExists = 4 STAFError.!HandleAlreadyExists.!Text = "Handle Already Exists" STAFError.!HandleDoesNotExist = 5 STAFError.!HandleDoesNotExist.!Text = "Handle Does Not Exist" STAFError.!UnknownError = 6 STAFError.!UnknownError.!Text = "Unknown Error" STAFError.!InvalidRequestString = 7 STAFError.!InvalidRequestString.!Text = "Invalid Request String" STAFError.!InvalidServiceResult = 8 STAFError.!InvalidServiceResult.!Text = "Invalid Service Result" STAFError.!REXXError = 9 STAFError.!REXXError.!Text = "Rexx Error" STAFError.!BaseOSError = 10 STAFError.!BaseOSError.!Text = "Base OS Error" STAFError.!ProcessAlreadyComplete = 11 STAFError.!ProcessAlreadyComplete.!Text = "Process Already Complete" STAFError.!ProcessNotComplete = 12 STAFError.!ProcessNotComplete.!Text = "Process Not Complete" STAFError.!VariableDoesNotExist = 13 STAFError.!VariableDoesNotExist.!Text = "Variable Does Not Exist" STAFError.!UnResolvableString = 14 STAFError.!UnResolvableString.!Text = "UnResolvable String" STAFError.!InvalidResolveString = 15 STAFError.!InvalidResolveString.!Text = "Invalid Resolve String" STAFError.!NoPathToMachine = 16 STAFError.!NoPathToMachine.!Text = "No Path To Machine" STAFError.!FileOpenError = 17 STAFError.!FileOpenError.!Text = "File Open Error" STAFError.!FileReadError = 18 STAFError.!FileReadError.!Text = "File Read Error" STAFError.!FileWriteError = 19 STAFError.!FileWriteError.!Text = "File Write Error" STAFError.!FileDeleteError = 20 STAFError.!FileDeleteError.!Text = "File Delete Error" STAFError.!STAFNotRunning = 21 STAFError.!STAFNotRunning.!Text = "STAF Not Running" STAFError.!CommunicationError = 22 STAFError.!CommunicationError.!Text = "Communication Error" STAFError.!TrusteeDoesNotExist = 23 STAFError.!TrusteeDoesNotExist.!Text = "Trustee Does Not Exist" STAFError.!InvalidTrustLevel = 24 STAFError.!InvalidTrustLevel.!Text = "Invalid Trust Level" STAFError.!AccessDenied = 25 STAFError.!AccessDenied.!Text = "Access Denied" STAFError.!STAFRegistrationError = 26 STAFError.!STAFRegistrationError.!Text = "STAF Registration Error" STAFError.!ServiceConfigurationError = 27 STAFError.!ServiceConfigurationError.!Text = "Service Configuration Error" STAFError.!QueueFull = 28 STAFError.!QueueFull.!Text = "Queue Full" STAFError.!NoQueueElement = 29 STAFError.!NoQueueElement.!Text = "No Queue Element" STAFError.!NotifieeDoesNotExist = 30 STAFError.!NotifieeDoesNotExist.!Text = "Notifiee Does Not Exist" STAFError.!InvalidAPILevel = 31 STAFError.!InvalidAPILevel.!Text = "Invalid API Level" STAFError.!ServiceNotUnregisterable = 32 STAFError.!ServiceNotUnregisterable.!Text = "Service Not Unregisterable" STAFError.!ServiceNotAvailable = 33 STAFError.!ServiceNotAvailable.!Text = "Service Not Available" STAFError.!SemaphoreDoesNotExist = 34 STAFError.!SemaphoreDoesNotExist.!Text = "Semaphore Does Not Exist" STAFError.!NotSemaphoreOwner = 35 STAFError.!NotSemaphoreOwner.!Text = "Not Semaphore Owner" STAFError.!SemaphoreHasPendingRequests = 36 STAFError.!SemaphoreHasPendingRequests.!Text = "Semaphore Has Pending Requests" STAFError.!Timeout = 37
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -