linux-test-project / lcov

LCOV
GNU General Public License v2.0
866 stars 234 forks source link

What do these symbols for branch coverage mean? #276

Closed GuWei007 closed 3 months ago

GuWei007 commented 3 months ago

brda1

What do these symbols for branch coverage mean? Are there any tools that can parse them? [+ + + -

define TORCH_MLU_CHECK(cond, ...) \

do { \ if (!(cond)) { \ CNLOG(ERROR) << ""; \ TORCH_CHECK(false, ##__VA_ARGS__); \ } \ } while (0);

define TORCH_CHECK(cond, ...) \

if (C10_UNLIKELY_OR_CONST(!(cond))) { \ ::c10::detail::torchCheckFail( \ func, \ FILE, \ static_cast(LINE), \ TORCH_CHECK_MSG(cond, "", ##__VA_ARGS__)); \ }

endif

`

GuWei007 commented 3 months ago

@henry2cox

henry2cox commented 3 months ago

+ is the true branch, red if not taken. - is the false branch. If you hover your mouse over the element, some additional information will pop up (tooltip widget)

To know which expression each branch corresponds to, you need to know something about the compiler - but you won't go far wrong by thinking about what the expression tree looks like. Lcov support for some other languages (e.g., perl or verilog) explicitly shows the (text) expression - which makes it a lot easier to understand what is missed/which tests are needed.

This specific example is showing expressions in an expanded macro - and probably also includes some related to exception handlers. Some compilers emit sufficient information to identify exception branches - and some do not. You already asked about filtering in an earlier question.

I don't understand what sort of tool you are looking for. If such a tool/feature worked perfectly and did exactly what you want... what would it have done? (That is: please write a functional spec.)

Hope this helps.

GuWei007 commented 3 months ago

Thanks for your help, I will change the impl of TORCH_MLU_CHECK to improve branch coverage