Skip to content

Commit

Permalink
tests: Avoid python tests if --no-ptrace is given as well
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonKagstrom committed Jul 17, 2024
1 parent 3b8f8c7 commit bcbd809
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 14 deletions.
6 changes: 4 additions & 2 deletions tests/tools/libkcov/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,12 @@ def addTests(config, args, patterns):
if not args.no_ptrace:
test_loader.add_tests_from_module("test_system_mode")

test_loader.add_tests_from_module("test_accumulate")
if not args.no_ptrace:
test_loader.add_tests_from_module("test_accumulate")
test_loader.add_tests_from_module("test_bash")
test_loader.add_tests_from_module("test_filter")
test_loader.add_tests_from_module("test_python")
if not args.no_ptrace:
test_loader.add_tests_from_module("test_python")

return test_loader.tests

Expand Down
12 changes: 0 additions & 12 deletions tests/tools/test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,3 @@ def runTest(self):
dom = cobertura.parseFile(self.outbase + "/kcov/main/cobertura.xml")
assert cobertura.hitsPerLine(dom, "second.py", 34) == 2
assert noKcovRv, rv


# Issue #414
class outdir_is_executable(libkcov.TestCase):
def runTest(self):
# Running a system executable on Linux may cause ptrace to fails with
# "Operation not permitted", even with ptrace_scope set to 0.
# See https://www.kernel.org/doc/Documentation/security/Yama.txt
executable = self.sources + "/tests/python/short-test.py"
rv, o = self.do(self.kcov + " echo " + executable)

assert rv == 0
12 changes: 12 additions & 0 deletions tests/tools/test_compiled.py
Original file line number Diff line number Diff line change
Expand Up @@ -572,3 +572,15 @@ def runTest(self):

assert cobertura.hitsPerLine(dom, "sanitizer-coverage.c", 22) == 0
assert cobertura.hitsPerLine(dom, "sanitizer-coverage.c", 25) == 0


# Issue #414
class outdir_is_executable(libkcov.TestCase):
def runTest(self):
# Running a system executable on Linux may cause ptrace to fails with
# "Operation not permitted", even with ptrace_scope set to 0.
# See https://www.kernel.org/doc/Documentation/security/Yama.txt
executable = self.sources + "/tests/python/short-test.py"
rv, o = self.do(self.kcov + " echo " + executable)

assert rv == 0

0 comments on commit bcbd809

Please sign in to comment.