I'm working with a C++17 program that supports clang compilation, not gcc, and built my program bugzoo infrastructure around clang-7
and libstdc++-8-dev
.
I found that there was no impact wrt using clang
, until I tried to generate the coverage via bugzoo bug coverage <myprogram>
.
It looks like bugzoo/mgr/coverage/gcov.py
, gcovr
needs the additional command-line --gcov-executable 'llvm-cov gcov'
instead of the default (--gcov-executable 'gcov'
) to support clang.
I was testing it out and weird thing, gcovr
returned an XML file that had no files or lines-covered.
So I ran the following experiments:
- I launched
bugzoo container launch <myprogram>
and interactively compiled for instrumentation, i.e.--coverage
, ran my tests with coverage executable, verified that the coverage was non-zero (llvm-cov gcov <file-to-instrument>
), then rangcovr -o <myxml> -x -d --gcov-executable 'llvm-cov gcov' -r .
and found that<myxml>
was not empty. - Before
gcovr
cmd was issued, I added code to verify the communication between the bugzoo server and bug client with another command, and the coverage output files are not empty, viallvm-cov gcov
:cmd = '(llvm-cov --version; llvm-cov gcov <files-to-instrument>; gcovr --version) |& tee {}'.format(fn_temp_ctr) response = mgr_ctr.command(container, cmd, context=dir_source, verbose=True) # copy the contents of the temporary file to the host machine (_, fn_temp_host) = tempfile.mkstemp(suffix='.bugzoo') try: mgr_ctr.copy_from(container, fn_temp_ctr, fn_temp_host) with open(fn_temp_host, 'r') as fh: report = fh.read() print("Find: {}".format(report)) finally: os.remove(fn_temp_host)
With this, I saw valid output from the
llvm-cov gcov
line:LLVM (http://llvm.org/): LLVM version 6.0.0 Optimized build. Default target: x86_64-pc-linux-gnu Host CPU: haswell File 'src/example_2.c' Lines executed:62.14% of 103 src/example_2.c:creating 'example_2.c.gcov' gcovr 3.4
- I tried this same scenario on
clang++
,clang++-7
,clang
and I'm still seeing empty coverage results withgcovr
and nonempty withllvm-cov gcov
viabugzoo bug coverage <myprogram>
.
The only thing I can think of is that either something cleared the .gc*
coverage intermediate files, like the gcovr
command was launched multiple times, which should have also impacted the gcc
coverage mechanism (??), or something is happening specifically in the http interaction. Neither of these seem very likely, but I'm flagging it because of the weirdness and for clang
support.