◆ _new_backslashreplace_errors()
def GaudiTesting.BaseTest._new_backslashreplace_errors |
( |
|
exc | ) |
|
|
private |
Definition at line 31 of file BaseTest.py.
32 if isinstance(exc, UnicodeDecodeError):
33 code =
hex(ord(exc.object[exc.start]))
34 return (
"\\" + code[1:], exc.start + 1)
36 return backslashreplace_errors(exc)
◆ _parseTTreeSummary()
def GaudiTesting.BaseTest._parseTTreeSummary |
( |
|
lines, |
|
|
|
pos |
|
) |
| |
|
private |
Parse the TTree summary table in lines, starting from pos.
Returns a tuple with the dictionary with the digested informations and the
position of the first line after the summary.
Definition at line 1275 of file BaseTest.py.
1277 Parse the TTree summary table in lines, starting from pos.
1278 Returns a tuple with the dictionary with the digested informations and the
1279 position of the first line after the summary.
1286 return [f.strip()
for f
in l.strip(
"*\n").split(
":", 2)]
1291 cols = splitcols(ll[0])
1295 r[
"Name"], r[
"Title"] = cols[1:]
1300 r[
"Title"] = ll[1].strip(
"*\n").split(
"|")[1].strip()
1304 cols = splitcols(ll[1 + delta_i])
1305 r[
"Entries"] = int(cols[1])
1307 sizes = cols[2].split()
1308 r[
"Total size"] = int(sizes[2])
1309 if sizes[-1] ==
"memory":
1312 r[
"File size"] = int(sizes[-1])
1314 cols = splitcols(ll[2 + delta_i])
1315 sizes = cols[2].split()
1316 if cols[0] ==
"Baskets":
1317 r[
"Baskets"] = int(cols[1])
1318 r[
"Basket size"] = int(sizes[2])
1319 r[
"Compression"] = float(sizes[-1])
1323 def nextblock(lines, i):
1325 dots = re.compile(
r"^\.+$")
1326 stars = re.compile(
r"^\*+$")
1330 and not dots.match(lines[i + delta_i][1:-1])
1331 and not stars.match(lines[i + delta_i])
1336 if i < (count - 3)
and lines[i].startswith(
"*Tree"):
1337 i_nextblock = nextblock(lines, i)
1338 result = parseblock(lines[i:i_nextblock])
1339 result[
"Branches"] = {}
1341 while i < (count - 3)
and lines[i].startswith(
"*Br"):
1342 if i < (count - 2)
and lines[i].startswith(
"*Branch "):
1346 i_nextblock = nextblock(lines, i)
1347 if i_nextblock >= count:
1349 branch = parseblock(lines[i:i_nextblock])
1350 result[
"Branches"][branch[
"Name"]] = branch
◆ cmpTreesDicts()
def GaudiTesting.BaseTest.cmpTreesDicts |
( |
|
reference, |
|
|
|
to_check, |
|
|
|
ignore = None |
|
) |
| |
Check that all the keys in reference are in to_check too, with the same value.
If the value is a dict, the function is called recursively. to_check can
contain more keys than reference, that will not be tested.
The function returns at the first difference found.
Definition at line 1227 of file BaseTest.py.
1229 Check that all the keys in reference are in to_check too, with the same value.
1230 If the value is a dict, the function is called recursively. to_check can
1231 contain more keys than reference, that will not be tested.
1232 The function returns at the first difference found.
1237 ignore_re = re.compile(ignore)
1238 keys = [key
for key
in reference
if not ignore_re.match(key)]
1240 keys = reference.keys()
1244 if (
type(reference[k])
is dict)
and (
type(to_check[k])
is dict):
1247 failed = fail_keys =
cmpTreesDicts(reference[k], to_check[k], ignore)
1250 failed = to_check[k] != reference[k]
1255 fail_keys.insert(0, k)
◆ dumpProcs()
def GaudiTesting.BaseTest.dumpProcs |
( |
|
name | ) |
|
helper to debug GAUDI-1084, dump the list of processes
Definition at line 63 of file BaseTest.py.
64 """helper to debug GAUDI-1084, dump the list of processes"""
65 from getpass
import getuser
67 if "WORKSPACE" in os.environ:
68 p = Popen([
"ps",
"-fH",
"-U", getuser()], stdout=PIPE)
69 with open(os.path.join(os.environ[
"WORKSPACE"], name),
"wb")
as f:
70 f.write(p.communicate()[0])
◆ findHistosSummaries()
def GaudiTesting.BaseTest.findHistosSummaries |
( |
|
stdout | ) |
|
Scan stdout to find ROOT TTree summaries and digest them.
Definition at line 1424 of file BaseTest.py.
1426 Scan stdout to find ROOT TTree summaries and digest them.
1428 outlines = stdout.splitlines()
1429 nlines = len(outlines) - 1
1437 match = h_count_re.search(outlines[pos])
1438 while pos < nlines
and not match:
1440 match = h_count_re.search(outlines[pos])
1443 summaries.update(summ)
◆ findTTreeSummaries()
def GaudiTesting.BaseTest.findTTreeSummaries |
( |
|
stdout | ) |
|
Scan stdout to find ROOT TTree summaries and digest them.
Definition at line 1205 of file BaseTest.py.
1207 Scan stdout to find ROOT TTree summaries and digest them.
1209 stars = re.compile(
r"^\*+$")
1210 outlines = stdout.splitlines()
1211 nlines = len(outlines)
1217 while i < nlines
and not stars.match(outlines[i]):
1222 trees[tree[
"Name"]] = tree
◆ getCmpFailingValues()
def GaudiTesting.BaseTest.getCmpFailingValues |
( |
|
reference, |
|
|
|
to_check, |
|
|
|
fail_path |
|
) |
| |
Definition at line 1260 of file BaseTest.py.
1266 if c
is None or r
is None:
1268 return (fail_path, r, c)
◆ GetPlatform()
def GaudiTesting.BaseTest.GetPlatform |
( |
|
self | ) |
|
Return the platform Id defined in CMTCONFIG or SCRAM_ARCH.
Definition at line 1447 of file BaseTest.py.
1449 Return the platform Id defined in CMTCONFIG or SCRAM_ARCH.
1453 if "BINARY_TAG" in os.environ:
1454 arch = os.environ[
"BINARY_TAG"]
1455 elif "CMTCONFIG" in os.environ:
1456 arch = os.environ[
"CMTCONFIG"]
1457 elif "SCRAM_ARCH" in os.environ:
1458 arch = os.environ[
"SCRAM_ARCH"]
1459 elif os.environ.get(
"ENV_CMAKE_BUILD_TYPE",
"")
in (
1465 elif os.environ.get(
"ENV_CMAKE_BUILD_TYPE",
"")
in (
◆ isWinPlatform()
def GaudiTesting.BaseTest.isWinPlatform |
( |
|
self | ) |
|
Return True if the current platform is Windows.
This function was needed because of the change in the CMTCONFIG format,
from win32_vc71_dbg to i686-winxp-vc9-dbg.
Definition at line 1475 of file BaseTest.py.
1477 Return True if the current platform is Windows.
1479 This function was needed because of the change in the CMTCONFIG format,
1480 from win32_vc71_dbg to i686-winxp-vc9-dbg.
1483 return "winxp" in platform
or platform.startswith(
"win")
◆ kill_tree()
def GaudiTesting.BaseTest.kill_tree |
( |
|
ppid, |
|
|
|
sig |
|
) |
| |
Send a signal to a process and all its child processes (starting from the
leaves).
Definition at line 73 of file BaseTest.py.
75 Send a signal to a process and all its child processes (starting from the
78 log = logging.getLogger(
"kill_tree")
79 ps_cmd = [
"ps",
"--no-headers",
"-o",
"pid",
"--ppid", str(ppid)]
82 get_children = Popen(ps_cmd, stdout=PIPE, stderr=PIPE, env={})
83 children =
map(int, get_children.communicate()[0].split())
84 for child
in children:
87 log.debug(
"killing process %d", ppid)
89 except OSError
as err:
92 log.debug(
"no such process %d", ppid)
◆ parseHistosSummary()
def GaudiTesting.BaseTest.parseHistosSummary |
( |
|
lines, |
|
|
|
pos |
|
) |
| |
Extract the histograms infos from the lines starting at pos.
Returns the position of the first line after the summary block.
Definition at line 1356 of file BaseTest.py.
1358 Extract the histograms infos from the lines starting at pos.
1359 Returns the position of the first line after the summary block.
1362 h_table_head = re.compile(
1363 r'SUCCESS\s+(1D|2D|3D|1D profile|2D profile) histograms in directory\s+"(\w*)"'
1365 h_short_summ = re.compile(
r"ID=([^\"]+)\s+\"([^\"]+)\"\s+(.*)")
1370 m = h_count_re.search(lines[pos])
1371 name = m.group(1).strip()
1372 total = int(m.group(2))
1374 for k, v
in [x.split(
"=")
for x
in m.group(3).split()]:
1377 header[
"Total"] = total
1381 m = h_table_head.search(lines[pos])
1384 t = t.replace(
" profile",
"Prof")
1391 if l.startswith(
" | ID"):
1393 titles = [x.strip()
for x
in l.split(
"|")][1:]
1395 while pos < nlines
and lines[pos].startswith(
" |"):
1397 values = [x.strip()
for x
in l.split(
"|")][1:]
1399 for i
in range(len(titles)):
1400 hcont[titles[i]] = values[i]
1401 cont[hcont[
"ID"]] = hcont
1403 elif l.startswith(
" ID="):
1404 while pos < nlines
and lines[pos].startswith(
" ID="):
1406 x.strip()
for x
in h_short_summ.search(lines[pos]).groups()
1408 cont[values[0]] = values
1411 raise RuntimeError(
"Cannot understand line %d: '%s'" % (pos, l))
1415 summ[d][
"header"] = header
1420 summ[name] = {
"header": header}
◆ RationalizePath()
def GaudiTesting.BaseTest.RationalizePath |
( |
|
p | ) |
|
Function used to normalize the used path
Definition at line 729 of file BaseTest.py.
731 Function used to normalize the used path
733 newPath = os.path.normpath(os.path.expandvars(p))
734 if os.path.exists(newPath):
735 p = os.path.realpath(newPath)
◆ ROOT6WorkAroundEnabled()
def GaudiTesting.BaseTest.ROOT6WorkAroundEnabled |
( |
|
id = None | ) |
|
◆ sanitize_for_xml()
def GaudiTesting.BaseTest.sanitize_for_xml |
( |
|
data | ) |
|
Take a string with invalid ASCII/UTF characters and quote them so that the
string can be used in an XML text.
>>> sanitize_for_xml('this is \x1b')
'this is [NON-XML-CHAR-0x1B]'
Definition at line 46 of file BaseTest.py.
48 Take a string with invalid ASCII/UTF characters and quote them so that the
49 string can be used in an XML text.
51 >>> sanitize_for_xml('this is \x1b')
52 'this is [NON-XML-CHAR-0x1B]'
54 bad_chars = re.compile(
"[\x00-\x08\x0b\x0c\x0e-\x1F\uD800-\uDFFF\uFFFE\uFFFF]")
58 return "".join(
"[NON-XML-CHAR-0x%2X]" % ord(c)
for c
in match.group())
60 return bad_chars.sub(quote, data)
◆ which()
def GaudiTesting.BaseTest.which |
( |
|
executable | ) |
|
Locates an executable in the executables path ($PATH) and returns the full
path to it. An application is looked for with or without the '.exe' suffix.
If the executable cannot be found, None is returned
Definition at line 739 of file BaseTest.py.
739 def which(executable):
741 Locates an executable in the executables path ($PATH) and returns the full
742 path to it. An application is looked for with or without the '.exe' suffix.
743 If the executable cannot be found, None is returned
745 if os.path.isabs(executable):
746 if not os.path.isfile(executable):
747 if executable.endswith(
".exe"):
748 if os.path.isfile(executable[:-4]):
749 return executable[:-4]
751 executable = os.path.split(executable)[1]
754 for d
in os.environ.get(
"PATH").split(os.pathsep):
755 fullpath = os.path.join(d, executable)
756 if os.path.isfile(fullpath):
758 elif executable.endswith(
".exe")
and os.path.isfile(fullpath[:-4]):
◆ __processLine__
GaudiTesting.BaseTest.__processLine__ |
|
private |
◆ h_count_re
GaudiTesting.BaseTest.h_count_re |
◆ lineSkipper
GaudiTesting.BaseTest.lineSkipper |
◆ maskPointers
GaudiTesting.BaseTest.maskPointers |
◆ normalizeDate
GaudiTesting.BaseTest.normalizeDate |
◆ normalizeEOL
GaudiTesting.BaseTest.normalizeEOL |
◆ normalizeExamples
GaudiTesting.BaseTest.normalizeExamples |
◆ regexps
list GaudiTesting.BaseTest.regexps |
◆ SKIP_RETURN_CODE
GaudiTesting.BaseTest.SKIP_RETURN_CODE |
◆ skipEmptyLines
GaudiTesting.BaseTest.skipEmptyLines |
MsgStream & hex(MsgStream &log)
def _parseTTreeSummary(lines, pos)
def sanitize_for_xml(data)
def getCmpFailingValues(reference, to_check, fail_path)
def _new_backslashreplace_errors(exc)
struct GAUDI_API map
Parametrisation class for map-like implementation.
def parseHistosSummary(lines, pos)
def cmpTreesDicts(reference, to_check, ignore=None)
def findHistosSummaries(stdout)
def findTTreeSummaries(stdout)
def ROOT6WorkAroundEnabled(id=None)
decltype(auto) range(Args &&... args)
Zips multiple containers together to form a single range.