Normalize DTrace output for comparison. DTrace keeps a per-CPU buffer, and when showing the fired probes, buffers are concatenated. So if the operating system moves our thread around, the straight result can be "non-causal". So we add timestamps to the probe firing, sort by that fie
(output)
| 20 | |
| 21 | |
| 22 | def normalize_trace_output(output): |
| 23 | """Normalize DTrace output for comparison. |
| 24 | |
| 25 | DTrace keeps a per-CPU buffer, and when showing the fired probes, buffers |
| 26 | are concatenated. So if the operating system moves our thread around, the |
| 27 | straight result can be "non-causal". So we add timestamps to the probe |
| 28 | firing, sort by that field, then strip it from the output""" |
| 29 | |
| 30 | # When compiling with '--with-pydebug', strip '[# refs]' debug output. |
| 31 | output = re.sub(r"\[[0-9]+ refs\]", "", output) |
| 32 | try: |
| 33 | result = [ |
| 34 | row.split("\t") |
| 35 | for row in output.splitlines() |
| 36 | if row and not row.startswith('#') |
| 37 | ] |
| 38 | result.sort(key=lambda row: int(row[0])) |
| 39 | result = [row[1] for row in result] |
| 40 | return "\n".join(result) |
| 41 | except (IndexError, ValueError): |
| 42 | raise AssertionError( |
| 43 | "tracer produced unparsable output:\n{}".format(output) |
| 44 | ) |
| 45 | |
| 46 | |
| 47 | class TraceBackend: |
no test coverage detected
searching dependent graphs…