Skip to content

Commit

Permalink
Merge pull request #744 from nasa/integration-candidate
Browse files Browse the repository at this point in the history
osal Integration Candidate: 2021-01-05
  • Loading branch information
astrogeco authored Jan 7, 2021
2 parents d698a4d + 32fd5cf commit 81c4fa8
Show file tree
Hide file tree
Showing 15 changed files with 113 additions and 50 deletions.
54 changes: 54 additions & 0 deletions .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Static Analysis

# Run this workflow every time a new commit pushed to your repository
on:
push:
branches:
- main
pull_request:

jobs:

static-analysis:
name: Run cppcheck
runs-on: ubuntu-18.04

strategy:
fail-fast: false
matrix:
cppcheck: [all, osal]

steps:

- name: Install cppcheck
run: sudo apt-get install cppcheck -y

# Checks out a copy of the cfs bundle
- name: Checkout code
uses: actions/checkout@v2
with:
submodules: true

- name: Run bundle cppcheck
if: ${{matrix.cppcheck =='all'}}
run: cppcheck --force --inline-suppr --quiet . 2> ${{matrix.cppcheck}}_cppcheck_err.txt

# Run strict static analysis for embedded portions of osal
- name: osal strict cppcheck
if: ${{matrix.cppcheck =='osal'}}
run: |
cppcheck --force --inline-suppr --std=c99 --language=c --enable=warning,performance,portability,style --suppress=variableScope --inconclusive ./src/bsp ./src/os 2> ./${{matrix.cppcheck}}_cppcheck_err.txt
- name: Archive Static Analysis Artifacts
uses: actions/upload-artifact@v2
with:
name: ${{matrix.cppcheck}}-cppcheck-err
path: ./*cppcheck_err.txt

- name: Check for errors
run: |
if [[ -s ${{matrix.cppcheck}}_cppcheck_err.txt ]];
then
cat ${{matrix.cppcheck}}_cppcheck_err.txt
exit -1
fi
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,16 @@ The autogenerated OSAL user's guide can be viewed at <https://github.com/nasa/cF

## Version History

### Development Build: 5.1.0-rc1+dev149

- Document UtAssert_Message parameters, also adds "see also" note for helper macros.
- Fix doxygen typo
- Replace `OS_BinSemFlush` with `OS_BinSemGive` to prevent a rare race condition. Change the port numbers to be different from network test for when tests are run in parallel.
- Fix doxygen format errors. Usersguide now builds without warnings.
- Suppress invalid cppcheck warning in `OS_WaitForStateChange`
- Add cppcheck static analysis workflow to osal CI
- See <https://github.com/nasa/osal/pull/744>

### Development Build: 5.1.0-rc1+dev132

- Convert the OSAL Configuration Guide from docx and pdf to a markdown file.
Expand Down
2 changes: 2 additions & 0 deletions src/os/inc/osapi-bsp.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,6 @@ char *const *OS_BSP_GetArgV(void);
------------------------------------------------------------------*/
void OS_BSP_SetExitCode(int32 code);

/**@}*/

#endif
9 changes: 0 additions & 9 deletions src/os/inc/osapi-idmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,6 @@
#define OS_OBJECT_TYPE_USER 0x10 /**< @brief Object user type */
/**@}*/

/** @defgroup OSAPICore OSAL Core Operation APIs
*
* These are for OSAL core operations for startup/initialization, running, and shutdown.
* Typically only used in bsps, unit tests, psps, etc.
*
* Not intended for user application use
* @{
*/

/** @defgroup OSAPIObjUtil OSAL Object ID Utility APIs
* @{
*/
Expand Down
2 changes: 1 addition & 1 deletion src/os/inc/osapi-version.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
/*
* Development Build Macro Definitions
*/
#define OS_BUILD_NUMBER 132
#define OS_BUILD_NUMBER 149
#define OS_BUILD_BASELINE "v5.1.0-rc1"

