Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ A clear and concise description of what the contribution is.
**Testing performed**
Steps taken to test the contribution:
1. Build steps '...'
1. Execution steps '...'
2. Execution steps '...'

**Expected behavior changes**
A clear and concise description of how this contribution will change behavior and level of impact.
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/codeql-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ name: "CodeQL Analysis"
on:
push:
pull_request:

jobs:
codeql:
name: Codeql
uses: nasa/cFS/.github/workflows/codeql-reusable.yml@main
with:
with:
component-path: psp
make: 'make -C build/native/default_cpu1/psp'
6 changes: 3 additions & 3 deletions .github/workflows/icbundle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,13 @@ jobs:
done
changelog_entry="${changelog_entry}\n${see_entry}\n"
sed -ir "s|# Changelog|$changelog_entry|" CHANGELOG.md

buildnumber_entry=$'#define CFE_PSP_IMPL_BUILD_NUMBER '${rev_num}
sed -ir "s|#define CFE_PSP_IMPL_BUILD_NUMBER.*|$buildnumber_entry|" fsw/mcp750-vxworks/inc/psp_version.h

buildnumber_entry=$'#define CFE_PSP_IMPL_BUILD_NUMBER '${rev_num}
sed -ir "s|#define CFE_PSP_IMPL_BUILD_NUMBER.*|$buildnumber_entry|" fsw/pc-linux/inc/psp_version.h

buildnumber_entry=$'#define CFE_PSP_IMPL_BUILD_NUMBER '${rev_num}
sed -ir "s|#define CFE_PSP_IMPL_BUILD_NUMBER.*|$buildnumber_entry|" fsw/pc-rtems/inc/psp_version.h
- name: Commit and Push Updates to IC Branch
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## Development Build: equuleus-rc1+dev85
- 'Fix #458, Correct minor logic bug in UT_DefaultHandler_PCS_read'
- See: <https://github.com/nasa/PSP/pull/459>


## Development Build: equuleus-rc1+dev77
- 'Fix #461, set stdout to unbuffered on pc-linux'
- See: <https://github.com/nasa/PSP/pull/462>
Expand Down
2 changes: 1 addition & 1 deletion fsw/mcp750-vxworks/src/cfe_psp_memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@ int32 CFE_PSP_GetCFETextSegmentInfo(cpuaddr *PtrToCFESegment, uint32 *SizeOfCFES
}
else
{
return_code = CFE_PSP_SUCCESS;
return_code = CFE_PSP_ERROR;
}
}
}
Expand Down
93 changes: 35 additions & 58 deletions fsw/modules/eeprom_mmap_file/cfe_psp_eeprom_mmap_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <sys/mman.h>
#include <sys/stat.h>

Expand All @@ -46,81 +47,57 @@ CFE_PSP_MODULE_DECLARE_SIMPLE(eeprom_mmap_file);
*/
int32 CFE_PSP_SetupEEPROM(uint32 EEPROMSize, cpuaddr *EEPROMAddress)
{
int FileDescriptor;
int ReturnStatus;
char * DataBuffer;
struct stat StatBuf;
int FileDescriptor;
int ReturnStatus;
void *DataBuffer;

/*
** Check to see if the file has been created.
** If not, create it.
** If so, then open it for read/write
*/
ReturnStatus = stat(EEPROM_FILE, &StatBuf);
if (ReturnStatus == -1)
DataBuffer = NULL;
FileDescriptor = open(EEPROM_FILE, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR);
if (FileDescriptor < 0)
{
/*
** File does not exist, create it.
*/
FileDescriptor = open(EEPROM_FILE, O_RDWR | O_CREAT, S_IRWXU);
if (FileDescriptor == -1)
{
OS_printf("CFE_PSP: Cannot open EEPROM File: %s\n", EEPROM_FILE);
return -1;
}
else
{
/*
** Need to seek to the desired EEPROM size
*/
if (lseek(FileDescriptor, EEPROMSize - 1, SEEK_SET) == -1)
{
OS_printf("CFE_PSP: Cannot Seek to end of EEPROM file.\n");
close(FileDescriptor);
return -1;
}

/*
** Write a byte at the end of the File
*/
if (write(FileDescriptor, "", 1) != 1)
{
OS_printf("CFE_PSP: Cannot write to EEPROM file\n");
close(FileDescriptor);
return -1;
}
}
OS_printf("CFE_PSP: Cannot open EEPROM File: %s\n", EEPROM_FILE);
perror("CFE_PSP: open");
ReturnStatus = CFE_PSP_ERROR;
}
else if (ftruncate(FileDescriptor, EEPROMSize) < 0)
{
OS_printf("CFE_PSP: ftruncate(%s) error: %s\n", EEPROM_FILE, strerror(errno));
ReturnStatus = CFE_PSP_ERROR;
}
else
{
/*
** File exists
*/
FileDescriptor = open(EEPROM_FILE, O_RDWR);
if (FileDescriptor == -1)
DataBuffer = mmap(NULL, EEPROMSize, PROT_READ | PROT_WRITE, MAP_SHARED, FileDescriptor, 0);
if (DataBuffer == (void *)(-1))
{
OS_printf("CFE_PSP: mmap to EEPROM File failed: %s\n", strerror(errno));
ReturnStatus = CFE_PSP_ERROR;
}
else
{
OS_printf("CFE_PSP: Cannot open EEPROM File: %s\n", EEPROM_FILE);
perror("CFE_PSP: open");
return -1;
ReturnStatus = CFE_PSP_SUCCESS;
}
}

/*
** Map the file to a memory space
*/
if ((DataBuffer = mmap(NULL, EEPROMSize, PROT_READ | PROT_WRITE, MAP_SHARED, FileDescriptor, 0)) == (void *)(-1))
/* POSIX says that a mapped pointer counts as a file ref, so the FD
* can be safely closed in all cases, success or failure */
if (FileDescriptor >= 0)
{
OS_printf("CFE_PSP: mmap to EEPROM File failed\n");
close(FileDescriptor);
return -1;
}

/*
** Return the address to the caller
*/
*EEPROMAddress = (cpuaddr)DataBuffer;
if (ReturnStatus == CFE_PSP_SUCCESS)
{
*EEPROMAddress = (cpuaddr)DataBuffer;
}
else
{
*EEPROMAddress = 0;
}

return 0;
return ReturnStatus;
}

