Skip to content

Commit

Permalink
Merge pull request #1079 from nasa/integration-candidate
Browse files Browse the repository at this point in the history
osal Integration candidate: 2021-06-22
  • Loading branch information
astrogeco authored Jun 23, 2021
2 parents a3b7012 + 8036c9e commit 64a6b31
Show file tree
Hide file tree
Showing 30 changed files with 198 additions and 263 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ The autogenerated OSAL user's guide can be viewed at <https://github.com/nasa/cF
## Version History


### Development Build: v5.1.0-rc1+dev548

- implement missing parameter/retcode test permutations
- See <https://github.com/nasa/osal/pull/1079> and <https://github.com/nasa/cFS/pull/270>

### Development Build: v5.1.0-rc1+dev530

- Implement Coding Standard Rules in CodeQL
Expand Down
2 changes: 1 addition & 1 deletion src/os/inc/osapi-filesys.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ typedef struct
*
* OS_FileSysAddFixedMap(&fs_id, "/", "/root");
*
* @param[out] filesys_id A non-zero OSAL ID reflecting the file system
* @param[out] filesys_id A buffer to store the ID of the file system mapping @nonnull
* @param[in] phys_path The native system directory (an existing mount point) @nonnull
* @param[in] virt_path The virtual mount point of this filesystem @nonnull
*
Expand Down
4 changes: 2 additions & 2 deletions src/os/inc/osapi-network.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ int32 OS_NetworkGetID(void);
* If configured in the underlying network stack,
* this function retrieves the local hostname of the system.
*
* @param[out] host_name Buffer to hold name information
* @param[in] name_len Maximum length of host name buffer
* @param[out] host_name Buffer to hold name information @nonnull
* @param[in] name_len Maximum length of host name buffer @nonzero
*
* @return Execution status, see @ref OSReturnCodes
* @retval #OS_SUCCESS @copybrief OS_SUCCESS
Expand Down
2 changes: 1 addition & 1 deletion src/os/inc/osapi-task.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ typedef osal_task((*osal_task_entry)(void)); /**< @brief For task entry point */
* In that case, a stack of the requested size will be dynamically allocated from
* the system heap.
*
* @param[out] task_id will be set to the non-zero ID of the newly-created resource
* @param[out] task_id will be set to the non-zero ID of the newly-created resource @nonnull
* @param[in] task_name the name of the new resource to create @nonnull
* @param[in] function_pointer the entry point of the new task @nonnull
* @param[in] stack_pointer pointer to the stack for the task, or NULL
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 @@ -36,7 +36,7 @@
/*
* Development Build Macro Definitions
*/
#define OS_BUILD_NUMBER 530
#define OS_BUILD_NUMBER 548
#define OS_BUILD_BASELINE "v5.1.0-rc1"

/*
Expand Down
1 change: 1 addition & 0 deletions src/os/shared/src/osapi-filesys.c
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ int32 OS_FileSysAddFixedMap(osal_id_t *filesys_id, const char *phys_path, const
/*
* Validate inputs
*/
OS_CHECK_POINTER(filesys_id);
OS_CHECK_STRING(phys_path, sizeof(filesys->system_mountpt), OS_FS_ERR_PATH_TOO_LONG);
OS_CHECK_PATHNAME(virt_path);

