-
Notifications
You must be signed in to change notification settings - Fork 215
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix #313: Use UT assert for OSAL unit tests
Modify the "unit-tests" (extended/functional tests) for OSAL to use the UT assert library for test case reporting and platform support. Reduce or eliminate the use of macros for platform abstraction wherever possible. This removes most platform-specific logic from the test cases, leaving that to the OSAL/BSP abstraction.
- Loading branch information
Showing
74 changed files
with
2,037 additions
and
5,794 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
103 changes: 49 additions & 54 deletions
103
src/unit-tests/shared/ut_osloader_stubs.c → src/unit-tests/inc/ut_os_support.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,88 +1,83 @@ | ||
/*================================================================================* | ||
** File: ut_osloader_stubs.c | ||
** File: ut_os_support.h | ||
** Owner: Tam Ngo | ||
** Date: March 2013 | ||
** Date: May 2013 | ||
**================================================================================*/ | ||
|
||
#ifndef _UT_OS_SUPPORT_H_ | ||
#define _UT_OS_SUPPORT_H_ | ||
|
||
/*--------------------------------------------------------------------------------* | ||
** Includes | ||
**--------------------------------------------------------------------------------*/ | ||
|
||
#include "ut_os_stubs.h" | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <string.h> | ||
|
||
/*--------------------------------------------------------------------------------* | ||
** Macros | ||
**--------------------------------------------------------------------------------*/ | ||
#include "utassert.h" | ||
#include "uttest.h" | ||
#include "osapi.h" | ||
|
||
/*--------------------------------------------------------------------------------* | ||
** Data types | ||
**--------------------------------------------------------------------------------*/ | ||
|
||
/*--------------------------------------------------------------------------------* | ||
** External global variables | ||
**--------------------------------------------------------------------------------*/ | ||
|
||
/*--------------------------------------------------------------------------------* | ||
** Global variables | ||
** Macros | ||
**--------------------------------------------------------------------------------*/ | ||
|
||
UT_OsReturnCode_t g_moduleTblInit = {0,0}; | ||
UT_OsReturnCode_t g_moduleLoad = {0,0}; | ||
UT_OsReturnCode_t g_moduleUnload = {0,0}; | ||
UT_OsReturnCode_t g_moduleInfo = {0,0}; | ||
/* | ||
* Buffers to hold names of various objects | ||
* | ||
* These are sized somewhat larger than the osconfig.h specification, | ||
* so that test cases may create names that exceed the allowed length | ||
*/ | ||
#define UT_OS_NAME_BUFF_SIZE (OS_MAX_API_NAME + 10) | ||
#define UT_OS_FILE_BUFF_SIZE (OS_MAX_FILE_NAME + 10) | ||
#define UT_OS_PATH_BUFF_SIZE (OS_MAX_PATH_LEN + 10) | ||
#define UT_OS_PHYS_NAME_BUFF_SIZE (OS_FS_PHYS_NAME_LEN + 10) | ||
#define UT_OS_LOCAL_PATH_BUFF_SIZE (OS_MAX_LOCAL_PATH_LEN + 10) | ||
|
||
UT_OsReturnCode_t g_symbolTblLookup = {0,0}; | ||
UT_OsReturnCode_t g_symbolTblDump = {0,0}; | ||
/* | ||
* Generic buffer for I/O operations | ||
*/ | ||
#define UT_OS_IO_BUFF_SIZE 128 | ||
|
||
|
||
/*--------------------------------------------------------------------------------* | ||
** Local function prototypes | ||
**--------------------------------------------------------------------------------*/ | ||
|
||
/*--------------------------------------------------------------------------------* | ||
** Function definitions | ||
**--------------------------------------------------------------------------------*/ | ||
/*--------------------------------------------------------------------------------*/ | ||
|
||
int32 OS_ModuleTableInit() | ||
{ | ||
return (g_moduleTblInit.value); | ||
} | ||
#define UT_OS_TEST_RESULT(descStr, caseType) \ | ||
UtAssertEx(false, caseType, __FILE__, __LINE__, "%s", descStr) | ||
|
||
/*--------------------------------------------------------------------------------*/ | ||
|
||
int32 OS_ModuleLoad(uint32* module_id, char* module_name, char* filename) | ||
{ | ||
return (g_moduleLoad.value); | ||
} | ||
#define UT_os_sprintf(buf,...) \ | ||
snprintf(buf,sizeof(buf),__VA_ARGS__) | ||
|
||
/*--------------------------------------------------------------------------------*/ | ||
|
||
int32 OS_ModuleUnload(uint32 module_id) | ||
{ | ||
return (g_moduleUnload.value); | ||
} | ||
#define UT_OS_LOG(...) \ | ||
UtAssert_Message(UTASSERT_CASETYPE_INFO,__FILE__,__LINE__,__VA_ARGS__); | ||
|
||
/*--------------------------------------------------------------------------------*/ | ||
/*--------------------------------------------------------------------------------* | ||
** Data types | ||
**--------------------------------------------------------------------------------*/ | ||
|
||
/*--------------------------------------------------------------------------------* | ||
** External global variables | ||
**--------------------------------------------------------------------------------*/ | ||
|
||
int32 OS_ModuleInfo(uint32 module_id, OS_module_prop_t* module_info) | ||
{ | ||
return (g_moduleInfo.value); | ||
} | ||
/*--------------------------------------------------------------------------------* | ||
** Global variables | ||
**--------------------------------------------------------------------------------*/ | ||
|
||
/*--------------------------------------------------------------------------------*/ | ||
/*--------------------------------------------------------------------------------* | ||
** Function prototypes | ||
**--------------------------------------------------------------------------------*/ | ||
|
||
int32 OS_SymbolLookup(uint32* SymbolAddress, char* SymbolName) | ||
{ | ||
return (g_symbolTblLookup.value); | ||
} | ||
|
||
/*--------------------------------------------------------------------------------*/ | ||
|
||
int32 OS_SymbolTableDump(char* filename, uint32 SizeLimit) | ||
{ | ||
return (g_symbolTblDump.value); | ||
} | ||
#endif /* _UT_OS_SUPPORT_H_ */ | ||
|
||
/*================================================================================* | ||
** End of File: ut_osloader_stubs.c | ||
** End of File: ut_os_support.h | ||
**================================================================================*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.