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

TBL missing coverage in cfe_tbl_api.c function CFE_TBL_Register #1837

Open
nmullane opened this issue Aug 18, 2021 · 1 comment
Open

TBL missing coverage in cfe_tbl_api.c function CFE_TBL_Register #1837

nmullane opened this issue Aug 18, 2021 · 1 comment

Comments

@nmullane
Copy link
Contributor

Is your feature request related to a problem? Please describe.
CFE_TBL_Register function contains two hard to reach lines (370-371) that remain untested, preventing us from reaching 100% line coverage.

  12: 360:          if (Status == CFE_ES_CDS_ALREADY_EXISTS)
    : 361:          {
   4: 362:              Status = CFE_TBL_GetWorkingBuffer(&WorkingBufferPtr, RegRecPtr, true);
    : 363:         
   4: 364:              if (Status != CFE_SUCCESS)
    : 365:              {
    : 366:                  /* Unable to get a working buffer - this error is not really */
    : 367:                  /* possible at this point during table registration.  But we */
    : 368:                  /* do need to handle the error case because if the function */
    : 369:                  /* call did fail, WorkingBufferPtr would be a NULL pointer. */
## 0: 370:                  CFE_ES_GetAppName(AppName, ThisAppId, sizeof(AppName));
## 0: 371:                  CFE_ES_WriteToSysLog("%s: Failed to get work buffer for '%s.%s' (ErrCode=0x%08X)\n",
    : 372:                                       __func__, AppName, Name, (unsigned int)Status);
    : 373:              }
    : 374:              else
    : 375:              {
    : 376:                  /* CDS exists for this table - try to restore the data */
   4: 377:                  Status = CFE_ES_RestoreFromCDS(WorkingBufferPtr->BufferPtr, RegRecPtr->CDSHandle);
    : 378:         
   4: 379:                  if (Status != CFE_SUCCESS)
    : 380:                  {
   1: 381:                      CFE_ES_GetAppName(AppName, ThisAppId, sizeof(AppName));
   1: 382:                      CFE_ES_WriteToSysLog("%s: Failed to recover '%s.%s' from CDS (ErrCode=0x%08X)\n",
    : 383:                                           __func__, AppName, Name, (unsigned int)Status);
    : 384:                  }
    : 385:              }

Describe the solution you'd like
These lines should be safe to leave uncovered because they do not contain any potential to access a NULL pointer or anything else similarly dangerous.

Additional context
Lines 370 and 371 are currently impossible to cover as noted in the code comment because line 362 calls GetWorkingBuffer with true for the third argument which skips over anything that could return a non CFE_SUCCESS code.

Requester Info
Niall Mullane - GSFC 582 Intern

@nmullane nmullane changed the title Missing coverage in cfe_tbl_api.c Missing coverage in cfe_tbl_api.c function CFE_TBL_Register Aug 18, 2021
@skliper skliper changed the title Missing coverage in cfe_tbl_api.c function CFE_TBL_Register TBL missing coverage in cfe_tbl_api.c function CFE_TBL_Register Aug 26, 2021
@avan989
Copy link
Contributor

avan989 commented Jun 21, 2023

Code coverage is not possible without changing the implementation. Getting to this branch would require GetWorkingBuffer return != CFE_SUCCESS which would require either RegRecPtr->TableLoadedOnce = true or CalledByApp = false (Parameter for GetWorkingBuffer). Since CalledByApp is hard-coded to be true, you can only set RegRecPtr.

The only way to set RegRecPtr->TableLoadedOnce to true if this was a dump-only table (CFE_TBL_OPT_DUMP_ONLY) but in order to get to this branch, it would have to be a critical table (CFE_TBL_OPT_CRITICAL). A dump-only table and a critical table (CFE_TBL_OPT_DUMP_ONLY | CFE_TBL_OPT_CRITICAL) is not considered a valid option.

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

3 participants