133 logging.debug(
"running test %s", self.name)
135 self.result = Result(
144 "TIMEOUT_DETAIL":
None,
150 r"from\s+Gaudi.Configuration\s+import\s+\*|"
151 "from\s+Configurables\s+import",
154 suffix, lang =
".py",
"python"
156 suffix, lang =
".opts",
"c++"
157 self.result[
"Options"] =
'<code lang="{}"><pre>{}</pre></code>'.
format(
158 lang, escape_for_html(self.options)
160 optionFile = tempfile.NamedTemporaryFile(suffix=suffix)
161 optionFile.file.write(self.options.encode(
"utf-8"))
166 self.environment.
get(
"BINARY_TAG")
167 or self.environment.
get(
"CMTCONFIG")
168 or platform.platform()
174 for prex
in self.unsupported_platforms
175 if re.search(prex, platform_id)
181 workdir = self.workdir
182 if self.use_temp_dir:
183 if self._common_tmpdir:
184 workdir = self._common_tmpdir
186 workdir = tempfile.mkdtemp()
190 if self.program !=
"":
192 elif "GAUDIEXE" in self.environment:
193 prog = self.environment[
"GAUDIEXE"]
197 prog_ext = os.path.splitext(prog)[1]
198 if prog_ext
not in [
".exe",
".py",
".bat"]:
202 prog =
which(prog)
or prog
204 args = list(
map(RationalizePath, self.args))
206 if prog_ext ==
".py":
217 logging.debug(
"executing %r in %s", params, workdir)
219 params, stdout=PIPE, stderr=PIPE, env=self.environment
221 logging.debug(
"(pid: %d)", self.proc.pid)
222 out, err = self.proc.communicate()
223 self.out = out.decode(
"utf-8", errors=
"backslashreplace")
224 self.err = err.decode(
"utf-8", errors=
"backslashreplace")
226 thread = threading.Thread(target=target)
229 thread.join(self.timeout)
231 if thread.is_alive():
232 logging.debug(
"time out in test %s (pid %d)", self.name, self.proc.pid)
239 "--eval-command=thread apply all backtrace",
241 gdb = Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=STDOUT)
242 self.stack_trace = gdb.communicate()[0].decode(
243 "utf-8", errors=
"backslashreplace"
248 if thread.is_alive():
250 self.causes.append(
"timeout")
252 self.returnedCode = self.proc.returncode
253 if self.returnedCode != SKIP_RETURN_CODE:
255 f
"completed test {self.name} with returncode = {self.returnedCode}"
257 logging.debug(
"validating test...")
258 self.result, self.causes = self.ValidateOutput(
259 stdout=self.out, stderr=self.err, result=self.result
262 logging.debug(f
"skipped test {self.name}")
263 self.status =
"skipped"
266 if self.use_temp_dir
and not self._common_tmpdir:
267 shutil.rmtree(workdir,
True)
269 os.chdir(self.basedir)
271 if self.status !=
"skipped":
273 if self.signal
is not None:
274 if int(self.returnedCode) != -int(self.signal):
275 self.causes.append(
"exit code")
277 elif self.exit_code
is not None:
278 if int(self.returnedCode) != int(self.exit_code):
279 self.causes.append(
"exit code")
281 elif self.returnedCode != 0:
282 self.causes.append(
"exit code")
285 self.status =
"failed"
287 self.status =
"passed"
290 self.status =
"skipped"
292 logging.debug(
"%s: %s", self.name, self.status)
294 "Exit Code":
"returnedCode",
297 "Runtime Environment":
"environment",
300 "Program Name":
"program",
302 "Validator":
"validator",
303 "Output Reference File":
"reference",
304 "Error Reference File":
"error_reference",
307 "Unsupported Platforms":
"unsupported_platforms",
308 "Stack Trace":
"stack_trace",
311 (key, getattr(self, attr))
312 for key, attr
in field_mapping.items()
313 if getattr(self, attr)
322 resultDict.extend(self.result.annotations.items())
324 resultDict = dict(resultDict)
327 if "Validator" in resultDict:
328 resultDict[
"Validator"] =
'<code lang="{}"><pre>{}</pre></code>'.
format(
329 "python", escape_for_html(resultDict[
"Validator"])