I’ve got a PR that’s failure due to missing code coverage:
My question is; where are these coverage results pulled from?
It would make sense to add any additional tests alongside the existing ones, but I’m not sure if there are existing tests covering src/util-file.c.
If I need to create a new test, should I just add a new file into src/tests ? Do those tests link against everything?
Or should I use the UtRegisterTest() call which is used in various other util-*.c files?
Coverage is currently taken from 2 CI jobs: one compiles with unittests and runs them, the other compiles w/o unittests and runs the Suricata-Verify tests. The results of both runs are submitted to Codecov.
For small functions we prefer unittests, for bigger tests, like checking if a feature leads to the correct log output, we prefer Suricata-Verify tests.
If you submit a Suricata-Verify PR, you can reference it in the Suricata PR by its number: suricata-verify-pr: NNN.
For this to work, you should have made the suricata-verify PR before you make the suricata PR so the CI can pull that exact PR and run tests with it.
CI does not read commit messages so the PR number should not be mentioned in the commit.
Something seems off… I’m not done my UTs, but I wanted to push upstream to see what the coverage was, and I see this:
All but the first two annotations seem to be complaining that my tests don’t have test coverage… how can I prevent it from checking coverage of my test code??
Codecov is correct, the tests are still in the outdated style. New tests are branchless. See StreamTcpTest02 as an example. We’re slowly converting tests to conform to this new style.