Package qat.common

Examples of qat.common.TestObject


    if (!inEvaluationMode()) {
      try {
        /* Open a socket with the Agent */
        openAgentSocket();

        TestObject test = new TestObject(Integer.toString(uniqueID),
            command,
            environment,
            agentWorkDir,
            0); // timeout
        /* send the DAEMONSTART_REQUEST command, and the TestObject,
       and wait for acknowledgment */
        outStr.writeInt(ProtocolConstants.DAEMONSTART_REQUEST);
        test.writeObject(outStr);
        outStr.flush();

        expectCode(ProtocolConstants.RESPONSE_PROCESSING,RESPONSE_PROCESSING_ERROR);       
        expectCode(ProtocolConstants.RESPONSE_FINISHED_OK,RESPONSE_OK_ERROR);
      }
 
View Full Code Here


    if (!inEvaluationMode()) {
      try {
        /* Open a socket with the Agent */
        openAgentSocket();

        TestObject test = (TestObject)executeRequests.get(new Integer(processID));

        /* send the CMDGETTRACE command, and the TestObject,
       and wait for acknowledgment */
        outStr.writeInt(ProtocolConstants.CMDGETTRACE_REQUEST);
        test.writeObject(outStr);
        outStr.flush();

        expectCode(ProtocolConstants.RESPONSE_PROCESSING,RESPONSE_PROCESSING_ERROR);       

        // recieve the stdout and stderr files
View Full Code Here

    if (!inEvaluationMode()) {
      try {
        /* Open a socket with the Agent */
        openAgentSocket();

        TestObject test = (TestObject)executeRequests.get(new Integer(processID));

        /* send the CMDCLEAN command, and the TestObject,
       and wait for acknowledgment */
        outStr.writeInt(ProtocolConstants.CMDCLEAN_REQUEST);
        test.writeObject(outStr);
        outStr.flush();

        expectCode(ProtocolConstants.RESPONSE_PROCESSING,RESPONSE_PROCESSING_ERROR);       
        expectCode(ProtocolConstants.RESPONSE_FINISHED_OK,RESPONSE_OK_ERROR);

 
View Full Code Here

    return Integer.toString(status);
  }

  public String[] GETTRACEPATHS(String processID) throws Exception {   
    String result[] = new String[3];
    TestObject test = (TestObject)executeRequests.get(new Integer(processID));
    if (!inEvaluationMode()) {   
      try {
        /* Open a socket with the Agent */
        openAgentSocket();

        /* send the GETTRACEPATHS command, and the TestObject,
       and wait for acknowledgment */
        outStr.writeInt(ProtocolConstants.GETTRACEPATHS_REQUEST);

        test.writeObject(outStr);
        outStr.flush();

        expectCode(ProtocolConstants.RESPONSE_PROCESSING,RESPONSE_PROCESSING_ERROR);

        expectCode(ProtocolConstants.RESPONSE_FINISHED_OK,"No process matching this Id was found");

        // recieve the stdout and stderr files
        result[0] = inStr.readUTF();
        result[1] = inStr.readUTF();
        result[2] = inStr.readUTF();

        expectCode(ProtocolConstants.RESPONSE_FINISHED_OK,RESPONSE_OK_ERROR);
      }
      finally {
        /* close socket and return the result */
        closeAgentSocket();
      }
    }
    else {   
      result[0] = test.getEnvFileName().toString();
      result[1] = test.getStdOutFileName().toString();
      result[2] = test.getStdErrFileName().toString();
    }

    return result;
  }
View Full Code Here

  /**
   * This method is responsible for executing a daemon on the agent.
   */
  private void processDAEMONSTART_REQUEST(DataInputStream in, DataOutputStream out) {
    TestObject test=new TestObject();
    String eol = System.getProperty("line.separator");
    try {
      ConsoleServer.debugMsg("Processing DAEMONSTART_REQUEST",1);
      // read the serialized TestObject which we will execute
      test.readObject(in);
      // now send a signal indicating we are processing the request
      sendSignal(out,ProtocolConstants.RESPONSE_PROCESSING);
      // create details about our agent to use in the trace file created by the ExecProcess object
      String details = "Local Address : "+socket.getLocalAddress().toString()+eol+
      "Port Number : "+portNo+eol+
View Full Code Here

  /**
   * This method is responsible for executing a command on the agent.
   */
  private void processCMDSTART_REQUEST(DataInputStream in, DataOutputStream out) {
    TestObject test=new TestObject();
    String eol = System.getProperty("line.separator");
    try {
      ConsoleServer.debugMsg("Processing CMDSTART_REQUEST",1);
      // read the serialized TestObject which we will execute
      test.readObject(in);
      // now send a signal indicating we are processing the request
      sendSignal(out,ProtocolConstants.RESPONSE_PROCESSING);
      // create details about our agent to use in the trace file created by the ExecProcess object
      String details = "Local Address : "+socket.getLocalAddress().toString()+eol+
      "Port Number : "+portNo+eol+
View Full Code Here

   * This method is resonsible for stopping a previously started command on the agent.
   * If the process has finished, it will return the exit code, else it will return
   * a negative value if the process had to be killed.
   */
  private int processCMDSTOP_REQUEST(DataInputStream in, DataOutputStream out) {
    TestObject test=new TestObject();
    int status=0;
    try {
      ConsoleServer.debugMsg("Processing CMDSTOP_REQUEST",1);
      // read the serialized TestObject which we will stop
      test.readObject(in);
      // now send a signal indicating we are processing the request
      sendSignal(out,ProtocolConstants.RESPONSE_PROCESSING);
      // find the exit code, blocking if neccesary
      ExecProcess proc;
      boolean wasRunning = false;
      for (int i = 0; i < processPool.size(); i++) {
        try {
          proc = (ExecProcess)processPool.get(i);
        }
        catch (java.lang.NoSuchMethodError ex) {
          // does not exist in jdk1.1.x
          proc = (ExecProcess)processPool.elementAt(i);
        }
        // check for any instance of test running with the same id
        if (proc.getTestObject().getTestID().equals(test.getTestID())) {
          ConsoleServer.debugMsg("Stopping process ",5);
          wasRunning = true;

          // flush and close it's output streams
          proc.interrupt();

          // get it's status if it has finished
          status = proc.checkExitValue();

          sendSignal(out,status);
          break;
        }
      }
      if (!wasRunning) {
        // the process was never started, so assume it failed
        ConsoleServer.debugMsg("Process was not running :"+test.getTestID(),1);     
      }
      // now send a signal indicating we have finished
      sendSignal(out,ProtocolConstants.RESPONSE_FINISHED_OK);
    }
    catch (Exception e) {
View Full Code Here

   * This method is resonsible for retrieving the status of a previously executed processes on the agent.
   * It will block until the process exits, or the timeout value specified in the CMDSTART method has been
   * reached.
   */
  private void processCMDSTATUS_REQUEST(DataInputStream in, DataOutputStream out) {
    TestObject test=new TestObject();
    try {
      ConsoleServer.debugMsg("Processing CMDSTATUS_REQUEST",1);
      // read the serialized TestObject that we want the exit code of
      test.readObject(in);
      // now send a signal indicating we are processing the request
      sendSignal(out,ProtocolConstants.RESPONSE_PROCESSING);
      // find the exit code, blocking if neccesary
      ExecProcess proc;
      boolean wasRunning = false;
      for (int i = 0; i < processPool.size(); i++) {
        try {
          proc = (ExecProcess)processPool.get(i);
        }
        catch (java.lang.NoSuchMethodError ex) {
          // does not exist in jdk1.1.x
          proc = (ExecProcess)processPool.elementAt(i);
        }
        // check for any instance of test running with the same name
        if (proc.getTestObject().getTestID().equals(test.getTestID())) {
          ConsoleServer.debugMsg("Returning CMDSTATUS value :"+proc.getExitValue(),5);
          out.writeInt(proc.getExitValue());
          wasRunning = true;
          // flush and close it's output streams
          proc.interrupt();
          // don't remove until it's cleaned :processPool.removeElementAt(i);
          break;
        }
      }
      if (!wasRunning) {
        // the process was never started, so assume it failed
        ConsoleServer.debugMsg("Process was never started :"+test.getTestID(),1);     
        out.writeInt(ProtocolConstants.FAILED);
      }
      // now send a signal indicating we have finished
      sendSignal(out,ProtocolConstants.RESPONSE_FINISHED_OK);
    }
View Full Code Here

  /**
   * This method is resonsible for cleaning all files created by running a process.
   */
  private void processCMDCLEAN_REQUEST(DataInputStream in, DataOutputStream out) {
    TestObject test=new TestObject();
    try {
      ConsoleServer.debugMsg("Processing CMDCLEAN_REQUEST",1);
      // read the serialized TestObject which we want the exit code of
      test.readObject(in);
      // now send a signal indicating we are processing the request
      sendSignal(out,ProtocolConstants.RESPONSE_PROCESSING);
      // find the exit code, blocking if neccesary
      ExecProcess proc;
      boolean exists = false;
      for (int i = 0; i < processPool.size(); i++) {
        try {
          proc = (ExecProcess)processPool.get(i);
        }
        catch (java.lang.NoSuchMethodError ex) {
          // does not exist in jdk1.1.x
          proc = (ExecProcess)processPool.elementAt(i);
        }
        // check for any instance of test running with the same name
        if (proc.getTestObject().getTestID().equals(test.getTestID())) {
          try {
            ConsoleServer.debugMsg("Deleting :"+proc.getTestObject().getEnvFileName(),5)
            Utils.delete(proc.getTestObject().getEnvFileName());
          }
          catch (IOException e) {
            ConsoleServer.debugMsg("No environment file was found :"+e,1);     
          }
          try {
            ConsoleServer.debugMsg("Deleting :"+proc.getTestObject().getStdOutFileName(),5)
            Utils.delete(proc.getTestObject().getStdOutFileName());
          }
          catch (IOException e) {
            ConsoleServer.debugMsg("No stdout file was found :"+e,1);     
          }
          try {
            ConsoleServer.debugMsg("Deleting :"+proc.getTestObject().getStdErrFileName(),5)
            Utils.delete(proc.getTestObject().getStdErrFileName());
          }
          catch (IOException e) {
            ConsoleServer.debugMsg("No stderr file was found :"+e,1);     
          }           
          exists = true;
          // flush and close it's output streams by doing a STOP command
          proc.interrupt();
          try {
            processPool.remove(i);
          }
          catch (java.lang.NoSuchMethodError ex) {
            // does not exist in jdk1.1.x
            processPool.removeElementAt(i);
          }
          break;
        }
      }
      if (!exists) {
        // the process was never started, so assume it failed
        ConsoleServer.debugMsg("Process was not running :"+test.getTestID(),1);     
        out.writeInt(ProtocolConstants.FAILED);
      }
      else {
        // now send a signal indicating we have finished
        sendSignal(out,ProtocolConstants.RESPONSE_FINISHED_OK);
View Full Code Here

   */
  private void processCMDGETTRACE_REQUEST(DataInputStream in, DataOutputStream out) {
    try {
      ConsoleServer.debugMsg("Processing CMDGETTRACE_REQUEST",1);
      // read the serialized TestObject which we want the exit code of
      TestObject test = new TestObject();
      test.readObject(in);
      // now send a signal indicating we are processing the request
      sendSignal(out,ProtocolConstants.RESPONSE_PROCESSING);
      // find the exit code, blocking if neccesary
      ExecProcess proc;
      boolean wasRun = false;
      for (int i = 0; i < processPool.size(); i++) {
        try {
          proc = (ExecProcess)processPool.get(i);
        }
        catch (java.lang.NoSuchMethodError ex) {
          // does not exist in jdk1.1.x
          proc = (ExecProcess)processPool.elementAt(i);
        }
        // check for any instance of test running with the same name
        if (proc.getTestObject().getTestID().equals(test.getTestID())) {
          wasRun = true;
          // ---- send the env, stdout and stderr files --------------------
          sendFile(proc.getTestObject().getEnvFileName(), out);
          sendFile(proc.getTestObject().getStdOutFileName(), out);
          sendFile(proc.getTestObject().getStdErrFileName(), out);
          // ----------------------------------
          break;
        }
      }
      if (!wasRun) {
        // the process was never started, so assume it failed
        ConsoleServer.debugMsg("Process was never started :"+test.getTestID(),1);     
        out.writeInt(ProtocolConstants.FAILED);
      }
      // now send a signal indicating we have finished
      sendSignal(out,ProtocolConstants.RESPONSE_FINISHED_OK);
    }
View Full Code Here

TOP

Related Classes of qat.common.TestObject

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.