Menu

STDOUTCONTAINS troubles

Help
Roach
2005-10-18
2013-04-25
  • Roach

    Roach - 2005-10-18

    Hi WebHiker,

    Just was wondering if you could take a quick peak at this code.  I am trying to check the standard output for the word "FAIL".  And if it is found, I want to return a status_code of 1 (which means fail).  I get a null pointer exception on the first line.

    CMDSTATUS(CMD_ID,status_code)

    IF(status_code=0)
        THEN
            CMDGETTRACE(CMD_ID)
            STDOUTCONTAINS(CMD_ID,result,FAIL)
            IF(result=1)
                status_code=1
                overall_result=1
            END
    END

     
    • Web Hiker

      Web Hiker - 2005-10-19

      Difficult to say what the error might be. Here are some things you can try :
      1)Insert a
      PRINT

       
      • Web Hiker

        Web Hiker - 2005-10-19

        Hi again,
        Difficult to say what the error might be. Sometimes the line number is not exactly where the error is, a problem from doing read-ahead stuff in the parser.
        Here are some things you can try :
        1)Insert a
          PRINT FAIL
        to be sure the value for FAIL has been set correctly
        2)Start the gui fom command line
        java -jar qatx.x.x.jar
        to see more detailed traces
        3)Check the example settings/default.func to see an example which works.

        By the way, did you know you can write your test scripts in a QAXML format too? There are some examples, but I think they are only in cvs. It might be easier for you, and there is much less ambiguity in the XML language.

        Hope this helps.

         
    • Roach

      Roach - 2005-10-21

      Hi WebHiker,

      I have looked through all of your examples looking for any  use of the CMDSTART and STDERRCONTAINS commands unfortunately I haven't been able to find any examples.  I also checked the QAXML examples but these were limited as well. 

      I have been trying to trouble shoot my code, and the problem I am having now is that whenever I use the STDERRCONTAINS command, I am receiving a '1' regardless.  I have changed to STRING which is checked for within the STDERR output to values that are either contained in the output or not, and each time I get a '1' as the RESULT.  In the documentation it says that if RESULT=1 then the STRING does exist in the output. 

      Do you have any working code that utilizes the STDERRCONTAINS command? Below is my code used

      CMDSTART(agent_id, CMD_ID, CMD_STRING)
      SLEEP(2)
      CMDSTOP(CMD_ID)

      CMDSTATUS(CMD_ID,STATUS_CODE)

      CMDGETTRACE(CMD_ID)
      STRING="_0_0_"

      STDERRCONTAINS(CMD_ID,RESULT,STRING)
      PRINT(STRING)
      PRINT(RESULT)

      In the above code, the PRINT RESULT will print a 1, and I know for a fact that the string "_0_0_ is no where in my output.

       
    • Roach

      Roach - 2005-10-21

      Hi WebHiker,

      Disregard the last post, I figured out that it was the output from the CMD_ID process that I was actually searching through, and not the output of my test (agent_cmd_id1)

      However now I am confused, how can you search through the output of your actual test and not from the process that you start with the CMDSTART command?  In your documentation it states that you must use CMDSTART to be able to use the CMDSTATUS and CMDGETTRACE.  When I use the CMDSTART command, it adds another "Agent" under the "Received from Agent" list. So I end up having two values under the "Received from Agent" list on the GUI, 1st one is "agent_cmd_id1 (this is the one I want to parse through the output) and the 2nd value is "CMD_ID" (I'm assuming this is from the CMDSTART command, this is the output that the STDERR command is actually parsing through however i want it to parse through the output from agent_cmd_id1).

      Hopefully you can give me some suggestions, I've looked through all your examples and haven't been able to find anything that uses the STDERR command.

       
      • Web Hiker

        Web Hiker - 2005-10-22

        I think there's a disconnect here.
        QAT is a test harness for executing tests on remote machines using the CMDSTART command..
        The tests you execute have their own std and stderr streams, which are recovered using the CMDGETTRACE once the process is finished (checking CMDSTATUS).

        What do you mean by "actual test" as opposed to something started with CMDSTART?
        You must make sure you only class CMDGETRACE and CMDSTATUS once for each matching CMDSTATUS.

        The examples are called stdoutcontains_test.qash and stderrcontains_test.qash which refenece the function in one of the include files.
        I think you are on the right track though. "Recieved from agent" count should match the number of "tests" you execued on the agents. I think you are calling one too many CMDSTATUS or CMDGETTRACE commands, which I suppose should throw an exception, but maybe it doesn't.

         
    • Roach

      Roach - 2005-10-24

      Hi Webhiker,

      I guess the main troubles I am encountering is starting/executing my test using the CMDSTART command.  My tests are already executing fine without using the CMDSTART command, however to parse the output I am receiving I must use the CMDSTART command.      

      When using the CMDSTART command, your documentation says that there are 3 required parameters:
      1) AGENT_ID
      2)CMD_ID
      3)CMD_STRING

      Now it is the CMD_STRING that I am having troubles with, I dont know exactly what value the CMD_STRING should be for it to execute my test (the one that is already being executed without using the CMDSTART command).

      Is this sometype of function that must defined somewhere else and then be referenced to in the CMD_STRING variable?

       
      • Web Hiker

        Web Hiker - 2005-10-24

        If you are not using CMDSTART, it means nothing is being executed on your agent.
        CMD_STRING is what will be run on the remote agent AGENT_ID. For example if CMD_STRING="dir" it will execute the "dir" command on the specified agent (assuming it's running on a windows machine. If you want to get the output of the dir command, you then need to call CMDSTATUS and CMDGETTRACE.

        In the examples packaged with QAT, I normally execute a Java test, so the CMD_STRING is simply something like "java -classpath='...' MyTest"

        But you can effectively execute any binary which is valid for the platform the java agent is running on.

         

Log in to post a comment.