/* For read/write - As this is mmap'ed we dereference the pointer directly.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,28 +71,12 @@ void Test_eeprom_mmap_file_Init(void)
UT_SetDeferredRetcode(UT_KEY(PCS_mmap), 1, -1);
UtAssert_VOIDCALL(eeprom_mmap_file_Init(1));

/* fail to create new file file */
/* fail to open file */
UT_SetDeferredRetcode(UT_KEY(PCS_open), 1, -1);
UtAssert_VOIDCALL(eeprom_mmap_file_Init(1));

/* file exists */
UT_SetDefaultReturnValue(UT_KEY(PCS_stat), -1);
UtAssert_VOIDCALL(eeprom_mmap_file_Init(1));

/* fail to open existing file */
UT_SetDeferredRetcode(UT_KEY(PCS_open), 1, -1);
UtAssert_VOIDCALL(eeprom_mmap_file_Init(1));

/* fail to seek in existing file */
UT_SetDeferredRetcode(UT_KEY(PCS_lseek), 1, -1);
UtAssert_VOIDCALL(eeprom_mmap_file_Init(1));

/* write success in existing file */
UT_SetDeferredRetcode(UT_KEY(PCS_write), 1, 1);
UtAssert_VOIDCALL(eeprom_mmap_file_Init(1));

/* fail to write a byte in existing file */
UT_SetDeferredRetcode(UT_KEY(PCS_write), 1, -1);
/* fail to resize file */
UT_SetDeferredRetcode(UT_KEY(PCS_ftruncate), 1, -1);
UtAssert_VOIDCALL(eeprom_mmap_file_Init(1));
}

Expand Down
1 change: 1 addition & 0 deletions unit-test-coverage/ut-stubs/inc/PCS_unistd.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
/* ----------------------------------------- */

extern int PCS_close(int fd);
extern int PCS_ftruncate(int fd, PCS_off_t len);
extern PCS_gid_t PCS_getegid(void);
extern PCS_uid_t PCS_geteuid(void);
extern long int PCS_gethostid(void);
Expand Down
1 change: 1 addition & 0 deletions unit-test-coverage/ut-stubs/override_inc/unistd.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#define STDERR_FILENO PCS_STDERR_FILENO

