Skip to content

Commit

Permalink
Fixes nasa#88, makes requested changes to docs and UT
Browse files Browse the repository at this point in the history
  • Loading branch information
dmknutsen committed Mar 27, 2020
1 parent 20a83c4 commit 960e7f4
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/bsp/mcp750-vxworks/config/osconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@


/*
** The maxium length allowed for a object (task,queue....) name
** The maxium length allowed for a object name (task, queue, etc.), including terminating null
*/
#define OS_MAX_API_NAME 20

Expand Down
2 changes: 1 addition & 1 deletion src/bsp/pc-linux/config/osconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
#define OS_MAX_LOCAL_PATH_LEN (OS_MAX_PATH_LEN + OS_FS_PHYS_NAME_LEN)

/*
** The maxium length allowed for a object (task,queue....) name
** The maxium length allowed for a object name (task, queue, etc.), including terminating null
*/
#define OS_MAX_API_NAME 20

Expand Down
2 changes: 1 addition & 1 deletion src/bsp/pc-rtems/config/osconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
#define OS_MAX_LOCAL_PATH_LEN (OS_MAX_PATH_LEN + OS_FS_PHYS_NAME_LEN)

/*
** The maxium length allowed for a object (task,queue....) name
** The maxium length allowed for a object name (task, queue, etc.), including terminating null
*/
#define OS_MAX_API_NAME 20

Expand Down
40 changes: 29 additions & 11 deletions src/unit-tests/ostimer-test/ut_ostimer_timerio_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -241,31 +241,36 @@ void UT_os_timerinit_test()
** 2) Expect the returned value to be
** (a) OS_ERR_NAME_TOO_LONG
** -----------------------------------------------------
** Test #3: Name-taken-argument condition
** Test #3: Unterminated String Test
** 1) Call this routine with a timer name equal to OS_MAX_API_NAME + 1 as argument
** 2) Expect the returned value to be
** (a) OS_ERR_NAME_TOO_LONG
** -----------------------------------------------------
** Test #4: Name-taken-argument condition
** 1) Call this routine with a valid timer name as argument
** 2) Expect the returned value to be
** (a) OS_SUCCESS
** 3) Call this routine the second time with the timer name used in #1 as argument
** 4) Expect the returned value to be
** (a) OS_ERR_NAME_TAKEN
** -----------------------------------------------------
** Test #4: No-free-ids condition
** Test #5: No-free-ids condition
** 1) Call this routine N number of times, where N = OS_MAX_TIMERS+1
** 2) Expect the returned value of the last call to be
** (a) OS_ERR_NO_FREE_IDS
** -----------------------------------------------------
** Test #5: Invalid-argument condition
** Test #6: Invalid-argument condition
** 1) Call this routine with a null pointer for callback as argument
** 2) Expect the returned value to be
** (a) OS_TIMER_ERR_INVALID_ARGS
** -----------------------------------------------------
** Test #6: Timer-unavailable condition
** Test #7: Timer-unavailable condition
** 1) Set up test to cause the OS call inside this routine to fail
** 2) Call this routine with valid arguments
** 3) Expect the returned value to be
** (a) OS_TIMER_ERR_UNAVAILABLE
** -----------------------------------------------------
** Test #7: Nominal condition
** Test #8: Nominal condition
** 1) Call this routine
** 2) Expect the returned value to be
** (a) OS_SUCCESS
Expand All @@ -281,7 +286,8 @@ void UT_os_timercreate_test()
{
const char* testDesc;
int32 res=0, i=0, j=0;
char tmpStr[UT_OS_NAME_BUFF_SIZE];
char tmpStr[UT_OS_NAME_BUFF_SIZE];
char unterminatedStringTest[OS_MAX_API_NAME+1];

/*-----------------------------------------------------*/
testDesc = "API not implemented";
Expand Down Expand Up @@ -319,7 +325,19 @@ void UT_os_timercreate_test()
UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE);

/*-----------------------------------------------------*/
testDesc = "#3 Name-taken";
testDesc = "#3 Unterminated String Test";
/* Reference https://github.com/nasa/osal/issues/88 for additional info */

strncpy( unterminatedStringTest, "12345678912345678900", OS_MAX_API_NAME + 1 );

if (OS_TimerCreate(&g_timerIds[2], unterminatedStringTest, &g_clkAccuracy, &UT_os_timercallback) ==
OS_ERR_NAME_TOO_LONG)
UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS);
else
UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE);

/*-----------------------------------------------------*/
testDesc = "#4 Name-taken";

if ((OS_TimerCreate(&g_timerIds[3], g_timerNames[3], &g_clkAccuracy, &UT_os_timercallback) ==
OS_SUCCESS) &&
Expand All @@ -333,7 +351,7 @@ void UT_os_timercreate_test()
OS_TimerDelete(g_timerIds[3]);

/*-----------------------------------------------------*/
testDesc = "#4 No-free-IDs";
testDesc = "#5 No-free-IDs";

for (i=0; i <= OS_MAX_TIMERS; i++)
{
Expand Down Expand Up @@ -363,7 +381,7 @@ void UT_os_timercreate_test()
OS_TimerDelete(g_timerIds[j]);

/*-----------------------------------------------------*/
testDesc = "#5 Invalid-arg";
testDesc = "#6 Invalid-arg";

if (OS_TimerCreate(&g_timerIds[5], g_timerNames[5], &g_clkAccuracy, NULL) ==
OS_TIMER_ERR_INVALID_ARGS)
Expand All @@ -372,12 +390,12 @@ void UT_os_timercreate_test()
UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE);

/*-----------------------------------------------------*/
testDesc = "#6 Timer-unavailable";
testDesc = "#7 Timer-unavailable";

UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_INFO);

/*-----------------------------------------------------*/
testDesc = "#7 Nominal";
testDesc = "#8 Nominal";

res = OS_TimerCreate(&g_timerIds[7], g_timerNames[7], &g_clkAccuracy, &UT_os_timercallback);
if (res == OS_SUCCESS)
Expand Down

0 comments on commit 960e7f4

Please sign in to comment.