File: test_bash_linux_only.py

package info (click to toggle)
kcov 43%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 1,600 kB
  • sloc: cpp: 12,617; ansic: 2,379; python: 2,001; sh: 333; makefile: 133; javascript: 65; xml: 7; asm: 4
file content (53 lines) | stat: -rw-r--r-- 1,941 bytes parent folder | download | duplicates (3)
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
45
46
47
48
49
50
51
52
53
import libkcov
from libkcov import cobertura


class bash_sh_shebang(libkcov.TestCase):
    def runTest(self):
        rv, o = self.do(
            self.kcov
            + " --bash-handle-sh-invocation "
            + self.outbase
            + "/kcov "
            + self.sources
            + "/tests/bash/shell-main"
        )

        dom = cobertura.parseFile(self.outbase + "/kcov/shell-main/cobertura.xml")
        assert cobertura.hitsPerLine(dom, "sh-shebang.sh", 4) == 1


class bash_exit_before_child(libkcov.TestCase):
    def runTest(self):
        # kcovKcov shouldn't wait for the background process, so call it with kcovKcov = False
        rv, o = self.do(
            self.kcov
            + " --bash-tracefd-cloexec "
            + self.outbase
            + "/kcov "
            + self.sources
            + "/tests/bash/background-child.sh",
            kcovKcov=False,
            timeout=3.0,
        )
        self.assertEqual(0, rv, "kcov exited unsuccessfully")
        dom = cobertura.parseFile(self.outbase + "/kcov/background-child.sh/cobertura.xml")
        self.assertIsNone(cobertura.hitsPerLine(dom, "background-child.sh", 1))
        self.assertEqual(1, cobertura.hitsPerLine(dom, "background-child.sh", 3))
        self.assertEqual(1, cobertura.hitsPerLine(dom, "background-child.sh", 4))


class bash_ldpreload_multilib(libkcov.TestCase):
    def runTest(self):
        rv, o = self.do(
            self.kcov
            + " --bash-handle-sh-invocation --bash-tracefd-cloexec "
            + self.outbase
            + "/kcov "
            + self.sources
            + "/tests/bash/sh-shebang.sh"
        )
        self.assertEqual(0, rv, "kcov exited unsuccessfully")
        dom = cobertura.parseFile(self.outbase + "/kcov/sh-shebang.sh/cobertura.xml")
        self.assertIsNone(cobertura.hitsPerLine(dom, "sh-shebang.sh", 1))
        self.assertEqual(1, cobertura.hitsPerLine(dom, "sh-shebang.sh", 4))