Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TIME missing coverage in cfe_time_api.c when default CFE_MISSION_TIME_EPOCH_SECOND is 0 #1841

Open
astrogeco opened this issue Aug 18, 2021 · 1 comment
Assignees

Comments

@astrogeco
Copy link
Contributor

astrogeco commented Aug 18, 2021

@skliper and @pepepr08 reformat into standard template

In cfe_time_api.c, can't test the following lines when default CFE_MISSION_TIME_EPOCH_SECOND is 0.

        -:  621:    /*
        -:  622:    ** Convert the cFE time (offset from epoch) into calendar time...
        -:  623:    */
        4:  624:    NumberOfMinutes = (TimeToPrint.Seconds / 60) + CFE_MISSION_TIME_EPOCH_MINUTE;
        4:  625:    NumberOfSeconds = (TimeToPrint.Seconds % 60) + CFE_MISSION_TIME_EPOCH_SECOND;
        -:  626:
        -:  627:    /*
        -:  628:    ** Adding the epoch "seconds" after computing the minutes avoids
        -:  629:    **    overflow problems when the input time value (seconds) is
        -:  630:    **    at, or near, 0xFFFFFFFF...
        -:  631:    */
        8:  632:    while (NumberOfSeconds >= 60)
        -:  633:    {
    #####:  634:        NumberOfMinutes++;
    #####:  635:        NumberOfSeconds -= 60;
        -:  636:    }

Reached 100% in all but cfe_time_api.c

File '/home/jfmarti4/cfs-gateway/remote/cfs/cfe/modules/time/fsw/src/cfe_time_api.c'
Lines executed:98.96% of 192

File '/home/jfmarti4/cfs-gateway/remote/cfs/cfe/modules/time/fsw/src/cfe_time_task.c'
Lines executed:100.00% of 381

File '/home/jfmarti4/cfs-gateway/remote/cfs/cfe/modules/time/fsw/src/cfe_time_utils.c'
Lines executed:100.00% of 255

File '/home/jfmarti4/cfs-gateway/remote/cfs/cfe/modules/time/fsw/src/cfe_time_tone.c'
Lines executed:100.00% of 149

Originally posted by @pepepr08 in #473 (comment)

@skliper skliper changed the title Missing coverage in cfe_time_api.c when default CFE_MISSION_TIME_EPOCH_SECOND is 0 TIME missing coverage in cfe_time_api.c when default CFE_MISSION_TIME_EPOCH_SECOND is 0 Aug 26, 2021
@avan989
Copy link
Contributor

avan989 commented Jun 7, 2023

no longer valid. Reference #2316

CFE_Status_t CFE_TIME_Print(char *PrintBuffer, CFE_TIME_SysTime_t TimeToPrint)
{
size_t FmtLen = 0;
uint32 Micros = (CFE_TIME_Sub2MicroSecs(TimeToPrint.Subseconds) + CFE_MISSION_TIME_EPOCH_MICROS) / 10;
struct tm tm;
if (PrintBuffer == NULL)
{
return CFE_TIME_BAD_ARGUMENT;
}
time_t sec = TimeToPrint.Seconds + CFE_MISSION_TIME_EPOCH_SECONDS; // epoch is Jan 1, 1980
gmtime_r(&sec, &tm);
FmtLen = strftime(PrintBuffer, CFE_TIME_PRINTED_STRING_SIZE - 6, "%Y-%j-%H:%M:%S", &tm);
PrintBuffer += FmtLen;
*(PrintBuffer++) = '.';
*(PrintBuffer++) = '0' + (char)((Micros % 100000) / 10000);
*(PrintBuffer++) = '0' + (char)((Micros % 10000) / 1000);
*(PrintBuffer++) = '0' + (char)((Micros % 1000) / 100);
*(PrintBuffer++) = '0' + (char)((Micros % 100) / 10);
*(PrintBuffer++) = '0' + (char)(Micros % 10);
*PrintBuffer = '\0';
return CFE_SUCCESS;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants