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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>LCOV - .lcov.total - src/executor.cpp</title>
<link rel="stylesheet" type="text/css" href="../gcov.css">
</head>
<body>
<table width="100%" border=0 cellspacing=0 cellpadding=0>
<tr><td class="title">LCOV - code coverage report</td></tr>
<tr><td class="ruler"><img src="../glass.png" width=3 height=3 alt=""></td></tr>
<tr>
<td width="100%">
<table cellpadding=1 border=0 width="100%">
<tr>
<td width="10%" class="headerItem">Current view:</td>
<td width="35%" class="headerValue"><a href="../index.html">top level</a> - <a href="index.html">src</a> - executor.cpp<span style="font-size: 80%;"> (source / <a href="executor.cpp.func-sort-c.html">functions</a>)</span></td>
<td width="5%"></td>
<td width="15%"></td>
<td width="10%" class="headerCovTableHead">Hit</td>
<td width="10%" class="headerCovTableHead">Total</td>
<td width="15%" class="headerCovTableHead">Coverage</td>
</tr>
<tr>
<td class="headerItem">Test:</td>
<td class="headerValue">.lcov.total</td>
<td></td>
<td class="headerItem">Lines:</td>
<td class="headerCovTableEntry">4</td>
<td class="headerCovTableEntry">85</td>
<td class="headerCovTableEntryLo">4.7 %</td>
</tr>
<tr>
<td class="headerItem">Date:</td>
<td class="headerValue">2018-06-12 11:27:04</td>
<td></td>
<td class="headerItem">Functions:</td>
<td class="headerCovTableEntry">2</td>
<td class="headerCovTableEntry">12</td>
<td class="headerCovTableEntryLo">16.7 %</td>
</tr>
<tr><td><img src="../glass.png" width=3 height=3 alt=""></td></tr>
</table>
</td>
</tr>
<tr><td class="ruler"><img src="../glass.png" width=3 height=3 alt=""></td></tr>
</table>
<table cellpadding=0 cellspacing=0 border=0>
<tr>
<td><br></td>
</tr>
<tr>
<td>
<pre class="sourceHeading"> Line data Source code</pre>
<pre class="source">
<a name="1"><span class="lineNum"> 1 </span> : #include "executor.h"</a>
<span class="lineNum"> 2 </span> : #include "debughelper.h"
<span class="lineNum"> 3 </span> : #include <QCoreApplication>
<span class="lineNum"> 4 </span> : #include <QDir>
<span class="lineNum"> 5 </span> : #include <QTextCodec>
<span class="lineNum"> 6 </span> :
<span class="lineNum"> 7 </span> : /**
<span class="lineNum"> 8 </span> : * @brief Executor::Executor executes external applications
<a name="9"><span class="lineNum"> 9 </span> : * @param parent</a>
<span class="lineNum"> 10 </span> : */
<span class="lineNum"> 11 </span><span class="lineCov"> 20 : Executor::Executor(QObject *parent) : QObject(parent), running(false) {</span>
<span class="lineNum"> 12 </span><span class="lineCov"> 8 : connect(&m_process,</span>
<span class="lineNum"> 13 </span> : static_cast<void (QProcess::*)(int, QProcess::ExitStatus)>(
<span class="lineNum"> 14 </span> : &QProcess::finished),
<span class="lineNum"> 15 </span> : this,
<span class="lineNum"> 16 </span> : static_cast<void (Executor::*)(int, QProcess::ExitStatus)>(
<span class="lineNum"> 17 </span> : &Executor::finished));
<span class="lineNum"> 18 </span><span class="lineCov"> 8 : connect(&m_process, &QProcess::started, this, &Executor::starting);</span>
<span class="lineNum"> 19 </span><span class="lineCov"> 8 : }</span>
<span class="lineNum"> 20 </span> :
<span class="lineNum"> 21 </span> : /**
<a name="22"><span class="lineNum"> 22 </span> : * @brief Executor::executeNext consumes executable tasks from the queue</a>
<span class="lineNum"> 23 </span> : */
<span class="lineNum"> 24 </span><span class="lineNoCov"> 0 : void Executor::executeNext() {</span>
<span class="lineNum"> 25 </span><span class="lineNoCov"> 0 : if (!running) {</span>
<span class="lineNum"> 26 </span><span class="lineNoCov"> 0 : if (!m_execQueue.isEmpty()) {</span>
<span class="lineNum"> 27 </span><span class="lineNoCov"> 0 : const execQueueItem &i = m_execQueue.head();</span>
<span class="lineNum"> 28 </span><span class="lineNoCov"> 0 : running = true;</span>
<span class="lineNum"> 29 </span><span class="lineNoCov"> 0 : if (!i.workingDir.isEmpty())</span>
<span class="lineNum"> 30 </span><span class="lineNoCov"> 0 : m_process.setWorkingDirectory(i.workingDir);</span>
<span class="lineNum"> 31 </span><span class="lineNoCov"> 0 : m_process.start(i.app, i.args);</span>
<span class="lineNum"> 32 </span><span class="lineNoCov"> 0 : if (!i.input.isEmpty()) {</span>
<span class="lineNum"> 33 </span><span class="lineNoCov"> 0 : m_process.waitForStarted(-1);</span>
<span class="lineNum"> 34 </span><span class="lineNoCov"> 0 : QByteArray data = i.input.toUtf8();</span>
<span class="lineNum"> 35 </span><span class="lineNoCov"> 0 : if (m_process.write(data) != data.length())</span>
<span class="lineNum"> 36 </span> : dbg() << "Not all data written to process:" << i.id << " " << i.app;
<span class="lineNum"> 37 </span><span class="lineNoCov"> 0 : }</span>
<span class="lineNum"> 38 </span><span class="lineNoCov"> 0 : m_process.closeWriteChannel();</span>
<span class="lineNum"> 39 </span><span class="lineNoCov"> 0 : }</span>
<span class="lineNum"> 40 </span> : }
<span class="lineNum"> 41 </span><span class="lineNoCov"> 0 : }</span>
<span class="lineNum"> 42 </span> :
<span class="lineNum"> 43 </span> : /**
<span class="lineNum"> 44 </span> : * @brief Executor::execute execute an app
<span class="lineNum"> 45 </span> : * @param id
<span class="lineNum"> 46 </span> : * @param app
<span class="lineNum"> 47 </span> : * @param args
<span class="lineNum"> 48 </span> : * @param readStdout
<a name="49"><span class="lineNum"> 49 </span> : * @param readStderr</a>
<span class="lineNum"> 50 </span> : */
<span class="lineNum"> 51 </span><span class="lineNoCov"> 0 : void Executor::execute(int id, const QString &app, const QStringList &args,</span>
<span class="lineNum"> 52 </span> : bool readStdout, bool readStderr) {
<span class="lineNum"> 53 </span><span class="lineNoCov"> 0 : execute(id, QString(), app, args, QString(), readStdout, readStderr);</span>
<span class="lineNum"> 54 </span><span class="lineNoCov"> 0 : }</span>
<span class="lineNum"> 55 </span> :
<span class="lineNum"> 56 </span> : /**
<span class="lineNum"> 57 </span> : * @brief Executor::execute executes an app from a workDir
<span class="lineNum"> 58 </span> : * @param id
<span class="lineNum"> 59 </span> : * @param workDir
<span class="lineNum"> 60 </span> : * @param app
<span class="lineNum"> 61 </span> : * @param args
<span class="lineNum"> 62 </span> : * @param readStdout
<a name="63"><span class="lineNum"> 63 </span> : * @param readStderr</a>
<span class="lineNum"> 64 </span> : */
<span class="lineNum"> 65 </span><span class="lineNoCov"> 0 : void Executor::execute(int id, const QString &workDir, const QString &app,</span>
<span class="lineNum"> 66 </span> : const QStringList &args, bool readStdout,
<span class="lineNum"> 67 </span> : bool readStderr) {
<span class="lineNum"> 68 </span><span class="lineNoCov"> 0 : execute(id, workDir, app, args, QString(), readStdout, readStderr);</span>
<span class="lineNum"> 69 </span><span class="lineNoCov"> 0 : }</span>
<span class="lineNum"> 70 </span> :
<span class="lineNum"> 71 </span> : /**
<span class="lineNum"> 72 </span> : * @brief Executor::execute an app, takes input and presents it as stdin
<span class="lineNum"> 73 </span> : * @param id
<span class="lineNum"> 74 </span> : * @param app
<span class="lineNum"> 75 </span> : * @param args
<span class="lineNum"> 76 </span> : * @param input
<span class=
|