/*
Expand Down
1 change: 1 addition & 0 deletions src/os/shared/src/osapi-idmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -762,6 +762,7 @@ void OS_WaitForStateChange(osal_objtype_t idtype, uint32 attempts)
/*
* After return, this task owns the table again
*/
/* cppcheck-suppress redundantAssignment */
objtype->table_owner = saved_owner_id;
}
}
Expand Down
12 changes: 6 additions & 6 deletions src/tests/select-test/select-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ void Setup_Server(void)
UtAssert_True(actual == expected, "OS_SocketAddrInit() (%ld) == OS_SUCCESS", (long)actual);

/* Set server port */
actual = OS_SocketAddrSetPort(&s_addr, 9997);
actual = OS_SocketAddrSetPort(&s_addr, 9994);
UtAssert_True(actual == expected, "OS_SocketAddrSetPort() (%ld) == OS_SUCCESS", (long)actual);

/* Set server address */
Expand Down Expand Up @@ -142,7 +142,7 @@ void Setup_Client(void)
UtAssert_True(actual == expected, "OS_SocketAddrInit() (%ld) == OS_SUCCESS", (long)actual);

/* Set client port */
actual = OS_SocketAddrSetPort(&c_addr, 9996);
actual = OS_SocketAddrSetPort(&c_addr, 9993);
UtAssert_True(actual == expected, "OS_SocketAddrSetPort() (%ld) == OS_SUCCESS", (long)actual);

/* Set client address */
Expand Down Expand Up @@ -193,7 +193,7 @@ void Setup_Server2(void)
UtAssert_True(actual == expected, "OS_SocketAddrInit() (%ld) == OS_SUCCESS", (long)actual);

/* Set server port */
actual = OS_SocketAddrSetPort(&s2_addr, 9998);
actual = OS_SocketAddrSetPort(&s2_addr, 9995);
UtAssert_True(actual == expected, "OS_SocketAddrSetPort() (%ld) == OS_SUCCESS", (long)actual);

/* Set server address */
Expand Down Expand Up @@ -227,7 +227,7 @@ void Setup_Client2(void)
UtAssert_True(actual == expected, "OS_SocketAddrInit() (%ld) == OS_SUCCESS", (long)actual);

/* Set client port */
actual = OS_SocketAddrSetPort(&c2_addr, 9995);
actual = OS_SocketAddrSetPort(&c2_addr, 9992);
UtAssert_True(actual == expected, "OS_SocketAddrSetPort() (%ld) == OS_SUCCESS", (long)actual);

