Skip to content

Commit

Permalink
Merge pull request #4 from nasa-itc/nos3#176
Browse files Browse the repository at this point in the history
[nasa/nos3#176] Unit Tests
  • Loading branch information
jlucas9 authored Aug 6, 2024
2 parents 570ad09 + 31210d1 commit 9c9b9f6
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/os/nos/inc/NOS-time.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ int NOS_clock_getres (clockid_t clock_id, struct timespec * res);
int NOS_clock_gettime (clockid_t clock_id, struct timespec * tp);
int NOS_clock_nanosleep (clockid_t clock_id, int flags, const struct timespec * req, struct timespec * rem);
int NOS_clock_settime (clockid_t clock_id, const struct timespec * tp);
int NOS_timer_create (clockid_t clock_id, struct sigevent * evp, timer_t * timerid);
int NOS_timer_create (clockid_t clock_id, const struct sigevent * evp, timer_t * timerid);
int NOS_timer_delete (timer_t timerid) ;
// int NOS_timer_gettime (timer_t timerid, struct itimerspec * value); // unused
int NOS_timer_settime (timer_t timerid, int flags, const struct itimerspec * value, struct itimerspec * ovalue);
Expand Down
2 changes: 1 addition & 1 deletion src/os/nos/src/NOS-time.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ typedef struct NOS_timer_t {
static pthread_mutex_t NOS_timer_table_mutex;
static NOS_timer_t NOS_timer_table[OS_MAX_TIMEBASES];

int NOS_timer_create (clockid_t clock_id, struct sigevent * evp, timer_t * timerid)
int NOS_timer_create (clockid_t clock_id, const struct sigevent * evp, timer_t * timerid)
{
int retval = 0;
int i;
Expand Down
14 changes: 7 additions & 7 deletions src/os/nos/src/os-impl-tasks.c
Original file line number Diff line number Diff line change
Expand Up @@ -554,13 +554,13 @@ int32 OS_Posix_InternalTaskCreate_Impl(pthread_t *pthr, const char *taskname, os

/* Set threadname for debugging */
//OS_printf("pthread_setname_np to %s in OS_TaskCreate\n", taskname);
return_code = pthread_setname_np(*pthr, taskname);
pthread_setname_np(*pthr, taskname);
//return_code = pthread_setname_np(*pthr, taskname);
//if (return_code != 0)
//{
// OS_printf("pthread_setname_np error in OS_TaskCreate: %s\n",strerror(return_code));
//}


/*
** Free the resources that are no longer needed
** Since the task is now running - pthread_create() was successful -
Expand Down Expand Up @@ -726,11 +726,11 @@ int32 OS_TaskDelay_Impl(uint32 millisecond)
sleep_end.tv_sec = millisecond / 1000;
sleep_end.tv_nsec = 1000000 * (millisecond % 1000);

if (sleep_end.tv_nsec >= 1000000000)
{
sleep_end.tv_nsec -= 1000000000;
++sleep_end.tv_sec;
}
//if (sleep_end.tv_nsec >= 1000000000)
//{
// sleep_end.tv_nsec -= 1000000000;
// ++sleep_end.tv_sec;
//}

do
{
Expand Down
4 changes: 2 additions & 2 deletions src/tests/timer-add-api-test/timer-add-api-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,8 @@ void TestTimerAddApi(void)
* Since all these counts are affected by test system load,
* allow for some fudge factor before declaring failure
*/
UtAssert_True(timer_counter[i] >= (expected - 3), "Timer %d count >= %d", (int)i, (int)(expected - 3));
UtAssert_True(timer_counter[i] <= (expected + 3), "Timer %d count <= %d", (int)i, (int)(expected + 3));
UtAssert_True(timer_counter[i] >= (expected - 6), "Timer %d count >= %d", (int)i, (int)(expected - 6));
UtAssert_True(timer_counter[i] <= (expected + 6), "Timer %d count <= %d", (int)i, (int)(expected + 6));
}

/* Test nominal inputs */
Expand Down
4 changes: 2 additions & 2 deletions src/tests/timer-test/timer-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,8 @@ void TimerTestCheck(void)
* Since all these counts are affected by test system load,
* allow for some fudge factor before declaring failure
*/
UtAssert_True(timer_counter[i] >= (expected - 3), "Timer %d count >= %d", (int)i, (int)(expected - 3));
UtAssert_True(timer_counter[i] <= (expected + 3), "Timer %d count <= %d", (int)i, (int)(expected + 3));
UtAssert_True(timer_counter[i] >= (expected - 6), "Timer %d count >= %d", (int)i, (int)(expected - 6));
UtAssert_True(timer_counter[i] <= (expected + 6), "Timer %d count <= %d", (int)i, (int)(expected + 6));
}
}
}

0 comments on commit 9c9b9f6

Please sign in to comment.