⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 genwl.rxp

📁 Software Testing Automation Framework (STAF)的开发代码
💻 RXP
📖 第 1 页 / 共 2 页
字号:
/*****************************************************************************//* Software Testing Automation Framework (STAF)                              *//* (C) Copyright IBM Corp. 2001                                              *//*                                                                           *//* This software is licensed under the Common Public License (CPL) V1.0.     *//*****************************************************************************//*************************************************//* GenWL - A generic workload processer for STAF *//*************************************************/OPTIONS "ETMODE EXMODE"SIGNAL ON ERROR NAME TrapHandlerSIGNAL ON HALT NAME TrapHandlerSIGNAL ON SYNTAX NAME TrapHandlercall RxFuncAdd 'STAFLoadFuncs', 'RXSTAF', 'STAFLoadFuncs'call STAFLoadFuncsparse arg commandline/**************************************//* If no parameters then display help *//**************************************/if commandline = '' thendo    call PrintUsage    RETURN 1end/*************************************************//* Check to see if they are requesting full help *//*************************************************/if (LEFT(commandline, 1) = '?') | (LEFT(commandline, 2) = '-?') |,   (LEFT(commandline, 2) = '/?') thendo    call PrintUsage 'full'    RETURN 1end/*************************************//* Verify the command line arguments *//*************************************/call DoParseCommandLine commandlineif RESULT \= 0 thendo    call PrintUsage    RETURN 1end/*****************************************************************   Tokens     Key Words     WORKLOAD   MACHINE   PROCESS   COMMAND    PARMS   PROCREF     WORKDIR    VAR       ENV       END        TITLE   NAME   Whitespace    Space Tab CR LF EOF*****************************************************************/Whitespace = ' ' || D2C(9) || D2C(10) || D2C(13) || D2C(26)Terminals =  ''FirstSet  = ""FollowSet = ""KeySymbols.0 = ''KeyWords = "WORKLOAD  MACHINE  PROCESS  COMMAND  PARMS    WORKDIR",           "VAR       ENV      END      TITLE    PROCREF  NAME"KeyWords = SPACE(KeyWords)/******************************************//* First lex the file into a token stream *//******************************************/if debugLex then say "Begining lex phase"if \quietMode then    say "Reading and processing" workloadScript/* Debug: call TIME 'R' */call LexFile workloadScript/* Debug: say "Lex time:" TIME('R') */if debugLex thendo    /* Output the token stream */    say    do i = 1 to Tokens.0        if (Tokens.i = 'STRING') | (Tokens.i = 'NUMBER') then            say Tokens.i "= '" || Tokens.i.0 || "'"        else            say Tokens.i    end    sayend/******************************//* Now parse the token stream *//******************************/CR = '0D'xLF = '0A'xCRLF = '0D0A'xworkload = ""machine.0 = 0var.0 = 0process.0 = 0ExposeList = "workload machine. var. machineIndex process."if debugParse thendo    say "Beginning Parse Phase"    sayendcall DoParseif RESULT \= 0 then EXIT 1/* Debug: say "Parse time:" TIME('R') */if debugSym thendo    /* Output the symbol table */    say "Workload:" workload    do i = 1 to var.0        say "Var #"i"  :" var.i    end    do i = 1 to process.0        say        say "Process #"i "Name   :" process.i.!Name        say "Process #"i "Command:" process.i.!Command        say "Process #"i "Parms  :" process.i.!Parms        say "Process #"i "WorkDir:" process.i.!WorkDir        do j = 1 to process.i.!Env.0            say "Process #"i "Env #"j" :" process.i.!Env.j        end        do j = 1 to process.i.!Var.0            say "Process #"i "Var #"j" :" process.i.!Var.j        end    end    do i = 1 to machine.0        say        say "Machine #"i "Name  :" machine.i.!Name        do j = 1 to machine.i.!Var.0            say "Machine #"i "Var #"j":" machine.i.!Var.j        end        do j = 1 to machine.i.!Process.0            if machine.i.!Process.j.!Type = "PROCREF" then            do                say "Machine #"i "Process #"j "ProcRef:",                    machine.i.!Process.j.!ProcRef            end            else            do                say                say "Machine #"i "Process #"j "Command:",                    machine.i.!Process.j.!Command                say "Machine #"i "Process #"j "Parms  :",                    machine.i.!Process.j.!Parms                say "Machine #"i "Process #"j "WorkDir:",                    machine.i.!Process.j.!WorkDir                do k = 1 to machine.i.!Process.j.!Env.0                    say "Machine #"i "Process #"j "Env #"k" :",                        machine.i.!Process.j.!Env.k                end                do k = 1 to machine.i.!Process.j.!Var.0                    say "Machine #"i "Process #"j "Var #"k" :",                        machine.i.!Process.j.!Var.k                end            end        end    end  /* do for each machine */    sayend  /* end if debugging symbols */if workload = "" thendo    say "No WORKLOAD specified in" workloadScript    RETURN 1end/* Verify all PROCREFs point to something valid */do i = 1 to machine.0    do j = 1 to machine.i.!Process.0        if machine.i.!Process.j.!Type = "PROCREF" then        do            procIndex = 0            do k = 1 to process.0 while procIndex = 0                if TRANSLATE(machine.i.!Process.j.!ProcRef) =,                   TRANSLATE(process.k.!Name) then                do                    procIndex = k                    machine.i.!Process.j.!ProcRefIndex = k                end            end            if procIndex = 0 then            do                say "Unknown process reference,",                     machine.i.!Process.j.!ProcRef", for machine",                    machine.i.!Name                RETURN 1            end        end    end  /* do for each process */end  /* do for each machine */if CommandLineOptionTimes("UseHandle") \= 0 then    STAFHandle = CommandLineOptionValue("UseHandle")elsedo    call STAFRegister "Generic WorkLoad Processor"    if RESULT \= 0 then    do        say "Error registering with STAF, RC:" RESULT        RETURN 1    endendretCode = 0if CommandLineOptionTimes("Start") \= 0 then retCode = HandleStart()else if CommandLineOptionTimes("Stop") \= 0 then retCode = HandleStop()else if CommandLineOptionTimes("Free") \= 0 then retCode = HandleFree()else retCode = HandleQuery()if CommandLineOptionTimes("UseHandle") = 0 thendo    call STAFUnRegister    if RESULT \= 0 then        say "Error unregistering with STAF, RC:" RESULTendRETURN retCode/* End of main *//*******************************************************//* HandleStart - Handles starting up all the processes *//*******************************************************/HandleStart:  do i = 1 to machine.0      if UseItem("MACHINE", machine.i.!Name) = 0 then      do          if verboseMode then              say "Bypassing machine:" machine.i.!Name          ITERATE      end      if \quietMode then          say "Processing machine:" machine.i.!Name      /* Add all global and machine variables to machine */      setVars = ""      if startGlobalVars then      do          do j = 1 to var.0              setVars = setVars "VAR" STAFWrapData(var.j)          end      end      if startMachineVars then      do          do j = 1 to machine.i.!Var.0              setVars = setVars "VAR" STAFWrapData(machine.i.!Var.j)          end      end      if setVars \= "" then      do          call STAFSubmit machine.i.!Name, "VAR", "SET SYSTEM" setVars          if RESULT \= 0 then          do              say "Error setting variables on machine",                  machine.i.!Name", RC:" RESULT              if STAFResult \= "" then                  say "Additional Info:" STAFResult          end      end      if \startProcesses then ITERATE      /* Loop through and start each process */      do j = 1 to machine.i.!Process.0          if machine.i.!Process.j.!Type = "PROCREF" then              procStem = "process."machine.i.!Process.j.!ProcRefIndex          else              procStem = "machine.i.!Process.j"          if UseItem("PROCESS", VALUE(procStem".!Name")) = 0 then          do              if verboseMode then                  say "Bypassing process:" VALUE(procStem".!Name")              ITERATE          end          startCommand = "START ASYNC WORKLOAD" STAFWrapData(workload),                         "COMMAND" STAFWrapData(VALUE(procStem".!Command"))          if VALUE(procStem".!Title") \= "" then          do              startCommand = startCommand "TITLE",                             STAFWrapData(VALUE(procStem".!Title"))          end          if VALUE(procStem".!WorkDir") \= "" then          do              startCommand = startCommand "WORKDIR",                             STAFWrapData(VALUE(procStem".!WorkDir"))          end          if VALUE(procStem".!Parms") \= "" then          do              startCommand = startCommand "PARMS",                             STAFWrapData(VALUE(procStem".!Parms"))          end          do k = 1 to VALUE(procStem".!Env.0")              startCommand = startCommand "ENV",                             STAFWrapData(VALUE(procStem".!Env.k"))          end          do k = 1 to VALUE(procStem".!Var.0")              startCommand = startCommand "VAR",                             STAFWrapData(VALUE(procStem".!Var.k"))          end          call STAFSubmit machine.i.!Name, "PROCESS", startCommand          if RESULT \= 0 then          do              say "Error starting process on machine," machine.i.!Name",",                  "RC:" RESULT              if STAFResult \= "" then                  say "Additional Info:" STAFResult              say "Request was:"              say startCommand          end      end  /* for each process on the machine */  end  /* for each machine */  RETURN 0/* End of HandleStart *//***************************************************//* HandleStop - Handles stopping all the processes *//***************************************************/HandleStop:  do i = 1 to machine.0      if UseItem("MACHINE", machine.i.!Name) = 0 then      do          if verboseMode then              say "Bypassing machine:" machine.i.!Name          ITERATE      end      if \quietMode then          say "Processing machine:" machine.i.!Name      call STAFSubmit machine.i.!Name, "PROCESS", "QUERY WORKLOAD",                      STAFWrapData(workload)      if RESULT \= 0 then      do          say "Error querying processes on machine," machine.i.!Name",",              "RC:" RESULT          if STAFResult \= "" then              say "Additional Info:" STAFResult          ITERATE      end      parse var STAFResult . (LF) . (LF) data      handle.0 = 0      do while data \= ""          handle.0 = handle.0 + 1          handleIndex = handle.0          parse var data handle.handleIndex . (LF) data      end      if handle.0 > machine.i.!Process.0 then      do          say "Warning: There were" (handle.0 - machine.i.!Process.0),              "more processes running on this machine than were"          say "         defined in" workloadScript      end      else if handle.0 < machine.i.!Process.0 then      do          say "Warning: There were" (machine.i.!Process.0 - handle.0),              "less processes running on this machine than were"          say "         defined in" workloadScript      end      call STAFSubmit machine.i.!Name, "PROCESS", "STOP WORKLOAD",                      STAFWrapData(workload)      if RESULT \= 0 then      do          say "Error stopping processes on machine," machine.i.!Name",",              "RC:" RESULT          if STAFResult \= "" then              say "Additional Info:" STAFResult          ITERATE      end      if WORD(STAFResult, 1) \= WORD(STAFResult, 2) then      do          say "Note:" WORD(STAFResult, 2) - Word(STAFResult, 1) "processes",              "were already completed/stopped on machine," machine.i.!Name      end  end  /* for each machine */  RETURN 0/* End of HandleStop *//****************************************************//* HandleQuery - Handles querying all the processes *//****************************************************/HandleQuery:  do i = 1 to machine.0      if UseItem("MACHINE", machine.i.!Name) = 0 then      do          if verboseMode then              say "Bypassing machine:" machine.i.!Name          ITERATE      end      say      say machine.i.!Name      say COPIES('-', LENGTH(machine.i.!Name))      call STAFSubmit machine.i.!Name, "PROCESS", "QUERY WORKLOAD",                      STAFWrapData(workload)      if RESULT \= 0 then      do          say "Error querying processes on machine," machine.i.!Name",",              "RC:" RESULT          if STAFResult \= "" then              say "Additional Info:" STAFResult          ITERATE      end      parse var STAFResult . (LF) . (LF) data      handle.0 = 0      do while data \= ""          handle.0 = handle.0 + 1          handleIndex = handle.0          parse var data handle.handleIndex . (LF) data      end      if handle.0 > machine.i.!Process.0 then      do          say "Warning: There were" (handle.0 - machine.i.!Process.0),

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -