Skip to content

Commit

Permalink
tests: fix basic.OutDirectoryIsExecutable
Browse files Browse the repository at this point in the history
Commit 4b4cb9c (Merge pull request #426 from perillo/fix-argv-parsing)
added a regression test, but the test failed due to ptrace errors on
Linux.
The "Operation not permitted" error was caused by kcov trying to trace
the "/bin/usr/python".

The solution is to execute an executable having user permission.
Restore the short-test.py executable, and use it instead of python.
short-test.py always exits with exit status 0.
  • Loading branch information
perillo committed Mar 17, 2024
1 parent 17db4f0 commit 402b735
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 2 additions & 2 deletions tests/python/short-test.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/usr/bin/python
#!/usr/bin/env python3

import sys

def doSomething():
print 'Hello world'
print('Hello world')


if __name__ == '__main__':
Expand Down
6 changes: 5 additions & 1 deletion tests/tools/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ def runTest(self):
class OutDirectoryIsExecutable(testbase.KcovTestCase):
def runTest(self):
self.setUp()
rv,o = self.do(testbase.kcov + " echo python -V")
# 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 = testbase.sources + "/tests/python/short-test.py"
rv,o = self.do(testbase.kcov + " echo " + executable)

assert rv == 0

0 comments on commit 402b735

Please sign in to comment.