◆ _new_backslashreplace_errors()
| def GaudiTesting.BaseTest._new_backslashreplace_errors |
( |
|
exc | ) |
|
|
private |
Definition at line 37 of file BaseTest.py.
38 if isinstance(exc, UnicodeDecodeError):
39 code =
hex(ord(exc.object[exc.start]))
40 return (
"\\" + code[1:], exc.start + 1)
42 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 1226 of file BaseTest.py.
1228 Parse the TTree summary table in lines, starting from pos.
1229 Returns a tuple with the dictionary with the digested informations and the
1230 position of the first line after the summary.
1237 return [f.strip()
for f
in l.strip(
"*\n").split(
":", 2)]
1241 cols = splitcols(ll[0])
1242 r[
"Name"], r[
"Title"] = cols[1:]
1244 cols = splitcols(ll[1])
1245 r[
"Entries"] = int(cols[1])
1247 sizes = cols[2].split()
1248 r[
"Total size"] = int(sizes[2])
1249 if sizes[-1] ==
"memory":
1252 r[
"File size"] = int(sizes[-1])
1254 cols = splitcols(ll[2])
1255 sizes = cols[2].split()
1256 if cols[0] ==
"Baskets":
1257 r[
"Baskets"] = int(cols[1])
1258 r[
"Basket size"] = int(sizes[2])
1259 r[
"Compression"] = float(sizes[-1])
1262 if i < (count - 3)
and lines[i].startswith(
"*Tree"):
1263 result = parseblock(lines[i : i + 3])
1264 result[
"Branches"] = {}
1266 while i < (count - 3)
and lines[i].startswith(
"*Br"):
1267 if i < (count - 2)
and lines[i].startswith(
"*Branch "):
1271 branch = parseblock(lines[i : i + 3])
1272 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 1178 of file BaseTest.py.
1180 Check that all the keys in reference are in to_check too, with the same value.
1181 If the value is a dict, the function is called recursively. to_check can
1182 contain more keys than reference, that will not be tested.
1183 The function returns at the first difference found.
1188 ignore_re = re.compile(ignore)
1189 keys = [key
for key
in reference
if not ignore_re.match(key)]
1191 keys = reference.keys()
1195 if (
type(reference[k])
is dict)
and (
type(to_check[k])
is dict):
1198 failed = fail_keys =
cmpTreesDicts(reference[k], to_check[k], ignore)
1201 failed = to_check[k] != reference[k]
1206 fail_keys.insert(0, k)
◆ dumpProcs()
| def GaudiTesting.BaseTest.dumpProcs |
( |
|
name | ) |
|
helper to debug GAUDI-1084, dump the list of processes
Definition at line 69 of file BaseTest.py.
70 """helper to debug GAUDI-1084, dump the list of processes"""
71 from getpass
import getuser
73 if "WORKSPACE" in os.environ:
74 p = Popen([
"ps",
"-fH",
"-U", getuser()], stdout=PIPE)
75 with open(os.path.join(os.environ[
"WORKSPACE"], name),
"wb")
as f:
76 f.write(p.communicate()[0])
◆ findHistosSummaries()
| def GaudiTesting.BaseTest.findHistosSummaries |
( |
|
stdout | ) |
|
Scan stdout to find ROOT TTree summaries and digest them.
Definition at line 1346 of file BaseTest.py.
1348 Scan stdout to find ROOT TTree summaries and digest them.
1350 outlines = stdout.splitlines()
1351 nlines = len(outlines) - 1
1359 match = h_count_re.search(outlines[pos])
1360 while pos < nlines
and not match:
1362 match = h_count_re.search(outlines[pos])
1365 summaries.update(summ)
◆ findTTreeSummaries()
| def GaudiTesting.BaseTest.findTTreeSummaries |
( |
|
stdout | ) |
|
Scan stdout to find ROOT TTree summaries and digest them.
Definition at line 1156 of file BaseTest.py.
1158 Scan stdout to find ROOT TTree summaries and digest them.
1160 stars = re.compile(
r"^\*+$")
1161 outlines = stdout.splitlines()
1162 nlines = len(outlines)
1168 while i < nlines
and not stars.match(outlines[i]):
1173 trees[tree[
"Name"]] = tree
◆ getCmpFailingValues()
| def GaudiTesting.BaseTest.getCmpFailingValues |
( |
|
reference, |
|
|
|
to_check, |
|
|
|
fail_path |
|
) |
| |
Definition at line 1211 of file BaseTest.py.
1217 if c
is None or r
is None:
1219 return (fail_path, r, c)
◆ GetPlatform()
| def GaudiTesting.BaseTest.GetPlatform |
( |
|
self | ) |
|
Return the platform Id defined in CMTCONFIG or SCRAM_ARCH.
Definition at line 1369 of file BaseTest.py.
1371 Return the platform Id defined in CMTCONFIG or SCRAM_ARCH.
1375 if "BINARY_TAG" in os.environ:
1376 arch = os.environ[
"BINARY_TAG"]
1377 elif "CMTCONFIG" in os.environ:
1378 arch = os.environ[
"CMTCONFIG"]
1379 elif "SCRAM_ARCH" in os.environ:
1380 arch = os.environ[
"SCRAM_ARCH"]
1381 elif os.environ.get(
"ENV_CMAKE_BUILD_TYPE",
"")
in (
1387 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 1397 of file BaseTest.py.
1399 Return True if the current platform is Windows.
1401 This function was needed because of the change in the CMTCONFIG format,
1402 from win32_vc71_dbg to i686-winxp-vc9-dbg.
1405 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 79 of file BaseTest.py.
81 Send a signal to a process and all its child processes (starting from the
84 log = logging.getLogger(
"kill_tree")
85 ps_cmd = [
"ps",
"--no-headers",
"-o",
"pid",
"--ppid", str(ppid)]
86 get_children = Popen(ps_cmd, stdout=PIPE, stderr=PIPE)
87 children =
map(int, get_children.communicate()[0].split())
88 for child
in children:
91 log.debug(
"killing process %d", ppid)
93 except OSError
as err:
96 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 1278 of file BaseTest.py.
1280 Extract the histograms infos from the lines starting at pos.
1281 Returns the position of the first line after the summary block.
1284 h_table_head = re.compile(
1285 r'SUCCESS\s+(1D|2D|3D|1D profile|2D profile) histograms in directory\s+"(\w*)"'
1287 h_short_summ = re.compile(
r"ID=([^\"]+)\s+\"([^\"]+)\"\s+(.*)")
1292 m = h_count_re.search(lines[pos])
1293 name = m.group(1).strip()
1294 total = int(m.group(2))
1296 for k, v
in [x.split(
"=")
for x
in m.group(3).split()]:
1299 header[
"Total"] = total
1303 m = h_table_head.search(lines[pos])
1306 t = t.replace(
" profile",
"Prof")
1313 if l.startswith(
" | ID"):
1315 titles = [x.strip()
for x
in l.split(
"|")][1:]
1317 while pos < nlines
and lines[pos].startswith(
" |"):
1319 values = [x.strip()
for x
in l.split(
"|")][1:]
1321 for i
in range(len(titles)):
1322 hcont[titles[i]] = values[i]
1323 cont[hcont[
"ID"]] = hcont
1325 elif l.startswith(
" ID="):
1326 while pos < nlines
and lines[pos].startswith(
" ID="):
1328 x.strip()
for x
in h_short_summ.search(lines[pos]).groups()
1330 cont[values[0]] = values
1333 raise RuntimeError(
"Cannot understand line %d: '%s'" % (pos, l))
1337 summ[d][
"header"] = header
1342 summ[name] = {
"header": header}
◆ RationalizePath()
| def GaudiTesting.BaseTest.RationalizePath |
( |
|
p | ) |
|
Function used to normalize the used path
Definition at line 679 of file BaseTest.py.
681 Function used to normalize the used path
683 newPath = os.path.normpath(os.path.expandvars(p))
684 if os.path.exists(newPath):
685 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 52 of file BaseTest.py.
54 Take a string with invalid ASCII/UTF characters and quote them so that the
55 string can be used in an XML text.
57 >>> sanitize_for_xml('this is \x1b')
58 'this is [NON-XML-CHAR-0x1B]'
60 bad_chars = re.compile(
"[\x00-\x08\x0b\x0c\x0e-\x1F\uD800-\uDFFF\uFFFE\uFFFF]")
64 return "".join(
"[NON-XML-CHAR-0x%2X]" % ord(c)
for c
in match.group())
66 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 689 of file BaseTest.py.
689 def which(executable):
691 Locates an executable in the executables path ($PATH) and returns the full
692 path to it. An application is looked for with or without the '.exe' suffix.
693 If the executable cannot be found, None is returned
695 if os.path.isabs(executable):
696 if not os.path.isfile(executable):
697 if executable.endswith(
".exe"):
698 if os.path.isfile(executable[:-4]):
699 return executable[:-4]
701 executable = os.path.split(executable)[1]
704 for d
in os.environ.get(
"PATH").split(os.pathsep):
705 fullpath = os.path.join(d, executable)
706 if os.path.isfile(fullpath):
708 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 912 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.