diff --git a/src/unit-test-coverage/ut-stubs/inc/overrides/time.h b/src/unit-test-coverage/ut-stubs/inc/overrides/time.h index 2e40c1d91..118fc8962 100644 --- a/src/unit-test-coverage/ut-stubs/inc/overrides/time.h +++ b/src/unit-test-coverage/ut-stubs/inc/overrides/time.h @@ -44,6 +44,7 @@ extern int OCS_clock_nanosleep (OCS_clockid_t clock_id, int flags, const struct extern int OCS_clock_settime (OCS_clockid_t clock_id, const struct OCS_timespec * tp); extern int OCS_timer_create (OCS_clockid_t clock_id, struct OCS_sigevent * evp, OCS_timer_t * timerid); extern int OCS_timer_delete (OCS_timer_t timerid) ; +extern int OCS_timer_gettime (OCS_timer_t timerid, struct OCS_itimerspec * value); extern int OCS_timer_settime (OCS_timer_t timerid, int flags, const struct OCS_itimerspec * value, struct OCS_itimerspec * ovalue); extern int OCS_timer_connect(OCS_timer_t, OCS_VOIDFUNCPTR, int); diff --git a/src/unit-test-coverage/ut-stubs/src/posix-time-stubs.c b/src/unit-test-coverage/ut-stubs/src/posix-time-stubs.c index d2ad683fb..094afa0a9 100644 --- a/src/unit-test-coverage/ut-stubs/src/posix-time-stubs.c +++ b/src/unit-test-coverage/ut-stubs/src/posix-time-stubs.c @@ -75,3 +75,17 @@ int OCS_timer_settime (OCS_timer_t timerid, int flags, const struct OCS_itimersp return Status; } +int OCS_timer_gettime (OCS_timer_t timerid, struct OCS_itimerspec * value) +{ + int32 Status; + + Status = UT_DEFAULT_IMPL(OCS_timer_gettime); + + if (Status == 0 && UT_Stub_CopyToLocal(UT_KEY(OCS_timer_gettime), value, sizeof(*value)) < sizeof(*value)) + { + memset(value, 0, sizeof(*value)); + } + + return Status; +} + diff --git a/src/unit-test-coverage/vxworks/modules/inc/ut-ostimer.h b/src/unit-test-coverage/vxworks/modules/inc/ut-ostimer.h index 6e6640a9d..58e2fb7f1 100644 --- a/src/unit-test-coverage/vxworks/modules/inc/ut-ostimer.h +++ b/src/unit-test-coverage/vxworks/modules/inc/ut-ostimer.h @@ -22,7 +22,7 @@ int32 OS_VxWorks_TimeBaseAPI_Impl_Init(void); void Osapi_Internal_ResetState(void); -void Osapi_Internal_Setup(uint32 local_id, int signo); +void Osapi_Internal_Setup(uint32 local_id, int signo, bool reset_flag); /** * Invokes OS_VxWorks_SigWait() with the given arguments. diff --git a/src/unit-test-coverage/vxworks/modules/src/stub-map-to-real.h b/src/unit-test-coverage/vxworks/modules/src/stub-map-to-real.h index d9042e6f7..f9761ac4a 100644 --- a/src/unit-test-coverage/vxworks/modules/src/stub-map-to-real.h +++ b/src/unit-test-coverage/vxworks/modules/src/stub-map-to-real.h @@ -238,6 +238,7 @@ #define timer_connect OCS_timer_connect #define timer_create OCS_timer_create #define timer_delete OCS_timer_delete +#define timer_gettime OCS_timer_gettime #define timer_settime OCS_timer_settime #define timer_t OCS_timer_t #define timespec OCS_timespec diff --git a/src/unit-test-coverage/vxworks/modules/src/ut-ostimer.c b/src/unit-test-coverage/vxworks/modules/src/ut-ostimer.c index 261ead83c..34b8bd86a 100644 --- a/src/unit-test-coverage/vxworks/modules/src/ut-ostimer.c +++ b/src/unit-test-coverage/vxworks/modules/src/ut-ostimer.c @@ -86,7 +86,7 @@ void Osapi_Internal_ResetState(void) memset(OS_stub_timecb_table, 0, sizeof(OS_stub_timecb_table)); } -void Osapi_Internal_Setup(uint32 local_id, int signo) +void Osapi_Internal_Setup(uint32 local_id, int signo, bool reset_flag) { static int FAKE_TASK; static int FAKE_SEM; @@ -94,5 +94,6 @@ void Osapi_Internal_Setup(uint32 local_id, int signo) OS_impl_timebase_table[local_id].assigned_signal = signo; OS_impl_timebase_table[local_id].handler_task = &FAKE_TASK; OS_impl_timebase_table[local_id].handler_mutex = &FAKE_SEM; + OS_impl_timebase_table[local_id].reset_flag = reset_flag; } diff --git a/src/unit-test-coverage/vxworks/src/coveragetest-ostimer.c b/src/unit-test-coverage/vxworks/src/coveragetest-ostimer.c index 13658258f..c729379ca 100644 --- a/src/unit-test-coverage/vxworks/src/coveragetest-ostimer.c +++ b/src/unit-test-coverage/vxworks/src/coveragetest-ostimer.c @@ -95,7 +95,7 @@ void Test_OS_TimeBaseCreate_Impl(void) * and therefore cause future calls to skip this block. */ OS_global_timebase_table[1].active_id = 0x1; - Osapi_Internal_Setup(1,OCS_SIGRTMIN); + Osapi_Internal_Setup(1,OCS_SIGRTMIN, false); UT_SetForceFail(UT_KEY(OCS_sigismember), true); OSAPI_TEST_FUNCTION_RC(OS_TimeBaseCreate_Impl(0), OS_TIMER_ERR_UNAVAILABLE); UT_ResetState(UT_KEY(OCS_sigismember)); @@ -152,13 +152,18 @@ void Test_OS_VxWorks_SigWait(void) int signo = OCS_SIGRTMIN; OS_global_timebase_table[0].active_id = 0x12345; + OS_timebase_table[0].nominal_start_time = 8888; OS_timebase_table[0].nominal_interval_time = 5555; - Osapi_Internal_Setup(0, signo); + Osapi_Internal_Setup(0, signo, true); + UT_SetDataBuffer(UT_KEY(OCS_sigwait),&signo,sizeof(signo),false); + OSAPI_TEST_FUNCTION_RC(Osapi_Internal_CallSigWaitFunc(0), 8888); + UT_SetDataBuffer(UT_KEY(OCS_sigwait),&signo,sizeof(signo),false); + OSAPI_TEST_FUNCTION_RC(Osapi_Internal_CallSigWaitFunc(0), 5555); UT_SetDataBuffer(UT_KEY(OCS_sigwait),&signo,sizeof(signo),false); OSAPI_TEST_FUNCTION_RC(Osapi_Internal_CallSigWaitFunc(0), 5555); - Osapi_Internal_Setup(0, 0); + Osapi_Internal_Setup(0, 0, false); OS_global_timebase_table[0].active_id = 0; OS_timebase_table[0].nominal_interval_time = 0; } @@ -170,7 +175,7 @@ void Test_OS_TimeBaseSet_Impl(void) */ OSAPI_TEST_FUNCTION_RC(OS_TimeBaseSet_Impl(0,1,1), OS_ERR_NOT_IMPLEMENTED); - Osapi_Internal_Setup(0, OCS_SIGRTMIN); + Osapi_Internal_Setup(0, OCS_SIGRTMIN, false); OSAPI_TEST_FUNCTION_RC(OS_TimeBaseSet_Impl(0,1,1), OS_SUCCESS); UT_SetForceFail(UT_KEY(OCS_timer_settime), -1); @@ -182,7 +187,7 @@ void Test_OS_TimeBaseDelete_Impl(void) /* Test Case For: * int32 OS_TimeBaseDelete_Impl(uint32 timer_id) */ - Osapi_Internal_Setup(0, OCS_SIGRTMIN); + Osapi_Internal_Setup(0, OCS_SIGRTMIN, false); OSAPI_TEST_FUNCTION_RC(OS_TimeBaseDelete_Impl(0), OS_SUCCESS); }