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))
|