File: t199_script_info.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 (40 lines) | stat: -rw-r--r-- 1,115 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
#!/usr/bin/env python3

import subprocess as sp

from runtest import TestBase

class TestCase(TestBase):
    def __init__(self):
        TestBase.__init__(self, 'abc', """
False
v0.8.3-10/gfbfac3
('foo', 'bar')
""")

    def prerun(self, timeout):
        self.subcmd = 'script'
        self.option = ''
        self.exearg = ''

        script_cmd = self.runcmd()
        p = sp.Popen(script_cmd.split(), stdout=sp.PIPE, stderr=sp.PIPE)
        if p.communicate()[1].decode(errors='ignore').startswith('WARN:'):
            return TestBase.TEST_SKIP

        self.subcmd = 'record'
        self.exearg = 't-' + self.name
        record_cmd = self.runcmd()
        self.pr_debug('prerun command: ' + record_cmd)
        sp.call(record_cmd.split())
        return TestBase.TEST_SUCCESS

    def setup(self):
        self.subcmd = 'script'
        self.option = '-F main -S %s/scripts/info.py' % self.basedir
        self.exearg = 'foo bar'

    def sort(self, output):
        result = output.strip().split('\n')
        result[1] = 'uftrace version'  # overwrite the version number
        return '\n'.join(result)