/* Set client address */
Expand Down Expand Up @@ -281,8 +281,8 @@ void Teardown_Multi(void)
{
uint32 status;

status = OS_BinSemFlush(bin_sem_id);
UtAssert_True(status == OS_SUCCESS, "BinSem1 Teardown multi flush Rc=%d", (int)status);
status = OS_BinSemGive(bin_sem_id);
UtAssert_True(status == OS_SUCCESS, "BinSem1 Teardown multi give Rc=%d", (int)status);

OS_close(c2_socket_id);
Teardown_Single();
Expand Down
2 changes: 0 additions & 2 deletions src/unit-tests/inc/ut_os_support.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,6 @@ static inline bool UtOsalImplemented(int32 Fn, const char *File, uint32 Line)

/*--------------------------------------------------------------------------------*/

#define UT_OS_LOG(...) UtAssert_Message(UTASSERT_CASETYPE_INFO, __FILE__, __LINE__, __VA_ARGS__);

/*
* An osal_id_t value which is not OS_OBJECT_ID_UNDEFINED and also
* not aliasing any other valid value/type.
Expand Down
26 changes: 13 additions & 13 deletions src/unit-tests/oscore-test/ut_oscore_misc_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ void UT_os_apiinit_test()
void UT_os_printf_test()
{
OS_printf_enable();
UT_OS_LOG("OS_printf() - #1 Nominal [This is the expected stdout output after API call]\n");
UtPrintf("OS_printf() - #1 Nominal [This is the expected stdout output after API call]\n");
OS_printf("OS_printf() - #1 Nominal [ This is the expected stdout output after API call]\n");

UT_OS_TEST_RESULT("#1 Nominal - Manual inspection required", UTASSERT_CASETYPE_MIR);
Expand All @@ -184,7 +184,7 @@ void UT_os_printfenable_test()
OS_printf_disable();

OS_printf_enable();
UT_OS_LOG("OS_printf_enable() - #1 Nominal [This is the expected stdout output after API call]\n");
UtPrintf("OS_printf_enable() - #1 Nominal [This is the expected stdout output after API call]\n");
OS_printf("OS_printf_enable() - #1 Nominal [This is the expected stdout output after API call]\n");

UT_OS_TEST_RESULT("#1 Nominal - Manual inspection required", UTASSERT_CASETYPE_MIR);
Expand All @@ -205,18 +205,18 @@ void UT_os_printfenable_test()
void UT_os_printfdisable_test()
{
OS_printf_enable();
UT_OS_LOG("OS_printf_disable() - #1 Nominal [This is the expected stdout output before API call]\n");
UtPrintf("OS_printf_disable() - #1 Nominal [This is the expected stdout output before API call]\n");
OS_printf("OS_printf_disable() - #1 Nominal [This is the expected stdout output before API call]\n");

OS_printf_disable();
UT_OS_LOG("OS_printf_disable() - #1 Nominal [This is NOT the expected stdout output after API call]\n");
UtPrintf("OS_printf_disable() - #1 Nominal [This is NOT the expected stdout output after API call]\n");
OS_printf("OS_printf_disable() - #1 Nominal [This is NOT the expected stdout output after API call]\n");

UT_OS_TEST_RESULT("#1 Nominal - Manual inspection required", UTASSERT_CASETYPE_MIR);

/* Reset test environment */
OS_printf_enable();
UT_OS_LOG("OS_printf_disable() - #1 Nominal [This is the expected stdout output after test reset]\n");
UtPrintf("OS_printf_disable() - #1 Nominal [This is the expected stdout output after test reset]\n");
OS_printf("OS_printf_disable() - #1 Nominal [This is the expected stdout output after test reset]\n");
}

