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