13c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#ifndef _TCUANDROIDEXECSERVICE_HPP 23c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#define _TCUANDROIDEXECSERVICE_HPP 33c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*------------------------------------------------------------------------- 43c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * drawElements Quality Program Tester Core 53c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * ---------------------------------------- 63c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 73c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Copyright 2014 The Android Open Source Project 83c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 93c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Licensed under the Apache License, Version 2.0 (the "License"); 103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * you may not use this file except in compliance with the License. 113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * You may obtain a copy of the License at 123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * http://www.apache.org/licenses/LICENSE-2.0 143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Unless required by applicable law or agreed to in writing, software 163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * distributed under the License is distributed on an "AS IS" BASIS, 173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * See the License for the specific language governing permissions and 193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * limitations under the License. 203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*! 223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \file 233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \brief Android ExecService. 243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/ 253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuDefs.hpp" 273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "deThread.hpp" 283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "xsExecutionServer.hpp" 293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "xsPosixFileReader.hpp" 303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include <jni.h> 323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 333c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace tcu 343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 353c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace Android 363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 383c827367444ee418f129b2c238299f49d3264554Jarkko Poyryenum 393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DEFAULT_PORT = 50016, 413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DEFAULT_SOCKETFAMILY = DE_SOCKETFAMILY_INET4 423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 443c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass TestProcess : public xs::TestProcess 453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 463c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TestProcess (JavaVM* vm, jobject context); 483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ~TestProcess (void); 493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual void start (const char* name, const char* params, const char* workingDir, const char* caseList); 513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual void terminate (void); 523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual void cleanup (void); 533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual bool isRunning (void); 553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual int getExitCode (void) const; 563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual int readTestLog (deUint8* dst, int numBytes); 583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual int readInfoLog (deUint8* dst, int numBytes); 593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 603c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry JNIEnv* getCurrentThreadEnv (void); 623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry JavaVM* m_vm; 643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry jclass m_remoteCls; 653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry jobject m_remote; 663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry jmethodID m_start; 673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry jmethodID m_kill; 683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry jmethodID m_isRunning; 693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 m_launchTime; 713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 m_lastQueryTime; 723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool m_lastRunningStatus; 733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry xs::posix::FileReader m_logReader; 743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 763c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass ExecutionServer : public xs::ExecutionServer 773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 783c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ExecutionServer (JavaVM* vm, xs::TestProcess* testProcess, deSocketFamily family, int port, RunMode runMode); 803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry xs::ConnectionHandler* createHandler (de::Socket* socket, const de::SocketAddress& clientAddress); 813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 823c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry JavaVM* m_vm; 843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 863c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass ConnectionHandler : public xs::ExecutionRequestHandler 873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 883c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ConnectionHandler (JavaVM* vm, xs::ExecutionServer* server, de::Socket* socket); 903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void run (void); 913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 923c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry JavaVM* m_vm; 943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 963c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass ServerThread : public de::Thread 973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 983c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ServerThread (JavaVM* vm, xs::TestProcess* testProcess, deSocketFamily family, int port); 1003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void run (void); 1023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void stop (void); 1033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1043c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 1053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ExecutionServer m_server; 1063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 1073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1083c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass ExecService 1093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1103c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 1113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ExecService (JavaVM* vm, jobject context, deSocketFamily family = (deSocketFamily)DEFAULT_SOCKETFAMILY, int port = DEFAULT_PORT); 1123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ~ExecService (void); 1133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void start (void); 1153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void stop (void); 1163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1173c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 1183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ExecService (const ExecService& other); 1193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ExecService& operator= (const ExecService& other); 1203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TestProcess m_process; 1223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ServerThread m_thread; 1233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 1243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // Android 1263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // tcu 1273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#endif // _TCUANDROIDEXECSERVICE_HPP 129