Hi,
I am using RTRT tool for doing code coverage. In my code I am using nested if conditions, in that one of the if condition is not getting covered.
In this code first 2 if conditions are getting covered then after for loop if condition is not getting covered. For both the if conditions I am using same global variables but data will be changed.
I need a help for how to cover this if condition also.
function()
{
Mcu1_Arinc429_DataReceiver();
/*Doing bitwise operation to check data bit*/
Latch_bit_g = Arincrx_mesg_g & ((0x1u) << 12);
UnLatch_bit_g = Arincrx_mesg_g & ((0x1u) << 13);
Lock_bit_g = Arincrx_mesg_g & ((0x1u) << 14);
UnLock_bit_g = Arincrx_mesg_g & ((0x1u) << 15);
/*Checking where Latch_bit_g is set to 1 and remaining bits to 0 */
if ((Latch_bit_g == 1) && (UnLatch_bit_g == 0) && (Lock_bit_g == 0)
&&(UnLock_bit_g ==0))
{
/*As condition is true incrementing Counter */
LTCHLCK_Counter1_g++;
/*Checking where counter is equal to 3 */
if (LTCHLCK_Counter1_g == 3)
{
/*As counter is 3 setting it to 0*/
LTCHLCK_Counter1_g = 0;
/*Calling DataReceiver function to read data*/
Mcu1_Arinc429_DataReceiver();
/*Doing bitwise operation to check data bit*/
UnLatch_bit_g = Arincrx_mesg_g & ((0x1u) << 13);
Latch_bit_g = Arincrx_mesg_g & ((0x1u) << 12);
Lock_bit_g = Arincrx_mesg_g & ((0x1u) << 14);
UnLock_bit_g = Arincrx_mesg_g & ((0x1u) << 15);
/*Using a for loop to check Inactive command*/
for (Ltchlck_loop_g = 0; Ltchlck_loop_g < 2; Ltchlck_loop_g++)
{
/*Checking where UnLatch_bit_g is set to 0 and remaining bits to 1 */
if ((UnLatch_bit_g == 0) && (Latch_bit_g == 1)
&& (Lock_bit_g == 1) && (UnLock_bit_g == 1))
{
/*As condition is true incrementing Counter */
LTCHLCK_Counter2_g++;
/*Checking where counter is equal to 2 */
if (LTCHLCK_Counter2_g == 2)
{
/*As counter is 2 setting it to 0*/
LTCHLCK_Counter2_g = 0;
/*As condition met setting for loop to 1*/
Ltchlck_loop_g = 1;
/*Setting Active Latch flag*/
ACTIVE_LATCH_FLAG = true;
/*printf("setting flag of active latch\n");*/
/*Calling Command processing function to transmit data*/
Mcu1_Arinc429_CommandProcessing();
}
/*When counter is not equal to 2, enters to else part*/
else
{
/*Calling DataReceiver function to read data*/
Mcu1_Arinc429_DataReceiver();
/*Doing bitwise operation to check data bit*/
UnLatch_bit_g = Arincrx_mesg_g & ((0x1u) << 13);
Latch_bit_g = Arincrx_mesg_g & ((0x1u) << 12);
Lock_bit_g = Arincrx_mesg_g & ((0x1u) << 14);
UnLock_bit_g = Arincrx_mesg_g & ((0x1u) << 15);
}
}
}
Thanks & regards,
Kiranmayee
------------------------------
Kiranmayee g
------------------------------