SimonKagstrom / kcov

Code coverage tool for compiled programs, Python and Bash which uses debugging information to collect and report data without special compilation options
http://simonkagstrom.github.io/kcov/
GNU General Public License v2.0
709 stars 109 forks source link

tests: fix basic.OutDirectoryIsExecutable #428

Closed perillo closed 5 months ago

perillo commented 5 months ago

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.

codecov[bot] commented 5 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 65.72%. Comparing base (692d41c) to head (402b735). Report is 3 commits behind head on master.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #428 +/- ## ========================================== - Coverage 65.81% 65.72% -0.10% ========================================== Files 58 58 Lines 4520 4508 -12 Branches 4177 4165 -12 ========================================== - Hits 2975 2963 -12 Misses 1545 1545 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

perillo commented 5 months ago

For the reason of the ptrace error with the old test, see https://bugs.launchpad.net/ubuntu/+source/linux-signed/+bug/1860822

In Linux, process tracing is tied with the process dumping flag. The dumpable flag is cleared at execve(2) time when a setuid or setgid application is executed. This flag persists to child processes created by fork(2) and will only be reset when a process calls execve(2) again.

> stat -L /usr/bin/python3
Access: (0755/-rwxr-xr-x)  Uid: (    0/    root)   Gid: (    0/    root)
stat tests/python/short-test.py 
Access: (0750/-rwxr-x---)  Uid: ( 1000/  manlio)   Gid: ( 1000/  manlio)

The kcov test suite runs correctly on my system, without using sudo and with /proc/sys/kernel/yama/ptrace_scope set to 1 (the default value).

SimonKagstrom commented 5 months ago

OK, thanks for the PR and the well-made analysis! Merged!