From 3456b8477f0efce4ce2d5f9fb3535294b9737620 Mon Sep 17 00:00:00 2001 From: Chris Knight Date: Tue, 14 Apr 2020 17:49:25 -0700 Subject: [PATCH] fix #397-ut_assert macros --- src/unit-tests/README.md | 80 +++ src/unit-tests/inc/ut_os_support.h | 29 + .../oscore-test/ut_oscore_binsem_test.c | 572 ++---------------- .../oscore-test/ut_oscore_countsem_test.c | 78 --- .../oscore-test/ut_oscore_exception_test.c | 78 --- .../oscore-test/ut_oscore_misc_test.c | 78 --- .../oscore-test/ut_oscore_mutex_test.c | 78 --- .../oscore-test/ut_oscore_queue_test.c | 78 --- .../oscore-test/ut_oscore_task_test.c | 78 --- .../osfile-test/ut_osfile_dirio_test.c | 78 --- .../osfile-test/ut_osfile_fileio_test.c | 80 --- .../osfilesys-test/ut_osfilesys_diskio_test.c | 78 --- .../osloader-test/ut_osloader_module_test.c | 80 --- .../osloader-test/ut_osloader_symtable_test.c | 80 --- .../osnetwork-test/ut_osnetwork_misc_test.c | 80 --- .../ostimer-test/ut_ostimer_timerio_test.c | 78 --- 16 files changed, 168 insertions(+), 1535 deletions(-) create mode 100644 src/unit-tests/README.md diff --git a/src/unit-tests/README.md b/src/unit-tests/README.md new file mode 100644 index 000000000..53b490ff0 --- /dev/null +++ b/src/unit-tests/README.md @@ -0,0 +1,80 @@ +The include file inc/ut_os_support.h file contains a number of macros (that call static inline utility fn's) to make for concise functional unit test functions, namely: + +* UT_IMPL(Fn) -> returns true if the fn is implemented, otherwise throws an assertion +* UT_RETVAL(Fn, Exp, Msg) -> asserts that Fn == Exp with the addl message Msg +* UT_SETUP(Fn) -> calls setup Fn and throws an assertion if it's not successful +* UT_TEARDOWN(Fn) -> calls teardown Fn and throws an assertion if it's not successful +* UT_NOMINAL(Fn) -> calls Fn and asserts that it is nominal + +Use the following structure for your unit test cases: + +``` +/*--------------------------------------------------------------------------------* +** Syntax: OS_SomethingCreate +** Purpose: Creates something +** Parameters: uint32 *id, const char *name, int32 max, int32 counter +** Returns: OS_INVALID_POINTER if any of the pointers passed in is null +** OS_ERR_NAME_TOO_LONG if the name passed in is too long +** OS_ERR_NAME_TAKEN if the name passed in has already been used +** OS_ERR_NO_FREE_IDS if there are no more free something ids +** OS_SEM_FAILURE if the OS call failed +** OS_SUCCESS if succeeded +**--------------------------------------------------------------------------------*/ +void UT_os_somethingcreate() +{ + int i; + char name[UT_OS_NAME_BUFF_SIZE]; + char long_name[UT_OS_NAME_BUFF_SIZE]; + uint32 ids[OS_MAX_SOMETHING_IDS+1]; + + /*-----------------------------------------------------*/ + if (!UT_IMPL(OS_SomethingCreate(&ids[0], "Something", 1, 0))) return; + + /*-----------------------------------------------------*/ + UT_RETVAL(OS_SomethingCreate(NULL, "Something", 1, 0), OS_INVALID_POINTER, "null pointer arg 1"); + + /*-----------------------------------------------------*/ + UT_RETVAL(OS_SomethingCreate(&ids[0], NULL, 1, 0), OS_INVALID_POINTER, "null pointer arg 2"); + + /*-----------------------------------------------------*/ + memset(long_name, 'X', sizeof(long_name)); + long_name[sizeof(long_name)-1] = '\0'; + UT_RETVAL(OS_SomethingCreate(&ids[0], long_name, 1, 0), OS_ERR_NAME_TOO_LONG, "name too long"); + + /*-----------------------------------------------------*/ + /* Setup */ + for ( i = 0; i< OS_MAX_SOMETHING_IDS; i++ ) + { + memset(name, '\0', sizeof(name)); + UT_os_sprintf(name, "Something%d", i); + + if(!UT_SETUP(OS_SomethingCreate(&ids[i], name, 1, 0))) + { + break; + } + } + + if ( i == OS_MAX_SOMETHING_IDS ) /* setup was successful */ + { + UT_RETVAL(OS_SomethingCreate(&ids[OS_MAX_BIN_SEMAPHORES], "OneTooMany", 1, 0), OS_ERR_NO_FREE_IDS, "no free ids"); + } + + /* Reset test environment */ + OS_DeleteAllObjects(); + + /*-----------------------------------------------------*/ + if(UT_SETUP(OS_SomethingCreate(&ids[0], "Something", 1, 0))) + { + UT_RETVAL(OS_SomethingCreate(&ids[0], "Something", 1, 0), OS_ERR_NAME_TAKEN, "duplicate name"); + + /* Reset test environment */ + UT_TEARDOWN(OS_SomethingDelete(ids[0])); + } + + /*-----------------------------------------------------*/ + UT_NOMINAL(OS_SomethingCreate(&ids[0], "Something", 1, 0)); + + /* Reset test environment */ + UT_TEARDOWN(OS_SomethingDelete(ids[0])); +} +``` diff --git a/src/unit-tests/inc/ut_os_support.h b/src/unit-tests/inc/ut_os_support.h index c8955de67..cc60a1d84 100644 --- a/src/unit-tests/inc/ut_os_support.h +++ b/src/unit-tests/inc/ut_os_support.h @@ -41,6 +41,35 @@ */ #define UT_OS_IO_BUFF_SIZE 128 +static inline bool UtOsalRetVal(int32 Fn, int32 Exp, UtAssert_CaseType_t casetype, const char *File, uint32 Line, const char *FnTxt, const char *ExpTxt, const char *Msg) +{ + return UtAssertEx(Fn == Exp, casetype, File, Line, "%s (%d) == %s (%d): %s", FnTxt, (int)Fn, ExpTxt, (int)Exp, Msg); +} + +/* Only report errors */ +static inline bool UtOsalCheck(int32 Fn, int32 Exp, UtAssert_CaseType_t casetype, const char *File, uint32 Line, const char *FnTxt, const char *ExpTxt) +{ + return Fn == Exp ? true : + UtAssertEx(Fn == Exp, casetype, File, Line, "%s (%d) == %s (%d)", FnTxt, (int)Fn, ExpTxt, (int)Exp); +} + +static inline bool UtOsalImplemented(int32 Fn, const char *File, uint32 Line) +{ + if (Fn == OS_ERR_NOT_IMPLEMENTED) + { + UtAssertEx(false, UTASSERT_CASETYPE_NA, File, Line, "API not implemented"); + return false; + } + + return true; +} + + +#define UT_NOMINAL(Fn) UtOsalRetVal(Fn, OS_SUCCESS, UTASSERT_CASETYPE_FAILURE, __FILE__, __LINE__, #Fn, "OS_SUCCESS", "Nominal") +#define UT_RETVAL(Fn, Exp, Msg) UtOsalRetVal(Fn, Exp, UTASSERT_CASETYPE_FAILURE, __FILE__, __LINE__, #Fn, #Exp, Msg) +#define UT_SETUP(Fn) UtOsalCheck(Fn, OS_SUCCESS, UTASSERT_CASETYPE_TSF, __FILE__, __LINE__, #Fn, "OS_SUCCESS") +#define UT_TEARDOWN(Fn) UtOsalCheck(Fn, OS_SUCCESS, UTASSERT_CASETYPE_TTF, __FILE__, __LINE__, #Fn, "OS_SUCCESS") +#define UT_IMPL(Fn) UtOsalImplemented(Fn, __FILE__, __LINE__) /*--------------------------------------------------------------------------------*/ diff --git a/src/unit-tests/oscore-test/ut_oscore_binsem_test.c b/src/unit-tests/oscore-test/ut_oscore_binsem_test.c index 892b155ca..ad8311508 100644 --- a/src/unit-tests/oscore-test/ut_oscore_binsem_test.c +++ b/src/unit-tests/oscore-test/ut_oscore_binsem_test.c @@ -34,84 +34,6 @@ ** Local function definitions **--------------------------------------------------------------------------------*/ -/* Test code template for testing a single OSAL API with multiple test cases */ - -#if 0 -void UT_os_sample_test() -{ - /* Must declare these variables for each function. They can be renamed. - * They're referenced in the macros used to track test cases and their results. */ - int32 idx = 0; - const char* testDesc; - - /*-----------------------------------------------------* - * For each test case, - * 1. Assign testDesc a brief description of the test - * 2. Setup the test environment, if necessary - * 3. Run the test - * 4. Log result by calling UT_OS_SET_TEST_RESULT_MACRO - * 4. Reset the test environment, if neccessary - * - * NOTE: "Not implemented" is always checked first but not - * being included as a test case. - * "Nominal" test case is always the last test case. - *-----------------------------------------------------*/ - - /*-----------------------------------------------------*/ - testDesc = "API not implemented"; - - /* TODO: Setup the test environment, if necessary */ - - if (OS_xxx() == OS_ERR_NOT_IMPLEMENTED) - { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_NA); - goto UT_os_sample_test_exit_tag; - } - - /* TODO: Reset the test environment here, if necessary */ - - /*-----------------------------------------------------*/ - testDesc = "#1 Null-pointer-arg"; - - /* TODO: Setup the test environment here, if necessary */ - - if (OS_xxx(NULL,...) == OS_INVALID_POINTER) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); - else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); - - /* TODO: Reset the test environment here, if necessary */ - - /*-----------------------------------------------------*/ - testDesc = "#2 Name-too-long-arg"; - - /* TODO: Setup the test environment here, if necessary */ - - if (OS_xxx(aVeryLoooooongName) == OS_ERR_NAME_TOO_LONG) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); - else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); - - /* TODO: Reset the test environment here, if necessary */ - - /*-----------------------------------------------------*/ - testDesc = "#3 Nominal"; - - /* TODO: Setup the test environment here, if necessary */ - - if (OS_xxx(...) != OS_SUCCESS) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); - else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); - - /* TODO: Reset the test environment here, if necessary */ - -UT_os_sample_test_exit_tag: - return; - -} -#endif - /*--------------------------------------------------------------------------------* ** Syntax: OS_BinSemCreate ** Purpose: Creates a binary semaphore @@ -126,128 +48,60 @@ void UT_os_sample_test() void UT_os_bin_sem_create_test() { int i; - int32 res = 0; - const char* testDesc; - uint32 test_setup_invalid = 0; char sem_name[UT_OS_NAME_BUFF_SIZE]; char long_sem_name[UT_OS_NAME_BUFF_SIZE]; uint32 sem_ids[OS_MAX_BIN_SEMAPHORES+1]; /*-----------------------------------------------------*/ - testDesc = "API not implemented"; - - res = OS_BinSemCreate(&sem_ids[0], "Good", 1, 0 ); - if (res == OS_ERR_NOT_IMPLEMENTED) - { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_NA); - goto UT_os_bin_sem_create_test_exit_tag; - } - - /* Clean up */ - OS_BinSemDelete(sem_ids[0]); + if (!UT_IMPL(OS_BinSemCreate(&sem_ids[0], "Good", 1, 0))) return; + UT_TEARDOWN(OS_BinSemDelete(sem_ids[0])); /*-----------------------------------------------------*/ - testDesc = "#1 Null-pointer-arg-1"; - - res = OS_BinSemCreate(NULL, "BinSem1", 1, 0); - if (res == OS_INVALID_POINTER) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); - else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_RETVAL(OS_BinSemCreate(NULL, "BinSem1", 1, 0), OS_INVALID_POINTER, "null pointer arg 1"); /*-----------------------------------------------------*/ - testDesc = "#2 Null-pointer-arg-2"; - - res = OS_BinSemCreate(&sem_ids[0], NULL, 1, 0); - if (res == OS_INVALID_POINTER) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); - else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_RETVAL(OS_BinSemCreate(&sem_ids[0], NULL, 1, 0), OS_INVALID_POINTER, "null pointer arg 2"); /*-----------------------------------------------------*/ - testDesc = "#3 Name-too-long"; - memset(long_sem_name, 'X', sizeof(long_sem_name)); long_sem_name[sizeof(long_sem_name)-1] = '\0'; - res = OS_BinSemCreate(&sem_ids[0], long_sem_name, 1, 0); - if (res == OS_ERR_NAME_TOO_LONG) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); - else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_RETVAL(OS_BinSemCreate(&sem_ids[0], long_sem_name, 1, 0), OS_ERR_NAME_TOO_LONG, "name too long"); /*-----------------------------------------------------*/ - testDesc = "#4 No-free-IDs"; - /* Setup */ for ( i = 0; i< OS_MAX_BIN_SEMAPHORES; i++ ) { memset(sem_name, '\0', sizeof(sem_name)); UT_os_sprintf(sem_name, "BINSEM%d", i); - res = OS_BinSemCreate(&sem_ids[i], sem_name, 1, 0); - if ( res != OS_SUCCESS ) + if(!UT_SETUP(OS_BinSemCreate(&sem_ids[i], sem_name, 1, 0))) { - testDesc = "#4 No-free-IDs - Bin Sem Create failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); - test_setup_invalid = 1; - break; + break; } } - if ( test_setup_invalid == 0 ) + if ( i == OS_MAX_BIN_SEMAPHORES ) /* setup was successful */ { - res = OS_BinSemCreate(&sem_ids[OS_MAX_BIN_SEMAPHORES], "OneTooMany", 1, 0); - if (res == OS_ERR_NO_FREE_IDS) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); - else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); - + UT_RETVAL(OS_BinSemCreate(&sem_ids[OS_MAX_BIN_SEMAPHORES], "OneTooMany", 1, 0), OS_ERR_NO_FREE_IDS, "no free ids"); } /* Reset test environment */ OS_DeleteAllObjects(); /*-----------------------------------------------------*/ - testDesc = "#5 Duplicate-name"; - - /* Setup */ - res = OS_BinSemCreate(&sem_ids[0], "DUPLICATE", 1, 0); - if ( res != OS_SUCCESS ) - { - testDesc = "#5 Duplicate-name - Bin Sem Create failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); - } - else + if(UT_SETUP(OS_BinSemCreate(&sem_ids[0], "DUPLICATE", 1, 0))) { - res = OS_BinSemCreate(&sem_ids[0], "DUPLICATE", 1, 0); - if (res == OS_ERR_NAME_TAKEN) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); - else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_RETVAL(OS_BinSemCreate(&sem_ids[0], "DUPLICATE", 1, 0), OS_ERR_NAME_TAKEN, "duplicate name"); /* Reset test environment */ - res = OS_BinSemDelete(sem_ids[0]); + UT_TEARDOWN(OS_BinSemDelete(sem_ids[0])); } /*-----------------------------------------------------*/ - testDesc = "#6 OS-call-failure"; - - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_INFO); - - /*-----------------------------------------------------*/ - testDesc = "#7 Nominal"; - - res = OS_BinSemCreate(&sem_ids[0], "Good", 1, 0); - if ( res == OS_SUCCESS ) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); - else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_NOMINAL(OS_BinSemCreate(&sem_ids[0], "Good", 1, 0)); /* Reset test environment */ - res = OS_BinSemDelete(sem_ids[0]); - -UT_os_bin_sem_create_test_exit_tag: - return; + UT_TEARDOWN(OS_BinSemDelete(sem_ids[0])); } /*--------------------------------------------------------------------------------* @@ -260,55 +114,19 @@ void UT_os_bin_sem_create_test() **--------------------------------------------------------------------------------*/ void UT_os_bin_sem_delete_test() { - int32 res = 0; - const char* testDesc; uint32 bin_sem_id; /*-----------------------------------------------------*/ - testDesc = "API not implemented"; - - res = OS_BinSemDelete(0); - if (res == OS_ERR_NOT_IMPLEMENTED) - { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_NA); - goto UT_os_bin_sem_delete_test_exit_tag; - } - - /*-----------------------------------------------------*/ - testDesc = "#1 Invalid-ID-arg"; - - res = OS_BinSemDelete(99999); - if ( res == OS_ERR_INVALID_ID ) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); - else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + if (!UT_IMPL(OS_BinSemDelete(0))) return; /*-----------------------------------------------------*/ - testDesc = "#2 OS-call-failure"; - - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_INFO); + UT_RETVAL(OS_BinSemDelete(99999), OS_ERR_INVALID_ID, "invalid id arg"); /*-----------------------------------------------------*/ - testDesc = "#3 Nominal"; - - /* Setup */ - res = OS_BinSemCreate(&bin_sem_id, "DeleteTest", 1, 0); - if ( res != OS_SUCCESS ) + if(UT_SETUP(OS_BinSemCreate(&bin_sem_id, "DeleteTest", 1, 0))) { - testDesc = "#3 Nominal - Bin Sem Create failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_NOMINAL(OS_BinSemDelete(bin_sem_id)); } - else - { - res = OS_BinSemDelete(bin_sem_id); - if ( res == OS_SUCCESS ) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); - else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); - } - -UT_os_bin_sem_delete_test_exit_tag: - return; } /*--------------------------------------------------------------------------------* @@ -322,58 +140,20 @@ void UT_os_bin_sem_delete_test() **--------------------------------------------------------------------------------*/ void UT_os_bin_sem_flush_test() { - int32 res = 0; - const char* testDesc; uint32 bin_sem_id; /*-----------------------------------------------------*/ - testDesc = "API not implemented"; - - res = OS_BinSemFlush(0); - if (res == OS_ERR_NOT_IMPLEMENTED) - { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_NA); - goto UT_os_bin_sem_flush_test_exit_tag; - } - - /*-----------------------------------------------------*/ - testDesc = "#1 Invalid-ID-arg"; - - res = OS_BinSemFlush(99999); - if ( res == OS_ERR_INVALID_ID ) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); - else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + if (!UT_IMPL(OS_BinSemFlush(0))) return; /*-----------------------------------------------------*/ - testDesc = "#2 OS-call-failure"; - - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_INFO); + UT_RETVAL(OS_BinSemFlush(99999), OS_ERR_INVALID_ID, "invalid id arg"); /*----------------------------------------------------*/ - testDesc = "#3 Nominal"; - - /* Setup */ - res = OS_BinSemCreate(&bin_sem_id, "FlushTest", 1, 0); - if ( res != OS_SUCCESS ) - { - testDesc = "#3 Nominal - Bin Sem Create failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); - } - else + if(UT_SETUP(OS_BinSemCreate(&bin_sem_id, "FlushTest", 1, 0))) { - res = OS_BinSemFlush(bin_sem_id); - if ( res == OS_SUCCESS ) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); - else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); - - res = OS_BinSemDelete(bin_sem_id); + UT_NOMINAL(OS_BinSemFlush(bin_sem_id)); + UT_TEARDOWN(OS_BinSemDelete(bin_sem_id)); } - -UT_os_bin_sem_flush_test_exit_tag: - return; - } /*--------------------------------------------------------------------------------* @@ -387,58 +167,20 @@ void UT_os_bin_sem_flush_test() **--------------------------------------------------------------------------------*/ void UT_os_bin_sem_give_test() { - int32 res = 0; - const char* testDesc; uint32 bin_sem_id; /*-----------------------------------------------------*/ - testDesc = "API not implemented"; - - res = OS_BinSemGive(0); - if (res == OS_ERR_NOT_IMPLEMENTED) - { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_NA); - goto UT_os_bin_sem_give_test_exit_tag; - } - - /*-----------------------------------------------------*/ - testDesc = "#1 Invalid-ID-arg"; - - res = OS_BinSemGive(99999); - if ( res == OS_ERR_INVALID_ID ) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); - else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + if (!UT_IMPL(OS_BinSemGive(0))) return; /*-----------------------------------------------------*/ - testDesc = "#2 OS-call-failure"; - - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_INFO); + UT_RETVAL(OS_BinSemGive(99999), OS_ERR_INVALID_ID, "invalid id arg"); /*-----------------------------------------------------*/ - testDesc = "#3 Nominal"; - - /* Setup */ - res = OS_BinSemCreate(&bin_sem_id, "GiveTest", 1, 0); - if ( res != OS_SUCCESS ) + if (UT_SETUP(OS_BinSemCreate(&bin_sem_id, "GiveTest", 1, 0))) { - testDesc = "#3 Nominal - Bin Sem Create failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_NOMINAL(OS_BinSemGive(bin_sem_id)); + UT_TEARDOWN(OS_BinSemDelete(bin_sem_id)); } - else - { - res = OS_BinSemGive(bin_sem_id); - if ( res == OS_SUCCESS ) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); - else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); - - res = OS_BinSemDelete(bin_sem_id); - } - -UT_os_bin_sem_give_test_exit_tag: - return; - } /*--------------------------------------------------------------------------------* @@ -453,58 +195,20 @@ void UT_os_bin_sem_give_test() **--------------------------------------------------------------------------------*/ void UT_os_bin_sem_take_test() { - int32 res = 0; - const char* testDesc; uint32 bin_sem_id; /*-----------------------------------------------------*/ - testDesc = "API not implemented"; - - res = OS_BinSemTake(0); - if (res == OS_ERR_NOT_IMPLEMENTED) - { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_NA); - goto UT_os_bin_sem_take_test_exit_tag; - } - - /*-----------------------------------------------------*/ - testDesc = "#1 Invalid-ID-arg"; - - res = OS_BinSemTake(99999); - if ( res == OS_ERR_INVALID_ID ) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); - else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + if (!UT_IMPL(OS_BinSemTake(0))) return; /*-----------------------------------------------------*/ - testDesc = "#2 OS-call-failure"; - - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_INFO); + UT_RETVAL(OS_BinSemTake(99999), OS_ERR_INVALID_ID, "invalid id arg"); /*-----------------------------------------------------*/ - testDesc = "#3 Nominal"; - - /* Setup */ - res = OS_BinSemCreate(&bin_sem_id, "TakeTest", 1, 0); - if ( res != OS_SUCCESS ) - { - testDesc = "#3 Nominal - Bin Sem Create failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); - } - else + if (UT_SETUP(OS_BinSemCreate(&bin_sem_id, "TakeTest", 1, 0))) { - res = OS_BinSemTake(bin_sem_id); - if ( res == OS_SUCCESS ) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); - else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); - - res = OS_BinSemDelete(bin_sem_id); + UT_NOMINAL(OS_BinSemTake(bin_sem_id)); + UT_TEARDOWN(OS_BinSemDelete(bin_sem_id)); } - -UT_os_bin_sem_take_test_exit_tag: - return; - } /*--------------------------------------------------------------------------------* @@ -518,88 +222,28 @@ void UT_os_bin_sem_take_test() **--------------------------------------------------------------------------------*/ void UT_os_bin_sem_timed_wait_test() { - int32 res = 0; - const char* testDesc; uint32 bin_sem_id; /*-----------------------------------------------------*/ - testDesc = "API not implemented"; - - res = OS_BinSemTimedWait(0,1000); - if (res == OS_ERR_NOT_IMPLEMENTED) - { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_NA); - goto UT_os_bin_sem_timed_wait_test_exit_tag; - } - - /*-----------------------------------------------------*/ - testDesc = "#1 Invalid-ID-arg"; - - res = OS_BinSemTimedWait(99999, 1000); - if ( res == OS_ERR_INVALID_ID ) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); - else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + if (!UT_IMPL(OS_BinSemTimedWait(0, 1000))) return; /*-----------------------------------------------------*/ - testDesc = "#2 OS-call-failure"; - - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_INFO); + UT_RETVAL(OS_BinSemTimedWait(99999, 1000), OS_ERR_INVALID_ID, "invalid id arg"); /*-----------------------------------------------------*/ - testDesc = "#3 Sem-take-timed-out"; - - /* Setup */ - res = OS_BinSemCreate(&bin_sem_id, "TimedWait", 1, 0); - if ( res != OS_SUCCESS ) - { - testDesc = "#3 Sem-take-timed-out - Bin Sem Create failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); - } - else + if(UT_SETUP(OS_BinSemCreate(&bin_sem_id, "TimedWait", 1, 0)) + && UT_SETUP(OS_BinSemTake(bin_sem_id))) { - res = OS_BinSemTake(bin_sem_id); - if ( res != OS_SUCCESS ) - { - testDesc = "#3 Sem-take-timed-out - Bin Sem Take failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); - } - else - { - res = OS_BinSemTimedWait(bin_sem_id,1000); - if ( res == OS_SEM_TIMEOUT ) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); - else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); - - } - res = OS_BinSemDelete(bin_sem_id); + UT_RETVAL(OS_BinSemTimedWait(bin_sem_id, 1000), OS_SEM_TIMEOUT, "semtake timed out"); + UT_TEARDOWN(OS_BinSemDelete(bin_sem_id)); } /*-----------------------------------------------------*/ - testDesc = "#4 Nominal"; - - /* Setup */ - res = OS_BinSemCreate(&bin_sem_id, "TimedWait", 1, 0); - if ( res != OS_SUCCESS ) + if(UT_SETUP(OS_BinSemCreate(&bin_sem_id, "TimedWait", 1, 0))) { - testDesc = "#4 Nominal - Bin Sem Create failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_NOMINAL(OS_BinSemTimedWait(bin_sem_id, 1000)); + UT_TEARDOWN(OS_BinSemDelete(bin_sem_id)); } - else - { - res = OS_BinSemTimedWait(bin_sem_id,1000); - if ( res == OS_SUCCESS ) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); - else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); - - res = OS_BinSemDelete(bin_sem_id); - } - -UT_os_bin_sem_timed_wait_test_exit_tag: - return; - } /*--------------------------------------------------------------------------------* @@ -614,83 +258,32 @@ void UT_os_bin_sem_timed_wait_test() **--------------------------------------------------------------------------------*/ void UT_os_bin_sem_get_id_by_name_test() { - int32 res = 0; - const char* testDesc; uint32 bin_sem_id; char long_sem_name[UT_OS_NAME_BUFF_SIZE]; /*-----------------------------------------------------*/ - testDesc = "API not implemented"; - - res = OS_BinSemGetIdByName(0, "InvalidName"); - if (res == OS_ERR_NOT_IMPLEMENTED) - { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_NA); - goto UT_os_bin_sem_get_id_by_name_test_exit_tag; - } + if (!UT_IMPL(OS_BinSemGetIdByName(NULL, "InvalidName"))) return; /*-----------------------------------------------------*/ - testDesc = "#1 Invalid-pointer-arg-1"; - - res = OS_BinSemGetIdByName(NULL, "InvalidName"); - if ( res == OS_INVALID_POINTER ) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); - else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); - - /*-----------------------------------------------------*/ - testDesc = "#2 Invalid-pointer-arg-2"; - - res = OS_BinSemGetIdByName(&bin_sem_id, NULL); - if ( res == OS_INVALID_POINTER ) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); - else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_RETVAL(OS_BinSemGetIdByName(NULL, "InvalidName"), OS_INVALID_POINTER, "invalid ptr arg 1"); /*-----------------------------------------------------*/ - testDesc = "#3 Name-too-long"; + UT_RETVAL(OS_BinSemGetIdByName(&bin_sem_id, NULL), OS_INVALID_POINTER, "invalid ptr arg 2"); + /*-----------------------------------------------------*/ memset(long_sem_name, 'Y', sizeof(long_sem_name)); long_sem_name[sizeof(long_sem_name)-1] = '\0'; - res = OS_BinSemGetIdByName(&bin_sem_id, long_sem_name); - if ( res == OS_ERR_NAME_TOO_LONG ) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); - else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_RETVAL(OS_BinSemGetIdByName(&bin_sem_id, long_sem_name), OS_ERR_NAME_TOO_LONG, "name too long"); /*-----------------------------------------------------*/ - testDesc = "#4 Name-not-found"; - - res = OS_BinSemGetIdByName(&bin_sem_id, "NameNotFound"); - if ( res == OS_ERR_NAME_NOT_FOUND ) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); - else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_RETVAL(OS_BinSemGetIdByName(&bin_sem_id, "NameNotFound"), OS_ERR_NAME_NOT_FOUND, "name not found"); /*-----------------------------------------------------*/ - testDesc = "#5 Nominal"; - - /* Setup */ - res = OS_BinSemCreate(&bin_sem_id, "GetIDByName", 1, 0); - if ( res != OS_SUCCESS ) - { - testDesc = "#5 Nominal - Bin Sem Create failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); - } - else + if(UT_SETUP(OS_BinSemCreate(&bin_sem_id, "GetIDByName", 1, 0))) { - res = OS_BinSemGetIdByName(&bin_sem_id, "GetIDByName"); - if ( res == OS_SUCCESS ) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); - else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); - - res = OS_BinSemDelete(bin_sem_id); + UT_NOMINAL(OS_BinSemGetIdByName(&bin_sem_id, "GetIDByName")); + UT_TEARDOWN(OS_BinSemDelete(bin_sem_id)); } - -UT_os_bin_sem_get_id_by_name_test_exit_tag: - return; - } /*--------------------------------------------------------------------------------* @@ -704,75 +297,28 @@ void UT_os_bin_sem_get_id_by_name_test() **--------------------------------------------------------------------------------*/ void UT_os_bin_sem_get_info_test() { - int32 res = 0; - const char* testDesc; uint32 bin_sem_id; OS_bin_sem_prop_t bin_sem_prop; /*-----------------------------------------------------*/ - testDesc = "API not implemented"; - - res = OS_BinSemGetInfo(0, &bin_sem_prop); - if (res == OS_ERR_NOT_IMPLEMENTED) - { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_NA); - goto UT_os_bin_sem_get_info_test_exit_tag; - } + if (!UT_IMPL(OS_BinSemGetInfo(0, &bin_sem_prop))) return; /*-----------------------------------------------------*/ - testDesc = "#1 Invalid-ID-arg"; - - res = OS_BinSemGetInfo(99999, &bin_sem_prop); - if ( res == OS_ERR_INVALID_ID ) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); - else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_RETVAL(OS_BinSemGetInfo(99999, &bin_sem_prop), OS_ERR_INVALID_ID, "invalid id"); /*-----------------------------------------------------*/ - testDesc = "#2 Invalid-pointer-arg"; - - /* Setup */ - res = OS_BinSemCreate(&bin_sem_id, "GetInfo", 1, 0); - if ( res != OS_SUCCESS ) + if(UT_SETUP(OS_BinSemCreate(&bin_sem_id, "GetInfo", 1, 0))) { - testDesc = "#2 Invalid-pointer-arg - Bin Sem Create failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); - } - else - { - res = OS_BinSemGetInfo(bin_sem_id, NULL); - if ( res == OS_INVALID_POINTER ) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); - else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); - - res = OS_BinSemDelete(bin_sem_id); + UT_RETVAL(OS_BinSemGetInfo(bin_sem_id, NULL),OS_INVALID_POINTER, "invalid ptr"); + UT_TEARDOWN(OS_BinSemDelete(bin_sem_id)); } /*-----------------------------------------------------*/ - testDesc = "#3 Nominal"; - - /* Setup */ - res = OS_BinSemCreate(&bin_sem_id, "GetInfo", 1, 0); - if ( res != OS_SUCCESS ) + if(UT_SETUP(OS_BinSemCreate(&bin_sem_id, "GetInfo", 1, 0))) { - testDesc = "#3 Nominal - Bin Sem Create failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_NOMINAL(OS_BinSemGetInfo(bin_sem_id, &bin_sem_prop)); + UT_TEARDOWN(OS_BinSemDelete(bin_sem_id)); } - else - { - res = OS_BinSemGetInfo(bin_sem_id, &bin_sem_prop); - if ( res == OS_SUCCESS ) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); - else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); - - res = OS_BinSemDelete(bin_sem_id); - } - -UT_os_bin_sem_get_info_test_exit_tag: - return; - } /*================================================================================* diff --git a/src/unit-tests/oscore-test/ut_oscore_countsem_test.c b/src/unit-tests/oscore-test/ut_oscore_countsem_test.c index 8abde7c35..4d3b746ab 100644 --- a/src/unit-tests/oscore-test/ut_oscore_countsem_test.c +++ b/src/unit-tests/oscore-test/ut_oscore_countsem_test.c @@ -34,84 +34,6 @@ ** Local function definitions **--------------------------------------------------------------------------------*/ -/* Test code template for testing a single OSAL API with multiple test cases */ - -#if 0 -void UT_os_sample_test() -{ - /* Must declare these variables for each function. They can be renamed. - * They're referenced in the macros used to track test cases and their results. */ - int32 idx = 0; - const char* testDesc; - - /*-----------------------------------------------------* - * For each test case, - * 1. Assign testDesc a brief description of the test - * 2. Setup the test environment, if necessary - * 3. Run the test - * 4. Log result by calling UT_OS_SET_TEST_RESULT_MACRO - * 4. Reset the test environment, if neccessary - * - * NOTE: "Not implemented" is always checked first but not - * being included as a test case. - * "Nominal" test case is always the last test case. - *-----------------------------------------------------*/ - - /*-----------------------------------------------------*/ - testDesc = "API not implemented"; - - /* TODO: Setup the test environment, if necessary */ - - if (OS_xxx() == OS_ERR_NOT_IMPLEMENTED) - { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_NA); - goto UT_os_sample_test_exit_tag; - } - - /* TODO: Reset the test environment here, if necessary */ - - /*-----------------------------------------------------*/ - testDesc = "#1 Null-pointer-arg"; - - /* TODO: Setup the test environment here, if necessary */ - - if (OS_xxx(NULL,...) == OS_INVALID_POINTER) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); - else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); - - /* TODO: Reset the test environment here, if necessary */ - - /*-----------------------------------------------------*/ - testDesc = "#2 Name-too-long-arg"; - - /* TODO: Setup the test environment here, if necessary */ - - if (OS_xxx(aVeryLoooooongName) == OS_ERR_NAME_TOO_LONG) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); - else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); - - /* TODO: Reset the test environment here, if necessary */ - - /*-----------------------------------------------------*/ - testDesc = "#3 Nominal"; - - /* TODO: Setup the test environment here, if necessary */ - - if (OS_xxx(...) != OS_SUCCESS) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); - else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); - - /* TODO: Reset the test environment here, if necessary */ - -UT_os_sample_test_exit_tag: - return; - -} -#endif - /*--------------------------------------------------------------------------------* ** Syntax: OS_CountSemCreate ** Purpose: Creates a counting semaphore diff --git a/src/unit-tests/oscore-test/ut_oscore_exception_test.c b/src/unit-tests/oscore-test/ut_oscore_exception_test.c index 3f75bd0df..7aac9199a 100644 --- a/src/unit-tests/oscore-test/ut_oscore_exception_test.c +++ b/src/unit-tests/oscore-test/ut_oscore_exception_test.c @@ -34,84 +34,6 @@ ** Local function definitions **--------------------------------------------------------------------------------*/ -/* Test code template for testing a single OSAL API with multiple test cases */ - -#if 0 -void UT_os_sample_test() -{ - /* Must declare these variables for each function. They can be renamed. - * They're referenced in the macros used to track test cases and their results. */ - int32 idx = 0; - const char* testDesc; - - /*-----------------------------------------------------* - * For each test case, - * 1. Assign testDesc a brief description of the test - * 2. Setup the test environment, if necessary - * 3. Run the test - * 4. Log result by calling UT_OS_SET_TEST_RESULT_MACRO - * 4. Reset the test environment, if neccessary - * - * NOTE: "Not implemented" is always checked first but not - * being included as a test case. - * "Nominal" test case is always the last test case. - *-----------------------------------------------------*/ - - /*-----------------------------------------------------*/ - testDesc = "API not implemented"; - - /* TODO: Setup the test environment, if necessary */ - - if (OS_xxx() == OS_ERR_NOT_IMPLEMENTED) - { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_NA); - goto UT_os_sample_test_exit_tag; - } - - /* TODO: Reset the test environment here, if necessary */ - - /*-----------------------------------------------------*/ - testDesc = "#1 Null-pointer-arg"; - - /* TODO: Setup the test environment here, if necessary */ - - if (OS_xxx(NULL,...) == OS_INVALID_POINTER) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); - else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); - - /* TODO: Reset the test environment here, if necessary */ - - /*-----------------------------------------------------*/ - testDesc = "#2 Name-too-long-arg"; - - /* TODO: Setup the test environment here, if necessary */ - - if (OS_xxx(aVeryLoooooongName) == OS_ERR_NAME_TOO_LONG) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); - else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); - - /* TODO: Reset the test environment here, if necessary */ - - /*-----------------------------------------------------*/ - testDesc = "#3 Nominal"; - - /* TODO: Setup the test environment here, if necessary */ - - if (OS_xxx(...) != OS_SUCCESS) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); - else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); - - /* TODO: Reset the test environment here, if necessary */ - -UT_os_sample_test_exit_tag: - return; - -} -#endif - /*--------------------------------------------------------------------------------* ** Syntax: int32 OS_FPUExcSetMask(uint32 mask) ** Purpose: Sets the FPU exception mask diff --git a/src/unit-tests/oscore-test/ut_oscore_misc_test.c b/src/unit-tests/oscore-test/ut_oscore_misc_test.c index 447aaf7d0..8665800a0 100644 --- a/src/unit-tests/oscore-test/ut_oscore_misc_test.c +++ b/src/unit-tests/oscore-test/ut_oscore_misc_test.c @@ -38,84 +38,6 @@ ** Local function definitions **--------------------------------------------------------------------------------*/ -/* Test code template for testing a single OSAL API with multiple test cases */ - -#if 0 -void UT_os_sample_test() -{ - /* Must declare these variables for each function. They can be renamed. - * They're referenced in the macros used to track test cases and their results. */ - int32 idx = 0; - const char* testDesc; - - /*-----------------------------------------------------* - * For each test case, - * 1. Assign testDesc a brief description of the test - * 2. Setup the test environment, if necessary - * 3. Run the test - * 4. Log result by calling UT_OS_SET_TEST_RESULT_MACRO - * 4. Reset the test environment, if neccessary - * - * NOTE: "Not implemented" is always checked first but not - * being included as a test case. - * "Nominal" test case is always the last test case. - *-----------------------------------------------------*/ - - /*-----------------------------------------------------*/ - testDesc = "API not implemented"; - - /* TODO: Setup the test environment, if necessary */ - - if (OS_xxx() == OS_ERR_NOT_IMPLEMENTED) - { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_NA); - goto UT_os_sample_test_exit_tag; - } - - /* TODO: Reset the test environment here, if necessary */ - - /*-----------------------------------------------------*/ - testDesc = "#1 Null-pointer-arg"; - - /* TODO: Setup the test environment here, if necessary */ - - if (OS_xxx(NULL,...) == OS_INVALID_POINTER) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); - else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); - - /* TODO: Reset the test environment here, if necessary */ - - /*-----------------------------------------------------*/ - testDesc = "#2 Name-too-long-arg"; - - /* TODO: Setup the test environment here, if necessary */ - - if (OS_xxx(aVeryLoooooongName) == OS_ERR_NAME_TOO_LONG) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); - else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); - - /* TODO: Reset the test environment here, if necessary */ - - /*-----------------------------------------------------*/ - testDesc = "#3 Nominal"; - - /* TODO: Setup the test environment here, if necessary */ - - if (OS_xxx(...) != OS_SUCCESS) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); - else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); - - /* TODO: Reset the test environment here, if necessary */ - -UT_os_sample_test_exit_tag: - return; - -} -#endif - /*--------------------------------------------------------------------------------* ** Syntax: int32 OS_API_Init(void) ** Purpose: Initializes the tables that the OS API uses to keep track of information diff --git a/src/unit-tests/oscore-test/ut_oscore_mutex_test.c b/src/unit-tests/oscore-test/ut_oscore_mutex_test.c index ca2f31a4b..8cbbbe37e 100644 --- a/src/unit-tests/oscore-test/ut_oscore_mutex_test.c +++ b/src/unit-tests/oscore-test/ut_oscore_mutex_test.c @@ -34,84 +34,6 @@ ** Local function definitions **--------------------------------------------------------------------------------*/ -/* Test code template for testing a single OSAL API with multiple test cases */ - -#if 0 -void UT_os_sample_test() -{ - /* Must declare these variables for each function. They can be renamed. - * They're referenced in the macros used to track test cases and their results. */ - int32 idx = 0; - const char* testDesc; - - /*-----------------------------------------------------* - * For each test case, - * 1. Assign testDesc a brief description of the test - * 2. Setup the test environment, if necessary - * 3. Run the test - * 4. Log result by calling UT_OS_SET_TEST_RESULT_MACRO - * 4. Reset the test environment, if neccessary - * - * NOTE: "Not implemented" is always checked first but not - * being included as a test case. - * "Nominal" test case is always the last test case. - *-----------------------------------------------------*/ - - /*-----------------------------------------------------*/ - testDesc = "API not implemented"; - - /* TODO: Setup the test environment, if necessary */ - - if (OS_xxx() == OS_ERR_NOT_IMPLEMENTED) - { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_NA); - goto UT_os_sample_test_exit_tag; - } - - /* TODO: Reset the test environment here, if necessary */ - - /*-----------------------------------------------------*/ - testDesc = "#1 Null-pointer-arg"; - - /* TODO: Setup the test environment here, if necessary */ - - if (OS_xxx(NULL,...) == OS_INVALID_POINTER) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); - else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); - - /* TODO: Reset the test environment here, if necessary */ - - /*-----------------------------------------------------*/ - testDesc = "#2 Name-too-long-arg"; - - /* TODO: Setup the test environment here, if necessary */ - - if (OS_xxx(aVeryLoooooongName) == OS_ERR_NAME_TOO_LONG) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); - else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); - - /* TODO: Reset the test environment here, if necessary */ - - /*-----------------------------------------------------*/ - testDesc = "#3 Nominal"; - - /* TODO: Setup the test environment here, if necessary */ - - if (OS_xxx(...) != OS_SUCCESS) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); - else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); - - /* TODO: Reset the test environment here, if necessary */ - -UT_os_sample_test_exit_tag: - return; - -} -#endif - /*--------------------------------------------------------------------------------* ** Syntax: OS_MutSemCreate ** Purpose: Creates a mutex semaphore diff --git a/src/unit-tests/oscore-test/ut_oscore_queue_test.c b/src/unit-tests/oscore-test/ut_oscore_queue_test.c index 45abc6ac7..4f490ccd9 100644 --- a/src/unit-tests/oscore-test/ut_oscore_queue_test.c +++ b/src/unit-tests/oscore-test/ut_oscore_queue_test.c @@ -38,84 +38,6 @@ ** Local function definitions **--------------------------------------------------------------------------------*/ -/* Test code template for testing a single OSAL API with multiple test cases */ - -#if 0 -void UT_os_sample_test() -{ - /* Must declare these variables for each function. They can be renamed. - * They're referenced in the macros used to track test cases and their results. */ - int32 idx = 0; - const char* testDesc; - - /*-----------------------------------------------------* - * For each test case, - * 1. Assign testDesc a brief description of the test - * 2. Setup the test environment, if necessary - * 3. Run the test - * 4. Log result by calling UT_OS_SET_TEST_RESULT_MACRO - * 4. Reset the test environment, if neccessary - * - * NOTE: "Not implemented" is always checked first but not - * being included as a test case. - * "Nominal" test case is always the last test case. - *-----------------------------------------------------*/ - - /*-----------------------------------------------------*/ - testDesc = "API not implemented"; - - /* TODO: Setup the test environment, if necessary */ - - if (OS_xxx() == OS_ERR_NOT_IMPLEMENTED) - { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_NA); - goto UT_os_sample_test_exit_tag; - } - - /* TODO: Reset the test environment here, if necessary */ - - /*-----------------------------------------------------*/ - testDesc = "#1 Null-pointer-arg"; - - /* TODO: Setup the test environment here, if necessary */ - - if (OS_xxx(NULL,...) == OS_INVALID_POINTER) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); - else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); - - /* TODO: Reset the test environment here, if necessary */ - - /*-----------------------------------------------------*/ - testDesc = "#2 Name-too-long-arg"; - - /* TODO: Setup the test environment here, if necessary */ - - if (OS_xxx(aVeryLoooooongName) == OS_ERR_NAME_TOO_LONG) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); - else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); - - /* TODO: Reset the test environment here, if necessary */ - - /*-----------------------------------------------------*/ - testDesc = "#3 Nominal"; - - /* TODO: Setup the test environment here, if necessary */ - - if (OS_xxx(...) != OS_SUCCESS) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); - else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); - - /* TODO: Reset the test environment here, if necessary */ - -UT_os_sample_test_exit_tag: - return; - -} -#endif - /*--------------------------------------------------------------------------------* ** Syntax: OS_QueueCreate ** Purpose: Creates a queue in the OS diff --git a/src/unit-tests/oscore-test/ut_oscore_task_test.c b/src/unit-tests/oscore-test/ut_oscore_task_test.c index e8c9a1963..061e1f097 100644 --- a/src/unit-tests/oscore-test/ut_oscore_task_test.c +++ b/src/unit-tests/oscore-test/ut_oscore_task_test.c @@ -52,84 +52,6 @@ uint32 g_task_stacks[UT_OS_TASK_LIST_LEN][UT_TASK_STACK_SIZE]; ** Local function definitions **--------------------------------------------------------------------------------*/ -/* Test code template for testing a single OSAL API with multiple test cases */ - -#if 0 -void UT_os_sample_test() -{ - /* Must declare these variables for each function. They can be renamed. - * They're referenced in the macros used to track test cases and their results. */ - int32 idx = 0; - const char* testDesc; - - /*-----------------------------------------------------* - * For each test case, - * 1. Assign testDesc a brief description of the test - * 2. Setup the test environment, if necessary - * 3. Run the test - * 4. Log result by calling UT_OS_SET_TEST_RESULT_MACRO - * 4. Reset the test environment, if neccessary - * - * NOTE: "API not implemented" is always checked first but not - * being included as a test case. - * "Nominal" test case is always the last test case. - *-----------------------------------------------------*/ - - /*-----------------------------------------------------*/ - testDesc = "API not implemented"; - - /* TODO: Setup the test environment, if necessary */ - - if (OS_xxx() == OS_ERR_NOT_IMPLEMENTED) - { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_NA); - goto UT_os_sample_test_exit_tag; - } - - /* TODO: Reset the test environment here, if necessary */ - - /*-----------------------------------------------------*/ - testDesc = "#1 Null-pointer-arg"; - - /* TODO: Setup the test environment here, if necessary */ - - if (OS_xxx(NULL,...) == OS_INVALID_POINTER) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); - else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); - - /* TODO: Reset the test environment here, if necessary */ - - /*-----------------------------------------------------*/ - testDesc = "#2 Name-too-long-arg"; - - /* TODO: Setup the test environment here, if necessary */ - - if (OS_xxx(aVeryLoooooongName) == OS_ERR_NAME_TOO_LONG) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); - else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); - - /* TODO: Reset the test environment here, if necessary */ - - /*-----------------------------------------------------*/ - testDesc = "#3 Nominal"; - - /* TODO: Setup the test environment here, if necessary */ - - if (OS_xxx(...) != OS_SUCCESS) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); - else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); - - /* TODO: Reset the test environment here, if necessary */ - -UT_os_sample_test_exit_tag: - return; - -} -#endif - /*--------------------------------------------------------------------------------*/ void generic_test_task(void) diff --git a/src/unit-tests/osfile-test/ut_osfile_dirio_test.c b/src/unit-tests/osfile-test/ut_osfile_dirio_test.c index 62d9f082f..0385516d4 100644 --- a/src/unit-tests/osfile-test/ut_osfile_dirio_test.c +++ b/src/unit-tests/osfile-test/ut_osfile_dirio_test.c @@ -52,84 +52,6 @@ void UT_os_read_n_sort_dirs(uint32); ** Local function definitions **--------------------------------------------------------------------------------*/ -/* Test code template for testing a single OSAL API with multiple test cases */ - -#if 0 -void UT_os_sample_test() -{ - /* Must declare these variables for each function. They can be renamed. - * They're referenced in the macros used to track test cases and their results. */ - int32 idx = 0; - const char* testDesc; - - /*-----------------------------------------------------* - * For each test case, - * 1. Assign testDesc a brief description of the test - * 2. Setup the test environment, if necessary - * 3. Run the test - * 4. Log result by calling UT_OS_SET_TEST_RESULT_MACRO - * 4. Reset the test environment, if neccessary - * - * NOTE: "Not implemented" is always checked first but not - * being included as a test case. - * "Nominal" test case is always the last test case. - *-----------------------------------------------------*/ - - /*-----------------------------------------------------*/ - testDesc = "API not implemented"; - - /* TODO: Setup the test environment, if necessary */ - - if (OS_xxx() == OS_FS_UNIMPLEMENTED) - { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_NA); - goto UT_os_sample_test_exit_tag; - } - - /* TODO: Reset the test environment here, if necessary */ - - /*-----------------------------------------------------*/ - testDesc = "#1 Null-pointer-arg"; - - /* TODO: Setup the test environment here, if necessary */ - - if (OS_xxx(NULL,...) == OS_INVALID_POINTER) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); - else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); - - /* TODO: Reset the test environment here, if necessary */ - - /*-----------------------------------------------------*/ - testDesc = "#2 Name-too-long-arg"; - - /* TODO: Setup the test environment here, if necessary */ - - if (OS_xxx(aVeryLoooooongName) == OS_ERR_NAME_TOO_LONG) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); - else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); - - /* TODO: Reset the test environment here, if necessary */ - - /*-----------------------------------------------------*/ - testDesc = "#3 Nominal"; - - /* TODO: Setup the test environment here, if necessary */ - - if (OS_xxx(...) != OS_SUCCESS) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); - else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); - - /* TODO: Reset the test environment here, if necessary */ - -UT_os_sample_test_exit_tag: - return; - -} -#endif - /*--------------------------------------------------------------------------------* ** Syntax: int32 OS_mkdir(const char *path, uint32 access) ** Purpose: Creates a directory specified by path diff --git a/src/unit-tests/osfile-test/ut_osfile_fileio_test.c b/src/unit-tests/osfile-test/ut_osfile_fileio_test.c index 800e2d574..0bf7ca8aa 100644 --- a/src/unit-tests/osfile-test/ut_osfile_fileio_test.c +++ b/src/unit-tests/osfile-test/ut_osfile_fileio_test.c @@ -54,86 +54,6 @@ char g_writeBuff[UT_OS_IO_BUFF_SIZE]; ** Local function definitions **--------------------------------------------------------------------------------*/ -/* Test code template for testing a single OSAL API with multiple test cases */ - -#if 0 -void UT_os_sample_test() -{ - /* Must declare these variables for each function. They can be renamed. - * They're referenced in the macros used to track test cases and their results. */ - int32 idx = 0; - const char* testDesc; - - /*-----------------------------------------------------* - * For each test case, - * 1. Assign testDesc a brief description of the test - * 2. Setup the test environment, if necessary - * 3. Run the test - * 4. Log result by calling UT_OS_SET_TEST_RESULT_MACRO - * 4. Reset the test environment, if neccessary - * - * NOTE: "Not implemented" is always checked first but not - * being included as a test case. - * "Nominal" test case is always the last test case. - *-----------------------------------------------------*/ - - /*-----------------------------------------------------*/ - testDesc = "API not implemented"; - - /* TODO: Setup the test environment, if necessary */ - - if (OS_xxx() == OS_FS_UNIMPLEMENTED) - { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_NA); - goto UT_os_sample_test_exit_tag; - } - - /* TODO: Reset the test environment here, if necessary */ - - /*-----------------------------------------------------*/ - testDesc = "#1 Null-pointer-arg"; - - /* TODO: Setup the test environment here, if necessary */ - - if (OS_xxx(NULL,...) == OS_INVALID_POINTER) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); - else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); - - /* TODO: Reset the test environment here, if necessary */ - - /*-----------------------------------------------------*/ - testDesc = "#2 Name-too-long-arg"; - - /* TODO: Setup the test environment here, if necessary */ - - if (OS_xxx(aVeryLoooooongName) == OS_ERR_NAME_TOO_LONG) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); - else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); - - /* TODO: Reset the test environment here, if necessary */ - - /*-----------------------------------------------------*/ - testDesc = "#3 Nominal"; - - /* TODO: Setup the test environment here, if necessary */ - - if (OS_xxx(...) != OS_SUCCESS) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); - else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); - - /* TODO: Reset the test environment here, if necessary */ - -UT_os_sample_test_exit_tag: - /* Call these macros at the very end of the function to close out the test variables - * and get it added to the global list being tracked. */ - return; - -} -#endif - /*--------------------------------------------------------------------------------* ** Syntax: int32 OS_FS_Init(void) ** Purpose: Initializes the tables that the OS file-system uses to keep track of information diff --git a/src/unit-tests/osfilesys-test/ut_osfilesys_diskio_test.c b/src/unit-tests/osfilesys-test/ut_osfilesys_diskio_test.c index 4a8b097da..3a789925f 100644 --- a/src/unit-tests/osfilesys-test/ut_osfilesys_diskio_test.c +++ b/src/unit-tests/osfilesys-test/ut_osfilesys_diskio_test.c @@ -50,84 +50,6 @@ extern char g_mntNames[UT_OS_FILESYS_LIST_LEN][UT_OS_FILE_BUFF_SIZE]; ** Local function definitions **--------------------------------------------------------------------------------*/ -/* Test code template for testing a single OSAL API with multiple test cases */ - -#if 0 -void UT_os_sample_test() -{ - /* Must declare these variables for each function. They can be renamed. - * They're referenced in the macros used to track test cases and their results. */ - int32 idx = 0; - const char* testDesc; - - /*-----------------------------------------------------* - * For each test case, - * 1. Assign testDesc a brief description of the test - * 2. Setup the test environment, if necessary - * 3. Run the test - * 4. Log result by calling UT_OS_SET_TEST_RESULT_MACRO - * 4. Reset the test environment, if neccessary - * - * NOTE: "Not implemented" is always checked first but not - * being included as a test case. - * "Nominal" test case is always the last test case. - *-----------------------------------------------------*/ - - /*-----------------------------------------------------*/ - testDesc = "API not implemented"; - - /* TODO: Setup the test environment, if necessary */ - - if (OS_xxx() == OS_ERR_NOT_IMPLEMENTED) - { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_NA); - goto UT_os_sample_test_exit_tag; - } - - /* TODO: Reset the test environment here, if necessary */ - - /*-----------------------------------------------------*/ - testDesc = "#1 Null-pointer-arg"; - - /* TODO: Setup the test environment here, if necessary */ - - if (OS_xxx(NULL,...) == OS_INVALID_POINTER) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); - else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); - - /* TODO: Reset the test environment here, if necessary */ - - /*-----------------------------------------------------*/ - testDesc = "#2 Name-too-long-arg"; - - /* TODO: Setup the test environment here, if necessary */ - - if (OS_xxx(aVeryLoooooongName) == OS_ERR_NAME_TOO_LONG) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); - else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); - - /* TODO: Reset the test environment here, if necessary */ - - /*-----------------------------------------------------*/ - testDesc = "#3 Nominal"; - - /* TODO: Setup the test environment here, if necessary */ - - if (OS_xxx(...) != OS_SUCCESS) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); - else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); - - /* TODO: Reset the test environment here, if necessary */ - -UT_os_sample_test_exit_tag: - return; - -} -#endif - /*--------------------------------------------------------------------------------* ** Syntax: int32 OS_initfs(char *address, char *devname, char *volname, uint32 blocksize, uint32 numblocks) ** Purpose: Initializes (without re-formatting) a drive on the target without diff --git a/src/unit-tests/osloader-test/ut_osloader_module_test.c b/src/unit-tests/osloader-test/ut_osloader_module_test.c index df06fdcea..7cde3d814 100644 --- a/src/unit-tests/osloader-test/ut_osloader_module_test.c +++ b/src/unit-tests/osloader-test/ut_osloader_module_test.c @@ -35,86 +35,6 @@ ** Local function definitions **--------------------------------------------------------------------------------*/ -/* Test code template for testing a single OSAL API with multiple test cases */ - -#if 0 -void UT_os_sample_test() -{ - /* Must declare these variables for each function. They can be renamed. - * They're referenced in the macros used to track test cases and their results. */ - int32 idx = 0; - const char* testDesc; - - /*-----------------------------------------------------* - * For each test case, - * 1. Assign testDesc a brief description of the test - * 2. Setup the test environment, if necessary - * 3. Run the test - * 4. Log result by calling UT_OS_SET_TEST_RESULT_MACRO - * 4. Reset the test environment, if neccessary - * - * NOTE: "Not implemented" is always checked first but not - * being included as a test case. - * "Nominal" test case is always the last test case. - *-----------------------------------------------------*/ - - /*-----------------------------------------------------*/ - testDesc = "API Not implemented"; - - /* TODO: Setup the test environment, if necessary */ - - if (OS_xxx() == OS_ERR_NOT_IMPLEMENTED) - { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_NA); - goto UT_os_sample_test_exit_tag; - } - - /* TODO: Reset the test environment here, if necessary */ - - /*-----------------------------------------------------*/ - testDesc = "#1 Null-pointer-arg"; - - /* TODO: Setup the test environment here, if necessary */ - - if (OS_xxx(NULL,...) == OS_INVALID_POINTER) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); - else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); - - /* TODO: Reset the test environment here, if necessary */ - - /*-----------------------------------------------------*/ - testDesc = "#2 Name-too-long-arg"; - - /* TODO: Setup the test environment here, if necessary */ - - if (OS_xxx(aVeryLoooooongName) == OS_ERR_NAME_TOO_LONG) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); - else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); - - /* TODO: Reset the test environment here, if necessary */ - - /*-----------------------------------------------------*/ - testDesc = "#3 Nominal"; - - /* TODO: Setup the test environment here, if necessary */ - - if (OS_xxx(...) != OS_SUCCESS) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); - else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); - - /* TODO: Reset the test environment here, if necessary */ - -UT_os_sample_test_exit_tag: - /* Call these macros at the very end of the function to close out the test variables - * and get it added to the global list being tracked. */ - return; - -} -#endif - /*--------------------------------------------------------------------------------* ** Syntax: OS_ModuleLoad ** Purpose: Loads the new ELF object module into the RTOS diff --git a/src/unit-tests/osloader-test/ut_osloader_symtable_test.c b/src/unit-tests/osloader-test/ut_osloader_symtable_test.c index 3edea3131..04ce252f8 100644 --- a/src/unit-tests/osloader-test/ut_osloader_symtable_test.c +++ b/src/unit-tests/osloader-test/ut_osloader_symtable_test.c @@ -35,86 +35,6 @@ ** Local function definitions **--------------------------------------------------------------------------------*/ -/* Test code template for testing a single OSAL API with multiple test cases */ - -#if 0 -void UT_os_sample_test() -{ - /* Must declare these variables for each function. They can be renamed. - * They're referenced in the macros used to track test cases and their results. */ - int32 idx = 0; - const char* testDesc; - - /*-----------------------------------------------------* - * For each test case, - * 1. Assign testDesc a brief description of the test - * 2. Setup the test environment, if necessary - * 3. Run the test - * 4. Log result by calling UT_OS_SET_TEST_RESULT_MACRO - * 4. Reset the test environment, if neccessary - * - * NOTE: "Not implemented" is always checked first but not - * being included as a test case. - * "Nominal" test case is always the last test case. - *-----------------------------------------------------*/ - - /*-----------------------------------------------------*/ - testDesc = "API Not implemented"; - - /* TODO: Setup the test environment, if necessary */ - - if (OS_xxx() == OS_ERR_NOT_IMPLEMENTED) - { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_NA); - goto UT_os_sample_test_exit_tag; - } - - /* TODO: Reset the test environment here, if necessary */ - - /*-----------------------------------------------------*/ - testDesc = "#1 Null-pointer-arg"; - - /* TODO: Setup the test environment here, if necessary */ - - if (OS_xxx(NULL,...) == OS_INVALID_POINTER) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); - else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); - - /* TODO: Reset the test environment here, if necessary */ - - /*-----------------------------------------------------*/ - testDesc = "#2 Name-too-long-arg"; - - /* TODO: Setup the test environment here, if necessary */ - - if (OS_xxx(aVeryLoooooongName) == OS_ERR_NAME_TOO_LONG) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); - else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); - - /* TODO: Reset the test environment here, if necessary */ - - /*-----------------------------------------------------*/ - testDesc = "#3 Nominal"; - - /* TODO: Setup the test environment here, if necessary */ - - if (OS_xxx(...) != OS_SUCCESS) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); - else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); - - /* TODO: Reset the test environment here, if necessary */ - -UT_os_sample_test_exit_tag: - /* Call these macros at the very end of the function to close out the test variables - * and get it added to the global list being tracked. */ - return; - -} -#endif - /*--------------------------------------------------------------------------------* ** Syntax: OS_SymbolLookup ** Purpose: Returns the memory address of a symbol diff --git a/src/unit-tests/osnetwork-test/ut_osnetwork_misc_test.c b/src/unit-tests/osnetwork-test/ut_osnetwork_misc_test.c index d371c058c..76299c178 100644 --- a/src/unit-tests/osnetwork-test/ut_osnetwork_misc_test.c +++ b/src/unit-tests/osnetwork-test/ut_osnetwork_misc_test.c @@ -34,86 +34,6 @@ ** Local function definitions **--------------------------------------------------------------------------------*/ -/* Test code template for testing a single OSAL API with multiple test cases */ - -#if 0 -void UT_os_sample_test() -{ - /* Must declare these variables for each function. They can be renamed. - * They're referenced in the macros used to track test cases and their results. */ - int32 idx = 0; - const char* testDesc; - - /*-----------------------------------------------------* - * For each test case, - * 1. Assign testDesc a brief description of the test - * 2. Setup the test environment, if necessary - * 3. Run the test - * 4. Log result by calling UT_OS_SET_TEST_RESULT_MACRO - * 4. Reset the test environment, if neccessary - * - * NOTE: "Not implemented" is always checked first but not - * being included as a test case. - * "Nominal" test case is always the last test case. - *-----------------------------------------------------*/ - - /*-----------------------------------------------------*/ - testDesc = "API Not implemented"; - - /* TODO: Setup the test environment, if necessary */ - - if (OS_xxx() == OS_ERR_NOT_IMPLEMENTED) - { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_NA); - goto UT_os_sample_test_exit_tag; - } - - /* TODO: Reset the test environment here, if necessary */ - - /*-----------------------------------------------------*/ - testDesc = "#1 Null-pointer-arg"; - - /* TODO: Setup the test environment here, if necessary */ - - if (OS_xxx(NULL,...) == OS_INVALID_POINTER) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); - else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); - - /* TODO: Reset the test environment here, if necessary */ - - /*-----------------------------------------------------*/ - testDesc = "#2 Name-too-long-arg"; - - /* TODO: Setup the test environment here, if necessary */ - - if (OS_xxx(aVeryLoooooongName) == OS_ERR_NAME_TOO_LONG) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); - else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); - - /* TODO: Reset the test environment here, if necessary */ - - /*-----------------------------------------------------*/ - testDesc = "#3 Nominal"; - - /* TODO: Setup the test environment here, if necessary */ - - if (OS_xxx(...) != OS_SUCCESS) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); - else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); - - /* TODO: Reset the test environment here, if necessary */ - -UT_os_sample_test_exit_tag: - /* Call these macros at the very end of the function to close out the test variables - * and get it added to the global list being tracked. */ - return; - -} -#endif - /*--------------------------------------------------------------------------------* ** Syntax: int32 OS_NetworkGetID(void) ** Purpose: Returns network ID of the machine it is on diff --git a/src/unit-tests/ostimer-test/ut_ostimer_timerio_test.c b/src/unit-tests/ostimer-test/ut_ostimer_timerio_test.c index adee67e59..8b82084bb 100644 --- a/src/unit-tests/ostimer-test/ut_ostimer_timerio_test.c +++ b/src/unit-tests/ostimer-test/ut_ostimer_timerio_test.c @@ -52,84 +52,6 @@ uint32 g_timerIds[UT_OS_TIMER_LIST_LEN]; ** Local function definitions **--------------------------------------------------------------------------------*/ -/* Test code template for testing a single OSAL API with multiple test cases */ - -#if 0 -void UT_os_sample_test() -{ - /* Must declare these variables for each function. They can be renamed. - * They're referenced in the macros used to track test cases and their results. */ - int32 idx = 0; - const char* testDesc; - - /*-----------------------------------------------------* - * For each test case, - * 1. Assign testDesc a brief description of the test - * 2. Setup the test environment, if necessary - * 3. Run the test - * 4. Log result by calling UT_OS_SET_TEST_RESULT_MACRO - * 4. Reset the test environment, if neccessary - * - * NOTE: "Not implemented" is always checked first but not - * being included as a test case. - * "Nominal" test case is always the last test case. - *-----------------------------------------------------*/ - - /*-----------------------------------------------------*/ - testDesc = "API not implemented"; - - /* TODO: Setup the test environment, if necessary */ - - if (OS_xxx() == OS_ERR_NOT_IMPLEMENTED) - { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_NA); - goto UT_os_sample_test_exit_tag; - } - - /* TODO: Reset the test environment here, if necessary */ - - /*-----------------------------------------------------*/ - testDesc = "#1 Null-pointer-arg"; - - /* TODO: Setup the test environment here, if necessary */ - - if (OS_xxx(NULL,...) == OS_INVALID_POINTER) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); - else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); - - /* TODO: Reset the test environment here, if necessary */ - - /*-----------------------------------------------------*/ - testDesc = "#2 Name-too-long"; - - /* TODO: Setup the test environment here, if necessary */ - - if (OS_xxx(aVeryLoooooongName) == OS_ERR_NAME_TOO_LONG) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); - else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); - - /* TODO: Reset the test environment here, if necessary */ - - /*-----------------------------------------------------*/ - testDesc = "#3 Nominal"; - - /* TODO: Setup the test environment here, if necessary */ - - if (OS_xxx(...) != OS_SUCCESS) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); - else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); - - /* TODO: Reset the test environment here, if necessary */ - -UT_os_sample_test_exit_tag: - return; - -} -#endif - /*--------------------------------------------------------------------------------* ** Syntax: int32 OS_TimerAPIInit(void) ** Purpose: Initializes the tables that the OS timer uses to keep track of information