File: t229_info_task.py

package info (click to toggle)
uftrace 0.19-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,372 kB
  • sloc: ansic: 49,879; python: 11,279; asm: 837; makefile: 769; sh: 637; cpp: 627; javascript: 191
file content (37 lines) | stat: -rw-r--r-- 1,000 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
#!/usr/bin/env python3

from runtest import TestBase

class TestCase(TestBase):
    def __init__(self):
        TestBase.__init__(self, 'fork', """
#         TIMESTAMP       FLAGS     TID    TASK              DATA SIZE
        347768.688479931  FS     [ 27364]  t-fork                0.000 MB
        347768.711664373  F      [ 27366]  t-fork                0.000 MB
""")

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

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

    def sort(self, output):
        import re
        result = []

        for ln in output.split('\n'):
            # ignore blank lines and comments
            if ln.strip() == '' or ln.startswith('#'):
                continue

            # ignore time part
            ln = ln[24:]

            # replace tid part into common string
            task = re.sub(r'\[ *[0-9]+\]', '[TID]', ln)
            result.append(task)

        return '\n'.join(result)