#define close PCS_close
#define ftruncate PCS_ftruncate
#define getegid PCS_getegid
#define geteuid PCS_geteuid
#define gethostid PCS_gethostid
Expand Down
20 changes: 10 additions & 10 deletions unit-test-coverage/ut-stubs/src/PCS_string_handlers.c
Original file line number Diff line number Diff line change
Expand Up @@ -165,17 +165,17 @@ void UT_DefaultHandler_PCS_strcat(void *UserObj, UT_EntryKey_t FuncKey, const UT

void UT_DefaultHandler_PCS_strncat(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context)
{
/* char *PCS_strncat(char *dest, const char *src, size_t size) */
/* char *PCS_strncat(char *dest, const char *src, size_t n) */
void * dest = UT_Hook_GetArgValueByName(Context, "dest", void *);
const void *src = UT_Hook_GetArgValueByName(Context, "src", const void *);
size_t size = UT_Hook_GetArgValueByName(Context, "size", size_t);
size_t n = UT_Hook_GetArgValueByName(Context, "n", size_t);

char *Result;

if (!UT_Stub_GetInt32StatusCode(Context, NULL))
{
/* Perform the real operation */
Result = strncat(dest, src, size);
Result = strncat(dest, src, n);
UT_Stub_SetReturnValue(FuncKey, Result);
}
}
Expand Down Expand Up @@ -215,33 +215,33 @@ void UT_DefaultHandler_PCS_strcmp(void *UserObj, UT_EntryKey_t FuncKey, const UT

void UT_DefaultHandler_PCS_strcpy(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context)
{
/* char *PCS_strcpy(char *dst, const char *src) */
char * dst = UT_Hook_GetArgValueByName(Context, "dst", char *);
/* char *PCS_strcpy(char *dest, const char *src) */
char * dest = UT_Hook_GetArgValueByName(Context, "dest", char *);
const char *src = UT_Hook_GetArgValueByName(Context, "src", const char *);

char *Result;

if (!UT_Stub_GetInt32StatusCode(Context, NULL))
{
/* Perform the real operation */
Result = strcpy(dst, src);
Result = strcpy(dest, src);
UT_Stub_SetReturnValue(FuncKey, Result);
}
}

void UT_DefaultHandler_PCS_strncpy(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context)
{
/* char *PCS_strncpy(char *dst, const char *src, size_t size) */
char * dst = UT_Hook_GetArgValueByName(Context, "dst", char *);
/* char *PCS_strncpy(char *dest, const char *src, size_t n) */
char * dest = UT_Hook_GetArgValueByName(Context, "dest", char *);
const char *src = UT_Hook_GetArgValueByName(Context, "src", const char *);
size_t size = UT_Hook_GetArgValueByName(Context, "size", size_t);
size_t n = UT_Hook_GetArgValueByName(Context, "n", size_t);

char *Result;

if (!UT_Stub_GetInt32StatusCode(Context, NULL))
{
/* Perform the real operation */
Result = strncpy(dst, src, size);
Result = strncpy(dest, src, n);
UT_Stub_SetReturnValue(FuncKey, Result);
}
}
Expand Down
2 changes: 1 addition & 1 deletion unit-test-coverage/ut-stubs/src/PCS_unistd_handlers.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ void UT_DefaultHandler_PCS_read(void *UserObj, UT_EntryKey_t FuncKey, const UT_S
memset(buf, 'r', Status);
retval = Status;
}
else if (UT_GetStubCount(FuncKey < 4))
else if (UT_GetStubCount(FuncKey) < 4)
{
memset(buf, 'r', nbytes);
retval = nbytes;
Expand Down
17 changes: 17 additions & 0 deletions unit-test-coverage/ut-stubs/src/PCS_unistd_stubs.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,23 @@ int PCS_close(int fd)
return UT_GenStub_GetReturnValue(PCS_close, int);
}

/*
* ----------------------------------------------------
* Generated stub function for PCS_ftruncate()
* ----------------------------------------------------
*/
int PCS_ftruncate(int fd, PCS_off_t len)
{
UT_GenStub_SetupReturnBuffer(PCS_ftruncate, int);

UT_GenStub_AddParam(PCS_ftruncate, int, fd);
UT_GenStub_AddParam(PCS_ftruncate, PCS_off_t, len);

UT_GenStub_Execute(PCS_ftruncate, Basic, NULL);

return UT_GenStub_GetReturnValue(PCS_ftruncate, int);
}

/*
* ----------------------------------------------------
* Generated stub function for PCS_getegid()
Expand Down
2 changes: 1 addition & 1 deletion ut-stubs/src/cfe_psp_cds_api_handlers.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
************************************************************************/

/*
** File: ut_bsp_stubs.c
** File: cfe_psp_cds_api_handlers.c
**
** Purpose:
** Unit test stubs for BSP routines
Expand Down
2 changes: 1 addition & 1 deletion ut-stubs/src/cfe_psp_exception_api_handlers.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
************************************************************************/

/*
** File: ut_bsp_stubs.c
** File: cfe_psp_exception_api_handlers.c
**
** Purpose:
** Unit test stubs for BSP routines
Expand Down
2 changes: 1 addition & 1 deletion ut-stubs/src/cfe_psp_id_api_handlers.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
************************************************************************/

/*
** File: ut_bsp_stubs.c
** File: cfe_psp_id_api_handlers.c
**
** Purpose:
** Unit test stubs for BSP routines
Expand Down
2 changes: 1 addition & 1 deletion ut-stubs/src/cfe_psp_memrange_api_handlers.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
************************************************************************/

/*
** File: ut_bsp_stubs.c
** File: cfe_psp_memrange_api_handlers.c
**
** Purpose:
** Unit test stubs for BSP routines
Expand Down
2 changes: 1 addition & 1 deletion ut-stubs/src/cfe_psp_timertick_api_handlers.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
************************************************************************/

/*
** File: ut_bsp_stubs.c
** File: cfe_psp_timertick_api_handlers.c
**
** Purpose:
** Unit test stubs for BSP routines
Expand Down
2 changes: 1 addition & 1 deletion ut-stubs/src/cfe_psp_version_api_handlers.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
************************************************************************/

/*
** File: ut_bsp_stubs.c
** File: cfe_psp_version_api_handlers.c
**
** Purpose:
** Unit test stubs for BSP routines
Expand Down
2 changes: 1 addition & 1 deletion ut-stubs/src/cfe_psp_watchdog_api_handlers.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
************************************************************************/

/*
** File: ut_bsp_stubs.c
** File: cfe_psp_watchdog_api_handlers.c
**
** Purpose:
** Unit test stubs for BSP routines
Expand Down
Loading