I compiled Zeek 2.6.1 from source today with the following lines:
sudo make install
I did not notice any differences from running bro —help. Nor was I able to get any new outputs when running btest as described here:
My understanding is that this is a way to check Zeek scripts (not the C++ source) to check coverage. Is my understanding correct?
If it is correct, what configuration / context am I missing to get a proper code coverage report?
That's C++ coverage, not Zeek script coverage.
Getting Zeek script coverage is a two step process:
1) Run bro with the BRO_PROFILER_FILE environment variable set to a
file path, adding 'X' characters to the file name cause them to be
randomized (in case you are running bro multiple times and need to
aggregate coverage across runs). Here's how we set this in our unit
Those files simply track how many times a given statement was executed.
2) Run a script over the results in step (1) to aggregate and
Here is the script we run for our test suite coverage calculation:
And how it is invoked:
Thanks for those details. I will execute these steps in the morning and follow up with additional questions.
Appreciate the help on this. I think I need to slightly modify the script to only evaluate my custom .bro / .zeek files. Which seem to be properly reporting out some lines as being executed.
Before I go down this path, is there some parameter I should pass instead to only scan my script directory? For example:
Looks like the last parameter of coverage-calc is a directory
containing the scripts you want the coverage calculated against, so
may try pointing that to your own custom bro/zeek scripts instead of
the ones shipped in the our source tree.
Generally that script was meant for our own test suite usage, so may
need to be modified for your use, but the data produced by running
with BRO_PROFILER_FILE is what any coverage calculation could be based
I was able to get it working by replacing line 29 in coverage-calc:
filepath = os.path.normpath(filepath)
filepath = os.path.abspath(filepath)
This allows for the Boolean check to succeed and processing to continue with processing only my scripts.