blob: 3e85901bb6dacea0d1553dcc732e99afefe876e5 [file] [log] [blame]
Jarkko Poyry3c827362014-09-02 11:48:52 +03001#ifndef _XSPOSIXTESTPROCESS_HPP
2#define _XSPOSIXTESTPROCESS_HPP
3/*-------------------------------------------------------------------------
4 * drawElements Quality Program Execution Server
5 * ---------------------------------------------
6 *
7 * Copyright 2014 The Android Open Source Project
8 *
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
12 *
13 * http://www.apache.org/licenses/LICENSE-2.0
14 *
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
20 *
21 *//*!
22 * \file
23 * \brief TestProcess implementation for Unix-like systems.
24 *//*--------------------------------------------------------------------*/
25
26#include "xsDefs.hpp"
27#include "xsTestProcess.hpp"
28#include "xsPosixFileReader.hpp"
29#include "deProcess.hpp"
30#include "deThread.hpp"
31
32#include <vector>
33#include <string>
34
35namespace xs
36{
37namespace posix
38{
39
40class CaseListWriter : public de::Thread
41{
42public:
43 CaseListWriter (void);
44 ~CaseListWriter (void);
45
46 void start (const char* caseList, deFile* dst);
47 void stop (void);
48
49 void run (void);
50
51private:
52 deFile* m_file;
53 std::vector<char> m_caseList;
54 bool m_run;
55};
56
57class PipeReader : public de::Thread
58{
59public:
60 PipeReader (ThreadedByteBuffer* dst);
61 ~PipeReader (void);
62
63 void start (deFile* file);
64 void stop (void);
65
66 void run (void);
67
68private:
69 deFile* m_file;
70 ThreadedByteBuffer* m_buf;
71};
72
73} // posix
74
75class PosixTestProcess : public TestProcess
76{
77public:
78 PosixTestProcess (void);
79 virtual ~PosixTestProcess (void);
80
81 virtual void start (const char* name, const char* params, const char* workingDir, const char* caseList);
82 virtual void terminate (void);
83 virtual void cleanup (void);
84
85 virtual bool isRunning (void);
86
87 virtual int getExitCode (void) const;
88
89 virtual int readTestLog (deUint8* dst, int numBytes);
90 virtual int readInfoLog (deUint8* dst, int numBytes) { return m_infoBuffer.tryRead(numBytes, dst); }
91
92private:
93 PosixTestProcess (const PosixTestProcess& other);
94 PosixTestProcess& operator= (const PosixTestProcess& other);
95
96 de::Process* m_process;
97 deUint64 m_processStartTime; //!< Used for determining log file timeout.
98 std::string m_logFileName;
99 ThreadedByteBuffer m_infoBuffer;
100
101 // Threads.
102 posix::CaseListWriter m_caseListWriter;
103 posix::PipeReader m_stdOutReader;
104 posix::PipeReader m_stdErrReader;
105 posix::FileReader m_logReader;
106};
107
108} // xs
109
110#endif // _XSPOSIXTESTPROCESS_HPP