◆ _new_backslashreplace_errors()
def GaudiTesting.BaseTest._new_backslashreplace_errors |
( |
|
exc | ) |
|
|
private |
Definition at line 38 of file BaseTest.py.
39 if isinstance(exc, UnicodeDecodeError):
40 code =
hex(ord(exc.object[exc.start]))
41 return (
"\\" + code[1:], exc.start + 1)
43 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 1280 of file BaseTest.py.
1282 Parse the TTree summary table in lines, starting from pos.
1283 Returns a tuple with the dictionary with the digested informations and the
1284 position of the first line after the summary.
1291 return [f.strip()
for f
in l.strip(
"*\n").split(
":", 2)]
1295 cols = splitcols(ll[0])
1296 r[
"Name"], r[
"Title"] = cols[1:]
1298 cols = splitcols(ll[1])
1299 r[
"Entries"] = int(cols[1])
1301 sizes = cols[2].split()
1302 r[
"Total size"] = int(sizes[2])
1303 if sizes[-1] ==
"memory":
1306 r[
"File size"] = int(sizes[-1])
1308 cols = splitcols(ll[2])
1309 sizes = cols[2].split()
1310 if cols[0] ==
"Baskets":
1311 r[
"Baskets"] = int(cols[1])
1312 r[
"Basket size"] = int(sizes[2])
1313 r[
"Compression"] = float(sizes[-1])
1316 if i < (count - 3)
and lines[i].startswith(
"*Tree"):
1317 result = parseblock(lines[i : i + 3])
1318 result[
"Branches"] = {}
1320 while i < (count - 3)
and lines[i].startswith(
"*Br"):
1321 if i < (count - 2)
and lines[i].startswith(
"*Branch "):
1325 branch = parseblock(lines[i : i + 3])
1326 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 1232 of file BaseTest.py.
1234 Check that all the keys in reference are in to_check too, with the same value.
1235 If the value is a dict, the function is called recursively. to_check can
1236 contain more keys than reference, that will not be tested.
1237 The function returns at the first difference found.
1242 ignore_re = re.compile(ignore)
1243 keys = [key
for key
in reference
if not ignore_re.match(key)]
1245 keys = reference.keys()
1249 if (
type(reference[k])
is dict)
and (
type(to_check[k])
is dict):
1252 failed = fail_keys =
cmpTreesDicts(reference[k], to_check[k], ignore)
1255 failed = to_check[k] != reference[k]
1260 fail_keys.insert(0, k)
◆ dumpProcs()
def GaudiTesting.BaseTest.dumpProcs |
( |
|
name | ) |
|
helper to debug GAUDI-1084, dump the list of processes
Definition at line 70 of file BaseTest.py.
71 """helper to debug GAUDI-1084, dump the list of processes"""
72 from getpass
import getuser
74 if "WORKSPACE" in os.environ:
75 p = Popen([
"ps",
"-fH",
"-U", getuser()], stdout=PIPE)
76 with open(os.path.join(os.environ[
"WORKSPACE"], name),
"wb")
as f:
77 f.write(p.communicate()[0])
◆ findHistosSummaries()
def GaudiTesting.BaseTest.findHistosSummaries |
( |
|
stdout | ) |
|
Scan stdout to find ROOT TTree summaries and digest them.
Definition at line 1400 of file BaseTest.py.
1402 Scan stdout to find ROOT TTree summaries and digest them.
1404 outlines = stdout.splitlines()
1405 nlines = len(outlines) - 1
1413 match = h_count_re.search(outlines[pos])
1414 while pos < nlines
and not match:
1416 match = h_count_re.search(outlines[pos])
1419 summaries.update(summ)
◆ findTTreeSummaries()
def GaudiTesting.BaseTest.findTTreeSummaries |
( |
|
stdout | ) |
|
Scan stdout to find ROOT TTree summaries and digest them.
Definition at line 1210 of file BaseTest.py.
1212 Scan stdout to find ROOT TTree summaries and digest them.
1214 stars = re.compile(
r"^\*+$")
1215 outlines = stdout.splitlines()
1216 nlines = len(outlines)
1222 while i < nlines
and not stars.match(outlines[i]):
1227 trees[tree[
"Name"]] = tree
◆ getCmpFailingValues()
def GaudiTesting.BaseTest.getCmpFailingValues |
( |
|
reference, |
|
|
|
to_check, |
|
|
|
fail_path |
|
) |
| |
Definition at line 1265 of file BaseTest.py.
1271 if c
is None or r
is None:
1273 return (fail_path, r, c)
◆ GetPlatform()
def GaudiTesting.BaseTest.GetPlatform |
( |
|
self | ) |
|
Return the platform Id defined in CMTCONFIG or SCRAM_ARCH.
Definition at line 1423 of file BaseTest.py.
1425 Return the platform Id defined in CMTCONFIG or SCRAM_ARCH.
1429 if "BINARY_TAG" in os.environ:
1430 arch = os.environ[
"BINARY_TAG"]
1431 elif "CMTCONFIG" in os.environ:
1432 arch = os.environ[
"CMTCONFIG"]
1433 elif "SCRAM_ARCH" in os.environ:
1434 arch = os.environ[
"SCRAM_ARCH"]
1435 elif os.environ.get(
"ENV_CMAKE_BUILD_TYPE",
"")
in (
1441 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 1451 of file BaseTest.py.
1453 Return True if the current platform is Windows.
1455 This function was needed because of the change in the CMTCONFIG format,
1456 from win32_vc71_dbg to i686-winxp-vc9-dbg.
1459 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 80 of file BaseTest.py.
82 Send a signal to a process and all its child processes (starting from the
85 log = logging.getLogger(
"kill_tree")
86 ps_cmd = [
"ps",
"--no-headers",
"-o",
"pid",
"--ppid", str(ppid)]
89 get_children = Popen(ps_cmd, stdout=PIPE, stderr=PIPE, env={})
90 children =
map(int, get_children.communicate()[0].split())
91 for child
in children:
94 log.debug(
"killing process %d", ppid)
96 except OSError
as err:
99 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 1332 of file BaseTest.py.
1334 Extract the histograms infos from the lines starting at pos.
1335 Returns the position of the first line after the summary block.
1338 h_table_head = re.compile(
1339 r'SUCCESS\s+(1D|2D|3D|1D profile|2D profile) histograms in directory\s+"(\w*)"'
1341 h_short_summ = re.compile(
r"ID=([^\"]+)\s+\"([^\"]+)\"\s+(.*)")
1346 m = h_count_re.search(lines[pos])
1347 name = m.group(1).strip()
1348 total = int(m.group(2))
1350 for k, v
in [x.split(
"=")
for x
in m.group(3).split()]:
1353 header[
"Total"] = total
1357 m = h_table_head.search(lines[pos])
1360 t = t.replace(
" profile",
"Prof")
1367 if l.startswith(
" | ID"):
1369 titles = [x.strip()
for x
in l.split(
"|")][1:]
1371 while pos < nlines
and lines[pos].startswith(
" |"):
1373 values = [x.strip()
for x
in l.split(
"|")][1:]
1375 for i
in range(len(titles)):
1376 hcont[titles[i]] = values[i]
1377 cont[hcont[
"ID"]] = hcont
1379 elif l.startswith(
" ID="):
1380 while pos < nlines
and lines[pos].startswith(
" ID="):
1382 x.strip()
for x
in h_short_summ.search(lines[pos]).groups()
1384 cont[values[0]] = values
1387 raise RuntimeError(
"Cannot understand line %d: '%s'" % (pos, l))
1391 summ[d][
"header"] = header
1396 summ[name] = {
"header": header}
◆ RationalizePath()
def GaudiTesting.BaseTest.RationalizePath |
( |
|
p | ) |
|
Function used to normalize the used path
Definition at line 738 of file BaseTest.py.
740 Function used to normalize the used path
742 newPath = os.path.normpath(os.path.expandvars(p))
743 if os.path.exists(newPath):
744 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 53 of file BaseTest.py.
55 Take a string with invalid ASCII/UTF characters and quote them so that the
56 string can be used in an XML text.
58 >>> sanitize_for_xml('this is \x1b')
59 'this is [NON-XML-CHAR-0x1B]'
61 bad_chars = re.compile(
"[\x00-\x08\x0b\x0c\x0e-\x1F\uD800-\uDFFF\uFFFE\uFFFF]")
65 return "".join(
"[NON-XML-CHAR-0x%2X]" % ord(c)
for c
in match.group())
67 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 748 of file BaseTest.py.
748 def which(executable):
750 Locates an executable in the executables path ($PATH) and returns the full
751 path to it. An application is looked for with or without the '.exe' suffix.
752 If the executable cannot be found, None is returned
754 if os.path.isabs(executable):
755 if not os.path.isfile(executable):
756 if executable.endswith(
".exe"):
757 if os.path.isfile(executable[:-4]):
758 return executable[:-4]
760 executable = os.path.split(executable)[1]
763 for d
in os.environ.get(
"PATH").split(os.pathsep):
764 fullpath = os.path.join(d, executable)
765 if os.path.isfile(fullpath):
767 elif executable.endswith(
".exe")
and os.path.isfile(fullpath[:-4]):
◆ __processLine__
GaudiTesting.BaseTest.__processLine__ |
|
private |
◆ h_count_re
GaudiTesting.BaseTest.h_count_re = re.compile(r"^(.*)SUCCESS\s+Booked (\d+) Histogram\(s\) :\s+([\s\w=-]*)") |
◆ lineSkipper
GaudiTesting.BaseTest.lineSkipper |
◆ maskPointers
GaudiTesting.BaseTest.maskPointers = RegexpReplacer("0x[0-9a-fA-F]{4,16}", "0x########") |
◆ normalizeDate
GaudiTesting.BaseTest.normalizeDate |
Initial value:
2 "[0-2]?[0-9]:[0-5][0-9]:[0-5][0-9] [0-9]{4}[-/][01][0-9][-/][0-3][0-9][ A-Z]*",
Definition at line 971 of file BaseTest.py.
◆ normalizeEOL
◆ normalizeExamples
◆ regexps
GaudiTesting.BaseTest.regexps |
◆ SKIP_RETURN_CODE
int GaudiTesting.BaseTest.SKIP_RETURN_CODE = 77 |
◆ 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.