Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
thnkslprpt committed Oct 10, 2024
1 parent c1e7a54 commit 8194a06
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/tests/bin-sem-test/bin-sem-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,6 @@ void Test_BinSem(void)
memset(&sem_prop, 0, sizeof(sem_prop));
memset(task_counter, 0, sizeof(task_counter));

// sem_id[0] = OS_OBJECT_ID_UNDEFINED;

/* Valid create and name taken */
UtAssert_INT32_EQ(OS_BinSemCreate(&sem_id[0], "Test_Sem", 0, 0), OS_SUCCESS);
UtAssert_INT32_EQ(OS_BinSemCreate(&sem_id[1], "Test_Sem", 0, 0), OS_ERR_NAME_TAKEN);

/* Invalid id checks */
UtAssert_INT32_EQ(OS_BinSemGetName(OS_OBJECT_ID_UNDEFINED, &sem_prop), OS_ERR_INVALID_ID);
UtAssert_INT32_EQ(OS_BinSemGetCreator(OS_OBJECT_ID_UNDEFINED, &sem_prop), OS_ERR_INVALID_ID);
Expand All @@ -98,9 +92,14 @@ void Test_BinSem(void)
UtAssert_INT32_EQ(OS_BinSemTimedWait(OS_OBJECT_ID_UNDEFINED, 0), OS_ERR_INVALID_ID);
UtAssert_INT32_EQ(OS_BinSemDelete(OS_OBJECT_ID_UNDEFINED), OS_ERR_INVALID_ID);

/* Null checks */
/* OS_BinSemCreate NULL checks */
UtAssert_INT32_EQ(OS_BinSemCreate(NULL, "Test_Sem", 0, 0), OS_INVALID_POINTER);
UtAssert_INT32_EQ(OS_BinSemCreate(&sem_id[0], NULL, 0, 0), OS_INVALID_POINTER);

// Initialize sem_id[0] to a valid value for the following NULL checks
sem_id[0] = OS_OBJECT_ID_UNDEFINED;

// OS_BinSemGet* NULL checks
UtAssert_INT32_EQ(OS_BinSemGetName(sem_id[0], NULL), OS_INVALID_POINTER);
UtAssert_INT32_EQ(OS_BinSemGetCreator(sem_id[0], NULL), OS_INVALID_POINTER);
UtAssert_INT32_EQ(OS_BinSemGetValue(sem_id[0], NULL), OS_INVALID_POINTER);
Expand All @@ -112,6 +111,9 @@ void Test_BinSem(void)
UtAssert_INT32_EQ(OS_BinSemCreate(&sem_id[0], long_name, 0, 0), OS_ERR_NAME_TOO_LONG);
UtAssert_INT32_EQ(OS_BinSemGetIdByName(&sem_id[0], long_name), OS_ERR_NAME_TOO_LONG);

/* Valid create and name taken */
UtAssert_INT32_EQ(OS_BinSemCreate(&sem_id[0], "Test_Sem", 0, 0), OS_SUCCESS);
UtAssert_INT32_EQ(OS_BinSemCreate(&sem_id[1], "Test_Sem", 0, 0), OS_ERR_NAME_TAKEN);

/* Nonzero create */
UtAssert_INT32_EQ(OS_BinSemCreate(&sem_id[1], "Test_Sem_Nonzero", 1, 0), OS_SUCCESS);
Expand Down

0 comments on commit 8194a06

Please sign in to comment.