File: t230_graph_task.py

package info (click to toggle)
uftrace 0.18.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,356 kB
  • sloc: ansic: 49,770; python: 11,181; asm: 837; makefile: 769; sh: 637; cpp: 627; javascript: 191
file content (44 lines) | stat: -rw-r--r-- 1,339 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/env python3

import re

from runtest import TestBase

class TestCase(TestBase):
    def __init__(self):
        TestBase.__init__(self, 'fork', result="""
========== TASK GRAPH ==========
# TOTAL TIME   SELF TIME     TID     TASK NAME
   16.172 ms  356.762 us  [129306] : t-fork
                                   :  |
   11.015 us   11.015 us  [129317] :  +----t-fork
""")

    def prepare(self):
        self.subcmd = 'record'
        return self.runcmd()

    def setup(self):
        self.subcmd = 'graph'
        self.option = '--task'
        self.exearg = ''

    def sort(self, output, ignored=False):
        """ This function post-processes output of the test to be compared.
            It ignores blank and comment (#) lines and header lines.  """
        result = []
        for ln in output.split('\n'):
            if ln.strip() == '' or ln.startswith('#'):
                continue
            # A graph result consists of backtrace and calling functions
            if ln.startswith('========== TASK GRAPH =========='):
                continue

            if " : " in ln:
                line = ln.split(':')[1]  # remove time part
                line = re.sub(r'\[\d+\]', 'TID', line)
                result.append(line)
            else:
                result.append(ln)

        return '\n'.join(result)