[go: up one dir, main page]

File: t122_time_range2.py

package info (click to toggle)
uftrace 0.9.0-1
  • links: PTS
  • area: main
  • in suites: buster
  • size: 3,896 kB
  • sloc: ansic: 41,425; python: 7,369; makefile: 698; asm: 488; cpp: 461; sh: 349
file content (42 lines) | stat: -rw-r--r-- 1,192 bytes parent folder | download
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
#!/usr/bin/env python

from runtest import TestBase
import subprocess as sp

TDIR='xxx'
START=0

class TestCase(TestBase):
    def __init__(self):
        TestBase.__init__(self, 'abc', """
#  ELAPSED    FUNCTION
   4.343 us |       c() {
   4.447 us |         getpid();
   5.137 us |       } /* c */
   5.436 us |     } /* b */
   5.544 us |   } /* a */
   5.626 us | } /* main */
""", sort='simple')

    def pre(self):
        global START

        record_cmd = '%s record -d %s %s' % (TestBase.uftrace_cmd, TDIR, 't-' + self.name)
        sp.call(record_cmd.split())

        # find timestamp of function 'c'
        replay_cmd = '%s replay -d %s -f elapsed -F main' % (TestBase.uftrace_cmd, TDIR)
        p = sp.Popen(replay_cmd, shell=True, stdout=sp.PIPE, stderr=sp.PIPE)
        r = p.communicate()[0].decode(errors='ignore')
        START, unit = r.split('\n')[4].split()[0:2] # skip header, main, a and b (= 4)
        START += unit
        p.wait()

        return TestBase.TEST_SUCCESS

    def runcmd(self):
        return '%s replay -f elapsed -r %s~ -d %s' % (TestBase.uftrace_cmd, START, TDIR)

    def post(self, ret):
        sp.call(['rm', '-rf', TDIR])
        return ret