Expand Down
2 changes: 2 additions & 0 deletions src/os/shared/src/osapi-queue.c
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ int32 OS_QueueGet(osal_id_t queue_id, void *data, size_t size, size_t *size_copi
/* Check Parameters */
OS_CHECK_POINTER(data);
OS_CHECK_POINTER(size_copied);
OS_CHECK_SIZE(size);

return_code = OS_ObjectIdGetById(OS_LOCK_MODE_NONE, LOCAL_OBJID_TYPE, queue_id, &token);
if (return_code == OS_SUCCESS)
Expand Down Expand Up @@ -205,6 +206,7 @@ int32 OS_QueuePut(osal_id_t queue_id, const void *data, size_t size, uint32 flag

/* Check Parameters */
OS_CHECK_POINTER(data);
OS_CHECK_SIZE(size);

return_code = OS_ObjectIdGetById(OS_LOCK_MODE_NONE, LOCAL_OBJID_TYPE, queue_id, &token);
if (return_code == OS_SUCCESS)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@

void TestFileSysAddFixedMapApi(void)
{
int32 expected;
int32 actual;
osal_id_t fs_id;
char translated_path[OS_MAX_LOCAL_PATH_LEN + 5];
char long_path[OS_MAX_PATH_LEN + 5];
Expand All @@ -51,42 +49,14 @@ void TestFileSysAddFixedMapApi(void)
* Just map /test to a dir of the same name, relative to current dir.
*/

expected = OS_FS_ERR_PATH_INVALID;
actual = OS_TranslatePath("/test/myfile.txt", translated_path);
UtAssert_True(actual == expected, "OS_TranslatePath() (%ld) == OS_SUCCESS", (long)actual);

expected = OS_SUCCESS;
actual = OS_FileSysAddFixedMap(&fs_id, "./test", "/test");
UtAssert_True(actual == expected, "OS_FileSysAddFixedMap() (%ld) == OS_SUCCESS", (long)actual);

expected = OS_SUCCESS;
actual = OS_TranslatePath("/test/myfile.txt", translated_path);
UtAssert_True(actual == expected, "OS_TranslatePath() (%ld) == OS_SUCCESS", (long)actual);
UtAssert_INT32_EQ(OS_TranslatePath("/test/myfile.txt", translated_path), OS_FS_ERR_PATH_INVALID);
UtAssert_INT32_EQ(OS_FileSysAddFixedMap(&fs_id, "./test", "/test"), OS_SUCCESS);
UtAssert_INT32_EQ(OS_TranslatePath("/test/myfile.txt", translated_path), OS_SUCCESS);

/* Test for invalid inputs */
expected = OS_ERR_NAME_TAKEN;
actual = OS_FileSysAddFixedMap(NULL, "./test", "/test");
UtAssert_True(actual == expected, "OS_FileSysAddFixedMap() (%ld) == OS_INVALID_POINTER", (long)actual);

expected = OS_INVALID_POINTER;
actual = OS_FileSysAddFixedMap(&fs_id, NULL, "/test");
UtAssert_True(actual == expected, "OS_FileSysAddFixedMap() (%ld) == OS_INVALID_POINTER", (long)actual);

expected = OS_INVALID_POINTER;
actual = OS_FileSysAddFixedMap(&fs_id, "./test", NULL);
UtAssert_True(actual == expected, "OS_FileSysAddFixedMap() (%ld) == OS_INVALID_POINTER", (long)actual);

expected = OS_INVALID_POINTER;
actual = OS_FileSysAddFixedMap(NULL, NULL, NULL);
UtAssert_True(actual == expected, "OS_FileSysAddFixedMap() (%ld) == OS_INVALID_POINTER", (long)actual);

expected = OS_INVALID_POINTER;
actual = OS_FileSysAddFixedMap(&fs_id, NULL, NULL);
UtAssert_True(actual == expected, "OS_FileSysAddFixedMap() (%ld) == OS_INVALID_POINTER", (long)actual);

expected = OS_INVALID_POINTER;
actual = OS_FileSysAddFixedMap(NULL, "./test", NULL);
UtAssert_True(actual == expected, "OS_FileSysAddFixedMap() (%ld) == OS_INVALID_POINTER", (long)actual);
UtAssert_INT32_EQ(OS_FileSysAddFixedMap(NULL, "./test", "/test"), OS_INVALID_POINTER);
UtAssert_INT32_EQ(OS_FileSysAddFixedMap(&fs_id, NULL, "/test"), OS_INVALID_POINTER);
UtAssert_INT32_EQ(OS_FileSysAddFixedMap(&fs_id, "./test", NULL), OS_INVALID_POINTER);

/* Test names too long (phys_path and virt_path have different limits) */
memset(long_path, 'x', sizeof(long_path) - 1);
Expand Down
41 changes: 27 additions & 14 deletions src/tests/network-api-test/network-api-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ void TestNetworkApiBadArgs(void)
/* OS_SocketAddrToString */
UtAssert_INT32_EQ(OS_SocketAddrToString(addr_string, 0, &addr), OS_ERR_INVALID_SIZE);
UtAssert_INT32_EQ(OS_SocketAddrToString(NULL, sizeof(addr_string), &addr), OS_INVALID_POINTER);
UtAssert_INT32_EQ(OS_SocketAddrToString(addr_string, sizeof(addr_string), NULL), OS_INVALID_POINTER);
UtAssert_INT32_EQ(OS_SocketAddrToString(addr_string, 1, &addr), OS_ERROR);
}

Expand Down Expand Up @@ -234,6 +235,7 @@ void TestDatagramNetworkApi(void)
uint32 Buf3 = 222;
uint32 Buf4 = 000;
osal_id_t objid;
osal_id_t invalid_fd;
uint16 PortNum;
OS_socket_prop_t prop;
OS_SockAddr_t l_addr;
Expand All @@ -250,35 +252,35 @@ void TestDatagramNetworkApi(void)
*/

/* make a bad object ID by flipping the bits of a good object ID */
objid = OS_ObjectIdFromInteger(OS_ObjectIdToInteger(p2_socket_id) ^ 0xFFFFFFFF);
invalid_fd = OS_ObjectIdFromInteger(OS_ObjectIdToInteger(p2_socket_id) ^ 0xFFFFFFFF);

/* OS_SocketBind */
UtAssert_INT32_EQ(OS_SocketBind(OS_OBJECT_ID_UNDEFINED, &p2_addr), OS_ERR_INVALID_ID);
UtAssert_INT32_EQ(OS_SocketBind(objid, &p2_addr), OS_ERR_INVALID_ID);
UtAssert_INT32_EQ(OS_SocketBind(invalid_fd, &p2_addr), OS_ERR_INVALID_ID);
UtAssert_INT32_EQ(OS_SocketBind(regular_file_id, &p2_addr), OS_ERR_INCORRECT_OBJ_TYPE);
UtAssert_INT32_EQ(OS_SocketBind(p2_socket_id, &p2_addr), OS_ERR_INCORRECT_OBJ_STATE);
UtAssert_INT32_EQ(OS_SocketBind(p2_socket_id, NULL), OS_INVALID_POINTER);

/* OS_SocketRecvFrom */
UtAssert_INT32_EQ(OS_SocketRecvFrom(OS_OBJECT_ID_UNDEFINED, &Buf2, sizeof(Buf2), &l_addr, UT_TIMEOUT),
OS_ERR_INVALID_ID);
UtAssert_INT32_EQ(OS_SocketRecvFrom(objid, &Buf2, sizeof(Buf2), &l_addr, UT_TIMEOUT), OS_ERR_INVALID_ID);
UtAssert_INT32_EQ(OS_SocketRecvFrom(invalid_fd, &Buf2, sizeof(Buf2), &l_addr, UT_TIMEOUT), OS_ERR_INVALID_ID);
UtAssert_INT32_EQ(OS_SocketRecvFrom(regular_file_id, &Buf2, sizeof(Buf2), &l_addr, UT_TIMEOUT),
OS_ERR_INCORRECT_OBJ_TYPE);
UtAssert_INT32_EQ(OS_SocketRecvFrom(p2_socket_id, NULL, sizeof(Buf2), &l_addr, UT_TIMEOUT), OS_INVALID_POINTER);
UtAssert_INT32_EQ(OS_SocketRecvFrom(p2_socket_id, &Buf2, 0, &l_addr, UT_TIMEOUT), OS_ERR_INVALID_SIZE);

/* OS_SocketSendTo */
UtAssert_INT32_EQ(OS_SocketSendTo(OS_OBJECT_ID_UNDEFINED, &Buf2, sizeof(Buf2), &l_addr), OS_ERR_INVALID_ID);
UtAssert_INT32_EQ(OS_SocketSendTo(objid, &Buf2, sizeof(Buf2), &l_addr), OS_ERR_INVALID_ID);
UtAssert_INT32_EQ(OS_SocketSendTo(invalid_fd, &Buf2, sizeof(Buf2), &l_addr), OS_ERR_INVALID_ID);
UtAssert_INT32_EQ(OS_SocketSendTo(regular_file_id, &Buf2, sizeof(Buf2), &l_addr), OS_ERR_INCORRECT_OBJ_TYPE);
UtAssert_INT32_EQ(OS_SocketSendTo(p2_socket_id, NULL, sizeof(Buf2), &l_addr), OS_INVALID_POINTER);
UtAssert_INT32_EQ(OS_SocketSendTo(p2_socket_id, &Buf2, 0, &l_addr), OS_ERR_INVALID_SIZE);
UtAssert_INT32_EQ(OS_SocketSendTo(p2_socket_id, &Buf2, sizeof(Buf2), NULL), OS_INVALID_POINTER);

/* OS_SocketGetInfo */
UtAssert_INT32_EQ(OS_SocketGetInfo(OS_OBJECT_ID_UNDEFINED, &prop), OS_ERR_INVALID_ID);
UtAssert_INT32_EQ(OS_SocketGetInfo(objid, &prop), OS_ERR_INVALID_ID);
UtAssert_INT32_EQ(OS_SocketGetInfo(invalid_fd, &prop), OS_ERR_INVALID_ID);
UtAssert_INT32_EQ(OS_SocketGetInfo(p2_socket_id, NULL), OS_INVALID_POINTER);

/* OS_SocketGetIdByName */
Expand Down Expand Up @@ -455,6 +457,7 @@ void TestStreamNetworkApi(void)
uint32 iter;
uint32 loopcnt;
osal_id_t temp_id;
osal_id_t invalid_fd;
OS_SockAddr_t temp_addr;
OS_task_prop_t taskprop;
char Buf_rcv_c[4] = {0};
Expand Down Expand Up @@ -497,8 +500,9 @@ void TestStreamNetworkApi(void)

/* OS_SocketAccept error conditions - check before binding */
/* create a bad ID by flipping the bits of a good ID */
temp_id = OS_ObjectIdFromInteger(OS_ObjectIdToInteger(s_socket_id) ^ 0xFFFFFFFF);
UtAssert_INT32_EQ(OS_SocketAccept(temp_id, &temp_id, &temp_addr, 0), OS_ERR_INVALID_ID);
invalid_fd = OS_ObjectIdFromInteger(OS_ObjectIdToInteger(s_socket_id) ^ 0xFFFFFFFF);
UtAssert_INT32_EQ(OS_SocketAccept(invalid_fd, &temp_id, &temp_addr, 0), OS_ERR_INVALID_ID);
UtAssert_INT32_EQ(OS_SocketAccept(OS_OBJECT_ID_UNDEFINED, &temp_id, &temp_addr, 0), OS_ERR_INVALID_ID);
UtAssert_INT32_EQ(OS_SocketAccept(s_socket_id, NULL, &temp_addr, UT_TIMEOUT), OS_INVALID_POINTER);
UtAssert_INT32_EQ(OS_SocketAccept(s_socket_id, &temp_id, NULL, UT_TIMEOUT), OS_INVALID_POINTER);
UtAssert_INT32_EQ(OS_SocketAccept(s_socket_id, &temp_id, &temp_addr, UT_TIMEOUT), OS_ERR_INCORRECT_OBJ_STATE);
Expand Down Expand Up @@ -561,10 +565,12 @@ void TestStreamNetworkApi(void)
if (iter == UT_STREAM_CONNECTION_INITIAL)
{
/* create a bad ID by flipping the bits of a good ID */
temp_id = OS_ObjectIdFromInteger(OS_ObjectIdToInteger(c_socket_id) ^ 0xFFFFFFFF);
invalid_fd = OS_ObjectIdFromInteger(OS_ObjectIdToInteger(c_socket_id) ^ 0xFFFFFFFF);

/* OS_SocketShutdown */
UtAssert_INT32_EQ(OS_SocketShutdown(temp_id, OS_SocketShutdownMode_SHUT_READ), OS_ERR_INVALID_ID);
UtAssert_INT32_EQ(OS_SocketShutdown(invalid_fd, OS_SocketShutdownMode_SHUT_READ), OS_ERR_INVALID_ID);
UtAssert_INT32_EQ(OS_SocketShutdown(OS_OBJECT_ID_UNDEFINED, OS_SocketShutdownMode_SHUT_READ),
OS_ERR_INVALID_ID);
UtAssert_INT32_EQ(OS_SocketShutdown(regular_file_id, OS_SocketShutdownMode_SHUT_READ),
OS_ERR_INCORRECT_OBJ_TYPE);
UtAssert_INT32_EQ(OS_SocketShutdown(c_socket_id, OS_SocketShutdownMode_SHUT_READ),
Expand All @@ -582,26 +588,33 @@ void TestStreamNetworkApi(void)
if (iter == UT_STREAM_CONNECTION_INITIAL)
{
/* create a bad ID by flipping the bits of a good ID */
temp_id = OS_ObjectIdFromInteger(OS_ObjectIdToInteger(c_socket_id) ^ 0xFFFFFFFF);
invalid_fd = OS_ObjectIdFromInteger(OS_ObjectIdToInteger(c_socket_id) ^ 0xFFFFFFFF);

/* OS_SocketShutdown */
UtAssert_INT32_EQ(OS_SocketShutdown(c_socket_id, OS_SocketShutdownMode_NONE), OS_ERR_INVALID_ARGUMENT);

/* OS_TimedRead */
UtAssert_INT32_EQ(OS_TimedRead(temp_id, Buf_rcv_c, sizeof(Buf_rcv_c), UT_TIMEOUT), OS_ERR_INVALID_ID);
UtAssert_INT32_EQ(OS_TimedRead(invalid_fd, Buf_rcv_c, sizeof(Buf_rcv_c), UT_TIMEOUT),
OS_ERR_INVALID_ID);
UtAssert_INT32_EQ(OS_TimedRead(OS_OBJECT_ID_UNDEFINED, Buf_rcv_c, sizeof(Buf_rcv_c), UT_TIMEOUT),
OS_ERR_INVALID_ID);
UtAssert_INT32_EQ(OS_TimedRead(c_socket_id, NULL, sizeof(Buf_rcv_c), UT_TIMEOUT), OS_INVALID_POINTER);
UtAssert_INT32_EQ(OS_TimedRead(c_socket_id, Buf_rcv_c, 0, UT_TIMEOUT), OS_ERR_INVALID_SIZE);
UtAssert_INT32_EQ(OS_TimedRead(c_socket_id, Buf_rcv_c, sizeof(Buf_rcv_c), 0), OS_ERROR_TIMEOUT);

/* OS_TimedWrite */
UtAssert_INT32_EQ(OS_TimedWrite(temp_id, Buf_rcv_c, sizeof(Buf_rcv_c), UT_TIMEOUT), OS_ERR_INVALID_ID);
UtAssert_INT32_EQ(OS_TimedWrite(invalid_fd, Buf_rcv_c, sizeof(Buf_rcv_c), UT_TIMEOUT),
OS_ERR_INVALID_ID);
UtAssert_INT32_EQ(OS_TimedWrite(OS_OBJECT_ID_UNDEFINED, Buf_rcv_c, sizeof(Buf_rcv_c), UT_TIMEOUT),
OS_ERR_INVALID_ID);
UtAssert_INT32_EQ(OS_TimedWrite(c_socket_id, NULL, sizeof(Buf_rcv_c), UT_TIMEOUT), OS_INVALID_POINTER);
UtAssert_INT32_EQ(OS_TimedWrite(c_socket_id, Buf_rcv_c, 0, UT_TIMEOUT), OS_ERR_INVALID_SIZE);

/* OS_SocketConnect */
UtAssert_INT32_EQ(OS_SocketConnect(c_socket_id, NULL, UT_TIMEOUT), OS_INVALID_POINTER);
UtAssert_INT32_EQ(OS_SocketConnect(temp_id, &s_addr, UT_TIMEOUT), OS_ERR_INVALID_ID);
UtAssert_INT32_EQ(OS_SocketConnect(invalid_fd, &s_addr, UT_TIMEOUT), OS_ERR_INVALID_ID);
UtAssert_INT32_EQ(OS_SocketConnect(OS_OBJECT_ID_UNDEFINED, &s_addr, UT_TIMEOUT), OS_ERR_INVALID_ID);
UtAssert_INT32_EQ(OS_SocketConnect(regular_file_id, &s_addr, UT_TIMEOUT), OS_ERR_INCORRECT_OBJ_TYPE);
UtAssert_INT32_EQ(OS_SocketConnect(c_socket_id, NULL, UT_TIMEOUT), OS_INVALID_POINTER);
UtAssert_INT32_EQ(OS_SocketConnect(c_socket_id, &s_addr, 0), OS_ERR_INCORRECT_OBJ_STATE);
}

Expand Down
Loading

0 comments on commit 64a6b31

Please sign in to comment.