From d3b0c81c931744ee157f9627f7d2a8a43a7d1803 Mon Sep 17 00:00:00 2001 From: Chris Knight Date: Mon, 1 Jun 2020 13:33:42 -0700 Subject: [PATCH 1/5] fix #485 - add text to make clear that IDs are non-zero --- src/os/inc/osapi-os-core.h | 10 +++++----- src/os/inc/osapi-os-filesys.h | 4 ++-- src/os/inc/osapi-os-loader.h | 2 +- src/os/inc/osapi-os-net.h | 2 +- src/os/inc/osapi-os-timer.h | 6 +++--- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/os/inc/osapi-os-core.h b/src/os/inc/osapi-os-core.h index 580513ea5..f93bdbe18 100644 --- a/src/os/inc/osapi-os-core.h +++ b/src/os/inc/osapi-os-core.h @@ -378,7 +378,7 @@ void OS_ForEachObjectOfType (uint32 objtype, uint32 creator_id, OS_ArgCallba * Creates a task and passes back the id of the task created. Task names must be unique; * if the name already exists this function fails. Names cannot be NULL. * - * @param[out] task_id will be set to the ID of the newly-created resource + * @param[out] task_id will be set to the non-zero ID of the newly-created resource * @param[in] task_name the name of the new resource to create * @param[in] function_pointer the entry point of the new task * @param[in] stack_pointer pointer to the stack for the task, or NULL @@ -566,7 +566,7 @@ int32 OS_TaskFindIdBySystemData(uint32 *task_id, const void *sysdata, size_t sys * function fails. Names cannot be NULL. * * - * @param[out] queue_id will be set to the ID of the newly-created resource + * @param[out] queue_id will be set to the non-zero ID of the newly-created resource * @param[in] queue_name the name of the new resource to create * @param[in] queue_depth the maximum depth of the queue * @param[in] data_size the size of each entry in the queue @@ -694,7 +694,7 @@ int32 OS_QueueGetInfo (uint32 queue_id, OS_queue_prop_t *queue_prop); * sem_initial_value and name specified by sem_name. sem_id will be * returned to the caller * - * @param[out] sem_id will be set to the ID of the newly-created resource + * @param[out] sem_id will be set to the non-zero ID of the newly-created resource * @param[in] sem_name the name of the new resource to create * @param[in] sem_initial_value the initial value of the binary semaphore * @param[in] options Reserved for future use, should be passed as 0. @@ -846,7 +846,7 @@ int32 OS_BinSemGetInfo (uint32 sem_id, OS_bin_sem_prop_t *bin_prop); * sem_initial_value and name specified by sem_name. sem_id will be * returned to the caller * - * @param[out] sem_id will be set to the ID of the newly-created resource + * @param[out] sem_id will be set to the non-zero ID of the newly-created resource * @param[in] sem_name the name of the new resource to create * @param[in] sem_initial_value the initial value of the counting semaphore * @param[in] options Reserved for future use, should be passed as 0. @@ -978,7 +978,7 @@ int32 OS_CountSemGetInfo (uint32 sem_id, OS_count_sem_prop_t *count_prop * * Mutex semaphores are always created in the unlocked (full) state. * - * @param[out] sem_id will be set to the ID of the newly-created resource + * @param[out] sem_id will be set to the non-zero ID of the newly-created resource * @param[in] sem_name the name of the new resource to create * @param[in] options reserved for future use. Should be passed as 0. * diff --git a/src/os/inc/osapi-os-filesys.h b/src/os/inc/osapi-os-filesys.h index af63e3989..e9e8b0c81 100644 --- a/src/os/inc/osapi-os-filesys.h +++ b/src/os/inc/osapi-os-filesys.h @@ -664,7 +664,7 @@ os_dirent_t * OS_readdir (os_dirp_t directory); * * Prepares for reading the files within a directory * - * @param[out] dir_id The handle ID of the directory + * @param[out] dir_id The non-zero handle ID of the directory * @param[in] path The directory to open * * @return Execution status, see @ref OSReturnCodes @@ -765,7 +765,7 @@ int32 OS_rmdir (const char *path); * This mimics the behavior of a "FS_BASED" entry in the VolumeTable but is registered * at runtime. It is intended to be called by the PSP/BSP prior to starting the application. * - * @param[out] filesys_id An OSAL ID reflecting the file system + * @param[out] filesys_id A non-zero OSAL ID reflecting the file system * @param[in] phys_path The native system directory (an existing mount point) * @param[in] virt_path The virtual mount point of this filesystem * diff --git a/src/os/inc/osapi-os-loader.h b/src/os/inc/osapi-os-loader.h index 7eb807e29..ed02714ce 100644 --- a/src/os/inc/osapi-os-loader.h +++ b/src/os/inc/osapi-os-loader.h @@ -132,7 +132,7 @@ int32 OS_SymbolTableDump ( const char *filename, uint32 size_limit ); * * Loads an object file into the running operating system * - * @param[out] module_id OSAL ID corresponding to the loaded module + * @param[out] module_id Non-zero OSAL ID corresponding to the loaded module * @param[in] module_name Name of module * @param[in] filename File containing the object code to load * diff --git a/src/os/inc/osapi-os-net.h b/src/os/inc/osapi-os-net.h index 1497288b2..85858aa5f 100644 --- a/src/os/inc/osapi-os-net.h +++ b/src/os/inc/osapi-os-net.h @@ -229,7 +229,7 @@ int32 OS_SocketAddrSetPort(OS_SockAddr_t *Addr, uint16 PortNum); * * A new, unconnected and unbound socket is allocated of the given domain and type. * - * @param[out] sock_id Buffer to hold the OSAL ID + * @param[out] sock_id Buffer to hold the non-zero OSAL ID * @param[in] Domain The domain / address family of the socket (INET or INET6, etc) * @param[in] Type The type of the socket (STREAM or DATAGRAM) * diff --git a/src/os/inc/osapi-os-timer.h b/src/os/inc/osapi-os-timer.h index fc3c989c8..adfc967c3 100644 --- a/src/os/inc/osapi-os-timer.h +++ b/src/os/inc/osapi-os-timer.h @@ -74,7 +74,7 @@ typedef struct * be configured to support at least (OS_MAX_TASKS + OS_MAX_TIMEBASES) threads, * to account for the helper threads associated with time base objects. * - * @param[out] timebase_id An identifier corresponding to the timebase resource + * @param[out] timebase_id A non-zero ID corresponding to the timebase resource * @param[in] timebase_name The name of the time base * @param[in] external_sync A synchronization function for BSP hardware-based timer ticks * @@ -204,7 +204,7 @@ int32 OS_TimeBaseGetFreeRun (uint32 timebase_id, uint32 *freerun_val); * interrupt service routine. Calls that cause the code to block or require * an application context (like sending events) are generally not supported. * - * @param[out] timer_id The resource ID of the timer object + * @param[out] timer_id The non-zero resource ID of the timer object * @param[in] timer_name Name of the timer object * @param[out] clock_accuracy Expected precision of the timer, in microseconds. This * is the underlying tick value rounded to the nearest @@ -245,7 +245,7 @@ int32 OS_TimerCreate (uint32 *timer_id, const char *timer_name, uint3 * interrupt service routine. Calls that cause the code to block or require * an application context (like sending events) are generally not supported. * - * @param[out] timer_id The resource ID of the timer object + * @param[out] timer_id The non-zero resource ID of the timer object * @param[in] timer_name Name of the timer object * @param[in] timebase_id The time base resource to use as a reference * @param[in] callback_ptr Application-provided function to invoke From 6d88b770e0a2e544efb921b80ff81c49fc49fa84 Mon Sep 17 00:00:00 2001 From: Joseph Hickey Date: Tue, 9 Jun 2020 09:49:46 -0400 Subject: [PATCH 2/5] Fix #494, add missing stub functions for OSAL API Added sub functions for: OS_TaskFindIdBySystemData OS_FileSysAddFixedMap OS_TimedRead OS_TimedWrite OS_FileSysAddFixedMap Required for testing other modules that use these functions. Also correct a name mismatch issue in OS_TaskGetInfo. --- src/ut-stubs/osapi-utstub-file.c | 21 +++++++++++++++++++++ src/ut-stubs/osapi-utstub-filesys.c | 27 +++++++++++++++++++++++++++ src/ut-stubs/osapi-utstub-printf.c | 11 +++++++++++ src/ut-stubs/osapi-utstub-task.c | 29 ++++++++++++++++++++++++++++- 4 files changed, 87 insertions(+), 1 deletion(-) diff --git a/src/ut-stubs/osapi-utstub-file.c b/src/ut-stubs/osapi-utstub-file.c index fb4805df3..78e149a68 100644 --- a/src/ut-stubs/osapi-utstub-file.c +++ b/src/ut-stubs/osapi-utstub-file.c @@ -196,6 +196,27 @@ int32 OS_write(uint32 filedes, const void *buffer, uint32 nbytes) return UT_GenericWriteStub(__func__,UT_KEY(OS_write),buffer,nbytes); } +/***************************************************************************** + * + * Stub function for OS_TimedRead() + * + *****************************************************************************/ +int32 OS_TimedRead(uint32 filedes, void *buffer, uint32 nbytes, int32 timeout) +{ + return UT_GenericReadStub(__func__,UT_KEY(OS_TimedRead),buffer,nbytes); +} + +/***************************************************************************** + * + * Stub function for OS_TimedWrite() + * + *****************************************************************************/ +int32 OS_TimedWrite(uint32 filedes, const void *buffer, uint32 nbytes, int32 timeout) +{ + return UT_GenericWriteStub(__func__,UT_KEY(OS_TimedWrite),buffer,nbytes); +} + + /***************************************************************************** * * Stub function for OS_chmod() diff --git a/src/ut-stubs/osapi-utstub-filesys.c b/src/ut-stubs/osapi-utstub-filesys.c index 1f3c368ff..466705e36 100644 --- a/src/ut-stubs/osapi-utstub-filesys.c +++ b/src/ut-stubs/osapi-utstub-filesys.c @@ -28,6 +28,33 @@ UT_DEFAULT_STUB(OS_FileSysAPI_Init,(void)) +/***************************************************************************** + * + * Stub function for OS_FileSysAddFixedMap() + * + *****************************************************************************/ +int32 OS_FileSysAddFixedMap(uint32 *filesys_id, const char *phys_path, + const char *virt_path) +{ + int32 status; + + status = UT_DEFAULT_IMPL(OS_FileSysAddFixedMap); + + if (status == OS_SUCCESS) + { + *filesys_id = UT_AllocStubObjId(UT_OBJTYPE_FILESYS); + } + else + { + *filesys_id = 0xDEADBEEFU; + } + + + + return status; +} + + /***************************************************************************** * * Stub function for OS_mkfs() diff --git a/src/ut-stubs/osapi-utstub-printf.c b/src/ut-stubs/osapi-utstub-printf.c index e0b5125e9..08ef9c42e 100644 --- a/src/ut-stubs/osapi-utstub-printf.c +++ b/src/ut-stubs/osapi-utstub-printf.c @@ -30,6 +30,17 @@ int32 OS_ConsoleAPI_Init(void) return UT_DEFAULT_IMPL(OS_ConsoleAPI_Init); } +/***************************************************************************** + * + * Stub function for OS_ConsoleWrite() + * + *****************************************************************************/ +int32 OS_ConsoleWrite(uint32 console_id, const char *Str) +{ + UT_Stub_RegisterContext(UT_KEY(OS_ConsoleWrite), Str); + return UT_DEFAULT_IMPL(OS_ConsoleWrite); +} + /***************************************************************************** * * Stub function for OS_printf() diff --git a/src/ut-stubs/osapi-utstub-task.c b/src/ut-stubs/osapi-utstub-task.c index bcaa5bfc7..a2affd621 100644 --- a/src/ut-stubs/osapi-utstub-task.c +++ b/src/ut-stubs/osapi-utstub-task.c @@ -260,7 +260,7 @@ int32 OS_TaskGetInfo(uint32 task_id, OS_task_prop_t *task_prop) status = UT_DEFAULT_IMPL(OS_TaskGetInfo); if (status == OS_SUCCESS && - UT_Stub_CopyToLocal(UT_KEY(OS_MutSemGetInfo), task_prop, sizeof(*task_prop)) < sizeof(*task_prop)) + UT_Stub_CopyToLocal(UT_KEY(OS_TaskGetInfo), task_prop, sizeof(*task_prop)) < sizeof(*task_prop)) { task_prop->creator = 1; UT_FIXUP_ID(task_prop->creator, UT_OBJTYPE_TASK); @@ -273,6 +273,33 @@ int32 OS_TaskGetInfo(uint32 task_id, OS_task_prop_t *task_prop) return status; } +/*****************************************************************************/ +/** +** \brief OS_TaskGetInfo stub function +** +** \par Description +** This function is used to mimic the response of the OS API function +** OS_TaskFindIdBySystemData. +** +** \returns +** The return value instructed by the test case setup +** +******************************************************************************/ +int32 OS_TaskFindIdBySystemData(uint32 *task_id, const void *sysdata, size_t sysdata_size) +{ + int32 status; + + status = UT_DEFAULT_IMPL(OS_TaskFindIdBySystemData); + + if (status == OS_SUCCESS && + UT_Stub_CopyToLocal(UT_KEY(OS_TaskFindIdBySystemData), (void**)&task_id, sizeof(task_id)) < sizeof(task_id)) + { + *task_id = 1; + UT_FIXUP_ID(*task_id, UT_OBJTYPE_TASK); + } + + return status; +} /***************************************************************************** * From b6b1ad802615bebb7f8107c1819bab1800d9dc7d Mon Sep 17 00:00:00 2001 From: Joseph Hickey Date: Tue, 16 Jun 2020 10:07:06 -0400 Subject: [PATCH 3/5] Update #494, OS_TaskFindIdBySystemData stub Correct output value --- src/ut-stubs/osapi-utstub-task.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ut-stubs/osapi-utstub-task.c b/src/ut-stubs/osapi-utstub-task.c index a2affd621..4b307b5b4 100644 --- a/src/ut-stubs/osapi-utstub-task.c +++ b/src/ut-stubs/osapi-utstub-task.c @@ -292,7 +292,7 @@ int32 OS_TaskFindIdBySystemData(uint32 *task_id, const void *sysdata, size_t sys status = UT_DEFAULT_IMPL(OS_TaskFindIdBySystemData); if (status == OS_SUCCESS && - UT_Stub_CopyToLocal(UT_KEY(OS_TaskFindIdBySystemData), (void**)&task_id, sizeof(task_id)) < sizeof(task_id)) + UT_Stub_CopyToLocal(UT_KEY(OS_TaskFindIdBySystemData), task_id, sizeof(*task_id)) < sizeof(*task_id)) { *task_id = 1; UT_FIXUP_ID(*task_id, UT_OBJTYPE_TASK); From 2d79f8e8776cbdbce1db94701d274109cf9c075a Mon Sep 17 00:00:00 2001 From: Joseph Hickey Date: Mon, 8 Jun 2020 10:24:15 -0400 Subject: [PATCH 4/5] Fix #491, increase UT assert buffer sizes The buffer for context info increases from 128 to 256 bytes --- ut_assert/src/utassert.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ut_assert/src/utassert.c b/ut_assert/src/utassert.c index 0ce18852b..74fb96b33 100644 --- a/ut_assert/src/utassert.c +++ b/ut_assert/src/utassert.c @@ -108,7 +108,7 @@ bool UtAssert(bool Expression, const char *Description, const char *File, uint32 bool UtAssertEx(bool Expression, UtAssert_CaseType_t CaseType, const char *File, uint32 Line, const char *MessageFormat, ...) { va_list va; - char FinalMessage[128]; + char FinalMessage[256]; ++UT_SegmentCounters.TotalTestCases; From 58718a2be4b0669e5b253b71d58c097218199520 Mon Sep 17 00:00:00 2001 From: "Gerardo E. Cruz-Ortiz" Date: Wed, 17 Jun 2020 15:08:19 -0400 Subject: [PATCH 5/5] Increase version to 5.0.20 and update ReadMe --- README.md | 8 ++++++++ src/os/inc/osapi-version.h | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 60e25cb7c..1863294a1 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,14 @@ This distribution contains: ## Version History + +### Development Build: 5.0.20 +- Add "non-zero" to the out variable description for OS_Create (and related) API's. +- Increases the buffer for context info from 128 to 256 bytes and the total report buffer to 320 bytes. +- Add stub functions for `OS_TaskFindIdBySystemData()`, `OS_FileSysAddFixedMap()`, +`OS_TimedRead()`, `OS_TimedWrite()`, and `OS_FileSysAddFixedMap()` +- See + ### Development Build: 5.0.19 - Rename BSPs that can be used on multiple platforms. diff --git a/src/os/inc/osapi-version.h b/src/os/inc/osapi-version.h index 2f4b53374..b7bdc236b 100644 --- a/src/os/inc/osapi-version.h +++ b/src/os/inc/osapi-version.h @@ -20,7 +20,7 @@ #define OS_MAJOR_VERSION 5 /**< @brief Major version number */ #define OS_MINOR_VERSION 0 /**< @brief Minor version number */ -#define OS_REVISION 19 /**< @brief Revision number */ +#define OS_REVISION 20 /**< @brief Revision number */ #define OS_MISSION_REV 0 /**< @brief Mission revision */ /**