Hi,
I am measure code coverage for some APIs relative ternary operator. Saw debugger cannot recognize branch when ternary operators are used and missing e_b also. It gives bad results measure code coverage. Please help me check it. My debugger as below:
- Function not taken decision:
Function foo1 not taken decision
Function foo2 not taken decision
Function foo4 not taken decision
Function foo5 not taken decision
Function foo5 not taken decision
- Funtion taken decision:
Funtion foo3 taken decision
My code test as below:
/// typedefs to fix MISRA DIR4.6
typedef uint8_t BOOL;
#define TRUE ((uint8_t)1u)
#define FALSE ((uint8_t)0u)
typedef uint32_t FOO_ERRCODE;
#define FOO_ERR_NOERROR (0u)
#define FOO_ERR_INPUTOUTOFRANGE (0x50001u)
#define FOO_ERR_INPUTOUTOFRANGE_2 (0x1u)
uint8_t foo1(uint8_t input1);
BOOL foo2(BOOL input2);
FOO_ERRCODE foo3(uint32_t input3);
FOO_ERRCODE foo4(uint32_t input4);
FOO_ERRCODE foo5(float32_t SeqInterval);
uint8_t foo1(uint8_t input1)
{
uint8_t output1 = 0u;
output1 = (input1 == 1u) ? 0u : 1u;
return output1;
}
BOOL foo2(BOOL input2)
{
BOOL output2 = FALSE;
output2 = (input2 == TRUE) ? FALSE : TRUE;
return output2;
}
FOO_ERRCODE foo3(uint32_t input3)
{
FOO_ERRCODE errodeCode = FOO_ERR_NOERROR;
errodeCode = (input3 > 32) ? FOO_ERR_NOERROR : FOO_ERR_INPUTOUTOFRANGE;
return errodeCode;
}
FOO_ERRCODE foo4(uint32_t input4)
{
FOO_ERRCODE errodeCode = FOO_ERR_NOERROR;
errodeCode = (input4 > 32) ? FOO_ERR_NOERROR : FOO_ERR_INPUTOUTOFRANGE_2;
return errodeCode;
}
FOO_ERRCODE foo5(float32_t SeqInterval)
{
FOO_ERRCODE errodeCode = FOO_ERR_NOERROR;
uint64_t tmpSeqInterval;
tmpSeqInterval = (uint64_t)lroundf(SeqInterval * 1000.0f / 25.0f);
if ((tmpSeqInterval >= 1u) && (tmpSeqInterval < 0xFFFFFFFFu))
{
errodeCode = FOO_ERR_NOERROR;
}
else
{
errodeCode = FOO_ERR_INPUTOUTOFRANGE;
}
return errodeCode;
}
void main(void)
{
foo1(1u);
foo1(0u);
foo2(TRUE);
foo2(FALSE);
foo3(35u);
foo3(25u);
foo4(35u);
foo4(25u);
foo5(10u);
foo5(0u);
foo5(0xFFFFFFFFu);
}
My tool and enviroment:
GNU Compiler Collection - GCC Version 4.9.4 20160726
- S32 Design Studio, version 2.1, Build ID 190624 with S32R294 development package version 2.1.0
- Lauterbach Trace32 PowerView for PowerPC, Version N.2021.06.000136240
- EVB S32R294RRU2