kcov icon indicating copy to clipboard operation
kcov copied to clipboard

Warn users when output directory contains target binary

Open mcraveiro opened this issue 6 years ago • 3 comments

Hi kcov developers,

Many thanks for a very useful tool. I just did something really silly and it took me a little while to figure it out, which led me to wonder if its not worth alerting users: I set my output directory to the same directory as the binary, and as a result got the following error:

kcov: error: elf_begin failed on /FULL_PATH_TO_DIR/dogen.annotations.tests

kcov: error: Can't start/attach to /FULL_PATH_TO_DIR/dogen.annotations.tests

This happened because kcov appears to delete the target binary and create a simlink to the reporting directory, and then (I assume) tries to open the directory as if it as a ELF binary:

lrwxrwxrwx  1 marco marco      150 Oct 15 15:48 dogen.annotations.tests -> /FULL_PATH_TO_DIR/dogen.annotations.tests.d5518294725c92ef/
drwxr-xr-x  4 marco marco     4096 Oct 15 15:48 dogen.annotations.tests.d5518294725c92ef

It may be worth issuing a warning informing users that their command line options are not sensible :-) Apologies if this has already been submitted, but could not spot it.

Many thanks for your time

Marco

mcraveiro avatar Oct 15 '18 15:10 mcraveiro

Hehe, that's one way I didn't think of before!

But I agree, it's not good behavior to overwrite the binary, so we should gate that usage.

SimonKagstrom avatar Oct 16 '18 05:10 SimonKagstrom

Thanks @SimonKagstrom. By the by, may I just add that, after years of gcov and associated tooling, kcov was a joy to setup! I had even given up on having code coverage for a while, just out of fear of facing gcov, but then I saw kcov! :-) got it working in slightly over half-a-day for both coveralls and codecov! amazing stuff.

mcraveiro avatar Oct 16 '18 08:10 mcraveiro

Thanks a lot for this issue!! Really helpful

BotellaA avatar May 16 '19 10:05 BotellaA