Expand Down Expand Up @@ -286,11 +286,11 @@ void UT_os_getlocaltime_test()
res = OS_GetLocalTime(&time_struct);
if (res == OS_SUCCESS)
{
UT_OS_LOG("\n");
UtPrintf("\n");
for (i = 0; i < 5; i++)
{
UT_OS_LOG("OS_GetLocalTime() - #3 Nominal ");
UT_OS_LOG("[Expecting output after API call to increase over time: %ld.%ld]\n", (long)time_struct.seconds,
UtPrintf("OS_GetLocalTime() - #3 Nominal ");
UtPrintf("[Expecting output after API call to increase over time: %ld.%ld]\n", (long)time_struct.seconds,
(long)time_struct.microsecs);

OS_TaskDelay(20);
Expand Down Expand Up @@ -378,8 +378,8 @@ void UT_os_setlocaltime_test()
{
for (i = 0; i < 5; i++)
{
UT_OS_LOG("OS_SetLocalTime() - #3 Nominal ");
UT_OS_LOG("[Expecting output before API call to increase over time: %ld.%ld]\n", (long)time_struct.seconds,
UtPrintf("OS_SetLocalTime() - #3 Nominal ");
UtPrintf("[Expecting output before API call to increase over time: %ld.%ld]\n", (long)time_struct.seconds,
(long)time_struct.microsecs);

OS_TaskDelay(20);
Expand All @@ -394,16 +394,16 @@ void UT_os_setlocaltime_test()
res = OS_SetLocalTime(&time_struct);
if (res == OS_SUCCESS)
{
UT_OS_LOG("OS_SetLocalTime() - #3 Nominal [New time set at %ld.%ld]\n", (long)time_struct.seconds,
UtPrintf("OS_SetLocalTime() - #3 Nominal [New time set at %ld.%ld]\n", (long)time_struct.seconds,
(long)time_struct.microsecs);

res = OS_GetLocalTime(&time_struct);
if (res == OS_SUCCESS)
{
for (i = 0; i < 5; i++)
{
UT_OS_LOG("OS_SetLocalTime() - #3 Nominal ");
UT_OS_LOG("[Expecting output after API call to increase over time: %ld.%ld]\n",
UtPrintf("OS_SetLocalTime() - #3 Nominal ");
UtPrintf("[Expecting output after API call to increase over time: %ld.%ld]\n",
(long)time_struct.seconds, (long)time_struct.microsecs);

OS_TaskDelay(20);
Expand Down
14 changes: 7 additions & 7 deletions src/unit-tests/oscore-test/ut_oscore_task_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ void generic_test_task(void)
task_id = OS_TaskGetId();
OS_TaskGetInfo(task_id, &task_prop);

UT_OS_LOG("Starting GenericTask: %s, id: %lx\n", task_prop.name, OS_ObjectIdToInteger(task_id));
UtPrintf("Starting GenericTask: %s, id: %lx\n", task_prop.name, OS_ObjectIdToInteger(task_id));

while (1)
{
Expand Down Expand Up @@ -322,7 +322,7 @@ void UT_os_task_delete_test()
**--------------------------------------------------------------------------------*/
void delete_handler_callback(void)
{
UT_OS_LOG("Task delete callback...\n");
UtPrintf("Task delete callback...\n");
}

/*--------------------------------------------------------------------------------*/
Expand All @@ -337,7 +337,7 @@ void delete_handler_test_task(void)
task_id = OS_TaskGetId();
OS_TaskGetInfo(task_id, &task_prop);

UT_OS_LOG("Starting DeleteTest Task: %s, id: %lx\n", task_prop.name, OS_ObjectIdToInteger(task_id));
UtPrintf("Starting DeleteTest Task: %s, id: %lx\n", task_prop.name, OS_ObjectIdToInteger(task_id));

g_task_result = OS_TaskInstallDeleteHandler(&delete_handler_callback);

Expand Down Expand Up @@ -443,7 +443,7 @@ void exit_test_task(void)
task_id = OS_TaskGetId();
OS_TaskGetInfo(task_id, &task_prop);

UT_OS_LOG("Starting ExitTest Task: %s, id: %lx\n", task_prop.name, OS_ObjectIdToInteger(task_id));
UtPrintf("Starting ExitTest Task: %s, id: %lx\n", task_prop.name, OS_ObjectIdToInteger(task_id));

/*
** The parent task will check to see if this task is valid.
Expand Down Expand Up @@ -675,7 +675,7 @@ void register_test_task(void)
task_id = OS_TaskGetId();
OS_TaskGetInfo(task_id, &task_prop);

UT_OS_LOG("Starting RegisterTest Task: %s\n", task_prop.name);
UtPrintf("Starting RegisterTest Task: %s\n", task_prop.name);
;

/*
Expand Down Expand Up @@ -775,7 +775,7 @@ void getid_test_task(void)
task_id = OS_TaskGetId();
OS_TaskGetInfo(task_id, &task_prop);

UT_OS_LOG("OS_TaskGetId() - #1 Nominal [This is the returned task Id=%lx]\n", OS_ObjectIdToInteger(task_id));
UtPrintf("OS_TaskGetId() - #1 Nominal [This is the returned task Id=%lx]\n", OS_ObjectIdToInteger(task_id));

while (1)
{
Expand Down Expand Up @@ -814,7 +814,7 @@ void UT_os_task_get_id_test()
{
OS_TaskDelay(500);

UT_OS_LOG("OS_TaskGetId() - #1 Nominal [This is the expected task Id=%lx]\n",
UtPrintf("OS_TaskGetId() - #1 Nominal [This is the expected task Id=%lx]\n",
OS_ObjectIdToInteger(g_task_ids[1]));

res = OS_TaskDelete(g_task_ids[1]); /* Won't hurt if its already deleted */
Expand Down
8 changes: 4 additions & 4 deletions src/unit-tests/osfile-test/ut_osfile_fileio_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -804,9 +804,9 @@ void UT_os_readfile_test()
OS_close(g_fDescs[0]);
OS_remove(g_fNames[0]);

UT_OS_LOG("OS_read() success test -- Write to file:\n\t%s\n", g_writeBuff);
UtPrintf("OS_read() success test -- Write to file:\n\t%s\n", g_writeBuff);
;
UT_OS_LOG("OS_read() success test -- Read from file:\n\t%s\n", g_readBuff);
UtPrintf("OS_read() success test -- Read from file:\n\t%s\n", g_readBuff);
;

UT_os_readfile_test_exit_tag:
Expand Down Expand Up @@ -975,9 +975,9 @@ void UT_os_writefile_test()
OS_close(g_fDescs[0]);
OS_remove(g_fNames[0]);

UT_OS_LOG("OS_write() success test -- Write to file:\n\t%s\n", g_writeBuff);
UtPrintf("OS_write() success test -- Write to file:\n\t%s\n", g_writeBuff);
;
UT_OS_LOG("OS_write() success test -- Read from file:\n\t%s\n", g_readBuff);
UtPrintf("OS_write() success test -- Read from file:\n\t%s\n", g_readBuff);
;

UT_os_writefile_test_exit_tag:
Expand Down
4 changes: 2 additions & 2 deletions src/unit-tests/osfile-test/ut_osfile_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,15 @@ int32 UT_os_setup_fs()
res = OS_mkfs(g_fsAddrPtr, g_devName, "RAM3", OSAL_SIZE_C(512), OSAL_BLOCKCOUNT_C(64));
if (res != OS_SUCCESS)
{
UT_OS_LOG("OS_mkfs() returns %d\n", (int)res);
UtPrintf("OS_mkfs() returns %d\n", (int)res);
;
goto UT_os_setup_fs_exit_tag;
}

res = OS_mount(g_devName, g_mntName);
if (res != OS_SUCCESS)
{
UT_OS_LOG("OS_mount() returns %d\n", (int)res);
UtPrintf("OS_mount() returns %d\n", (int)res);
;
OS_rmfs(g_devName);
goto UT_os_setup_fs_exit_tag;
Expand Down
2 changes: 1 addition & 1 deletion src/unit-tests/osnetwork-test/ut_osnetwork_misc_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ void UT_os_networkgetid_test()

/* NOTE: This API does not return error codes.
* Any return value could be valid */
UT_OS_LOG("OS_NetworkGetID() return value=%ld", (long)res);
UtPrintf("OS_NetworkGetID() return value=%ld", (long)res);
UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_MIR);

UT_os_networkgetid_test_exit_tag:
Expand Down
4 changes: 2 additions & 2 deletions src/unit-tests/ostimer-test/ut_ostimer_timerio_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ void UT_os_timerset_test()
intervalTime = 5;
g_toleranceVal = 0;

UT_OS_LOG("\nOS_TimerSet() - #3 Interval-too-short (clk_accuracy=%d)\n", (int)g_clkAccuracy);
UtPrintf("\nOS_TimerSet() - #3 Interval-too-short (clk_accuracy=%d)\n", (int)g_clkAccuracy);
res = OS_TimerSet(g_timerIds[3], startTime, intervalTime);
if (res == OS_SUCCESS)
{
Expand Down Expand Up @@ -588,7 +588,7 @@ void UT_os_timerset_test()
startTime = 1000;
intervalTime = 500000;
g_toleranceVal = intervalTime / 20; /* 5% */
UT_OS_LOG("\nOS_TimerSet() - #1 Nominal condition (clk_accuracy=%d)\n", (int)g_clkAccuracy);
UtPrintf("\nOS_TimerSet() - #1 Nominal condition (clk_accuracy=%d)\n", (int)g_clkAccuracy);
res = OS_TimerSet(g_timerIds[4], startTime, intervalTime);
if (res == OS_SUCCESS)
{
Expand Down
Loading

0 comments on commit 81c4fa8

Please sign in to comment.