Merge pull request #34 from k0ekk0ek/cunit

Cleanup and CUnit integration and add support for theories and fixtures
This commit is contained in:
eboasson 2018-11-08 17:31:16 +01:00 committed by GitHub
commit 970680468c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
21 changed files with 863 additions and 667 deletions

View file

@ -11,6 +11,22 @@
#
include(CUnit)
add_cunit_executable(abstraction .)
set(sources
"atomics.c"
"error_no.c"
"heap.c"
"ifaddrs.c"
"iter.c"
"mutex.c"
"once.c"
"report.c"
"rwlock.c"
"stdlib.c"
"strtoll.c"
"thread.c"
"thread_cleanup.c"
"strcasecmp.c")
add_cunit_executable(abstraction ${sources})
target_link_libraries(abstraction OSAPI)

View file

@ -10,7 +10,7 @@
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
*/
#include "os/os.h"
#include "CUnit/Runner.h"
#include "CUnit/Test.h"
uint32_t _osuint32 = 0;
uint64_t _osuint64 = 0;
@ -19,7 +19,7 @@ uintptr_t _osaddress = 0;
ptrdiff_t _ptrdiff = 0;
void * _osvoidp = (uintptr_t *)0;
CUnit_Test(os_atomics, load_store)
CU_Test(os_atomics, load_store)
{
volatile os_atomic_uint32_t uint32 = OS_ATOMIC_UINT32_INIT(5);
#if OS_ATOMIC64_SUPPORT
@ -57,7 +57,7 @@ CUnit_Test(os_atomics, load_store)
printf ("Ending atomics_load_store\n");
}
CUnit_Test(os_atomics, compare_and_swap)
CU_Test(os_atomics, compare_and_swap)
{
/* Compare and Swap
* if (ptr == expected) { ptr = newval; }
@ -115,7 +115,7 @@ CUnit_Test(os_atomics, compare_and_swap)
printf ("Ending atomics_compare_and_swap\n");
}
CUnit_Test(os_atomics, increment)
CU_Test(os_atomics, increment)
{
volatile os_atomic_uint32_t uint32 = OS_ATOMIC_UINT32_INIT(0);
#if OS_ATOMIC64_SUPPORT
@ -164,7 +164,7 @@ CUnit_Test(os_atomics, increment)
printf ("Ending atomics_increment\n");
}
CUnit_Test(os_atomics, decrement)
CU_Test(os_atomics, decrement)
{
volatile os_atomic_uint32_t uint32 = OS_ATOMIC_UINT32_INIT(1);
#if OS_ATOMIC64_SUPPORT
@ -213,7 +213,7 @@ CUnit_Test(os_atomics, decrement)
printf ("Ending atomics_decrement\n");
}
CUnit_Test(os_atomics, add)
CU_Test(os_atomics, add)
{
volatile os_atomic_uint32_t uint32 = OS_ATOMIC_UINT32_INIT(1);
#if OS_ATOMIC64_SUPPORT
@ -273,7 +273,7 @@ CUnit_Test(os_atomics, add)
printf ("Ending atomics_add\n");
}
CUnit_Test(os_atomics, subtract)
CU_Test(os_atomics, subtract)
{
volatile os_atomic_uint32_t uint32 = OS_ATOMIC_UINT32_INIT(5);
#if OS_ATOMIC64_SUPPORT
@ -333,7 +333,7 @@ CUnit_Test(os_atomics, subtract)
printf ("Ending atomics_subtract\n");
}
CUnit_Test(os_atomics, and)
CU_Test(os_atomics, and)
{
/* AND Operation:
@ -399,7 +399,7 @@ CUnit_Test(os_atomics, and)
printf ("Ending atomics_and\n");
}
CUnit_Test(os_atomics, or)
CU_Test(os_atomics, or)
{
/* OR Operation:

View file

@ -9,11 +9,11 @@
*
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
*/
#include "CUnit/Runner.h"
#include "CUnit/Test.h"
#include "os/os.h"
CUnit_Suite_Initialize(os_errno)
CU_Init(os_errno)
{
int result = 0;
os_osInit();
@ -22,7 +22,7 @@ CUnit_Suite_Initialize(os_errno)
return result;
}
CUnit_Suite_Cleanup(os_errno)
CU_Clean(os_errno)
{
int result = 0;
os_osExit();
@ -31,7 +31,7 @@ CUnit_Suite_Cleanup(os_errno)
return result;
}
CUnit_Test(os_errno, get_and_set)
CU_Test(os_errno, get_and_set)
{
printf ("Starting os_errno_get_and_set_001\n");
os_setErrno (0);

View file

@ -9,11 +9,11 @@
*
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
*/
#include "CUnit/Runner.h"
#include "CUnit/Test.h"
#include "os/os.h"
CUnit_Suite_Initialize(os_heap)
CU_Init(os_heap)
{
int result = 0;
os_osInit();
@ -22,7 +22,7 @@ CUnit_Suite_Initialize(os_heap)
return result;
}
CUnit_Suite_Cleanup(os_heap)
CU_Clean(os_heap)
{
int result = 0;
os_osExit();
@ -34,7 +34,7 @@ CUnit_Suite_Cleanup(os_heap)
static const size_t allocsizes[] = {0, 1, 2, 3, 4, 5, 10, 20, 257, 1024};
static const size_t nof_allocsizes = sizeof allocsizes / sizeof *allocsizes;
CUnit_Test(os_heap, os_malloc)
CU_Test(os_heap, os_malloc)
{
for(size_t i = 0; i < nof_allocsizes; i++) {
for(size_t j = 0; j < nof_allocsizes; j++) {
@ -48,7 +48,7 @@ CUnit_Test(os_heap, os_malloc)
CU_PASS("os_malloc");
}
CUnit_Test(os_heap, os_malloc_0)
CU_Test(os_heap, os_malloc_0)
{
for(size_t i = 0; i < nof_allocsizes; i++) {
for(size_t j = 0; j < nof_allocsizes; j++) {
@ -64,7 +64,7 @@ CUnit_Test(os_heap, os_malloc_0)
CU_PASS("os_malloc_0");
}
CUnit_Test(os_heap, os_calloc)
CU_Test(os_heap, os_calloc)
{
for(size_t i = 0; i < nof_allocsizes; i++) {
for(size_t j = 0; j < nof_allocsizes; j++) {
@ -79,7 +79,7 @@ CUnit_Test(os_heap, os_calloc)
CU_PASS("os_calloc");
}
CUnit_Test(os_heap, os_realloc)
CU_Test(os_heap, os_realloc)
{
char *ptr = NULL;
size_t unchanged, s, prevs = 0;
@ -105,7 +105,7 @@ CUnit_Test(os_heap, os_realloc)
static const size_t allocsizes_s[] = {0, 1, 2, 3, 4, 5, 10, 20, 257, 1024, 8192};
static const size_t nof_allocsizes_s = sizeof allocsizes_s / sizeof *allocsizes_s;
CUnit_Test(os_heap, os_malloc_s)
CU_Test(os_heap, os_malloc_s)
{
for(size_t i = 0; i < nof_allocsizes_s; i++) {
for(size_t j = 0; j < nof_allocsizes_s; j++) {
@ -124,7 +124,7 @@ CUnit_Test(os_heap, os_malloc_s)
CU_PASS("os_malloc_s");
}
CUnit_Test(os_heap, os_malloc_0_s)
CU_Test(os_heap, os_malloc_0_s)
{
for(size_t i = 0; i < nof_allocsizes_s; i++) {
for(size_t j = 0; j < nof_allocsizes_s; j++) {
@ -145,7 +145,7 @@ CUnit_Test(os_heap, os_malloc_0_s)
CU_PASS("os_malloc_0_s");
}
CUnit_Test(os_heap, os_calloc_s)
CU_Test(os_heap, os_calloc_s)
{
for(size_t i = 0; i < nof_allocsizes_s; i++) {
for(size_t j = 0; j < nof_allocsizes_s; j++) {
@ -166,7 +166,7 @@ CUnit_Test(os_heap, os_calloc_s)
CU_PASS("os_calloc_s");
}
CUnit_Test(os_heap, os_realloc_s)
CU_Test(os_heap, os_realloc_s)
{
char *newptr, *ptr = NULL;
size_t unchanged, s, prevs = 0;

View file

@ -9,7 +9,7 @@
*
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
*/
#include "CUnit/Runner.h"
#include "CUnit/Test.h"
#include "os/os.h"
/* FIXME: It's not possible to predict what network interfaces are available
@ -24,7 +24,7 @@
static int ipv6_enabled = 1;
#endif
CUnit_Suite_Initialize(os_getifaddrs)
CU_Init(os_getifaddrs)
{
os_osInit();
@ -51,7 +51,7 @@ CUnit_Suite_Initialize(os_getifaddrs)
return 0;
}
CUnit_Suite_Cleanup(os_getifaddrs)
CU_Clean(os_getifaddrs)
{
os_osExit();
return 0;
@ -60,7 +60,7 @@ CUnit_Suite_Cleanup(os_getifaddrs)
/* Assume every test machine has at least one IPv4 enabled interface. This
simple test verifies an interface can at least be found and that the
IFF_LOOPBACK flags are properly set. */
CUnit_Test(os_getifaddrs, ipv4)
CU_Test(os_getifaddrs, ipv4)
{
int err;
int seen = 0;
@ -87,7 +87,7 @@ CUnit_Test(os_getifaddrs, ipv4)
os_freeifaddrs(ifa_root);
}
CUnit_Test(os_getifaddrs, null_filter)
CU_Test(os_getifaddrs, null_filter)
{
int err;
int cnt = 0;
@ -105,7 +105,7 @@ CUnit_Test(os_getifaddrs, null_filter)
os_freeifaddrs(ifa_root);
}
CUnit_Test(os_getifaddrs, empty_filter)
CU_Test(os_getifaddrs, empty_filter)
{
int err;
os_ifaddrs_t *ifa_root;
@ -119,7 +119,7 @@ CUnit_Test(os_getifaddrs, empty_filter)
}
#ifdef OS_SOCKET_HAS_IPV6
CUnit_Test(os_getifaddrs, ipv6)
CU_Test(os_getifaddrs, ipv6)
{
if (ipv6_enabled == 1) {
int err;
@ -154,7 +154,7 @@ CUnit_Test(os_getifaddrs, ipv6)
/* Assume at least one IPv4 and one IPv6 interface are available when IPv6 is
available on the platform. */
CUnit_Test(os_getifaddrs, ipv4_n_ipv6)
CU_Test(os_getifaddrs, ipv4_n_ipv6)
{
if (ipv6_enabled == 1) {
int err;

View file

@ -9,7 +9,7 @@
*
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
*/
#include "CUnit/Runner.h"
#include "CUnit/Test.h"
#include "os/os.h"
#include "assert.h"
@ -19,7 +19,7 @@ static int32_t three = 3;
static int32_t four = 4;
static int32_t five = 5;
CUnit_Test(os_iter, create)
CU_Test(os_iter, create)
{
os_iter *iter;
@ -31,7 +31,7 @@ CUnit_Test(os_iter, create)
os_iterFree(iter, NULL);
}
CUnit_Test(os_iter, prepend)
CU_Test(os_iter, prepend)
{
os_iter *iter;
int32_t idx;
@ -51,7 +51,7 @@ CUnit_Test(os_iter, prepend)
os_iterFree(iter, NULL);
}
CUnit_Test(os_iter, append)
CU_Test(os_iter, append)
{
os_iter *iter;
int32_t idx;
@ -71,7 +71,7 @@ CUnit_Test(os_iter, append)
os_iterFree(iter, NULL);
}
CUnit_Test(os_iter, insert)
CU_Test(os_iter, insert)
{
os_iter *iter;
int32_t idx;
@ -104,7 +104,7 @@ iter_free_callback(
(*(int32_t *)ptr)++;
}
CUnit_Test(os_iter, free)
CU_Test(os_iter, free)
{
os_iter *iter;
int32_t cnt = 0;
@ -126,7 +126,7 @@ iter_walk_callback(
(*(int32_t *)arg)++;
}
CUnit_Test(os_iter, walk)
CU_Test(os_iter, walk)
{
os_iter *iter;
int32_t cnt = 0;
@ -166,7 +166,7 @@ iter_new(
return iter;
}
CUnit_Test(os_iter, object_indices)
CU_Test(os_iter, object_indices)
{
os_iter *iter;
int32_t *num;
@ -198,7 +198,7 @@ CUnit_Test(os_iter, object_indices)
os_iterFree(iter, NULL);
}
CUnit_Test(os_iter, take_indices)
CU_Test(os_iter, take_indices)
{
os_iter *iter;
int32_t *num, cnt = 0;

View file

@ -9,7 +9,7 @@
*
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
*/
#include "CUnit/Runner.h"
#include "CUnit/Test.h"
#include "os/os.h"
#ifdef __VXWORKS__
@ -157,7 +157,7 @@ uint32_t concurrent_trylock_thread (_In_opt_ void *arg)
return 0;
}
CUnit_Suite_Initialize(os_mutex)
CU_Init(os_mutex)
{
printf ( "Run os_mutex_Initialize\n" );
@ -166,7 +166,7 @@ CUnit_Suite_Initialize(os_mutex)
return 0;
}
CUnit_Suite_Cleanup(os_mutex)
CU_Clean(os_mutex)
{
printf("Run os_mutex_Cleanup\n");
@ -176,7 +176,7 @@ CUnit_Suite_Cleanup(os_mutex)
}
/* This test only checks a single-threaded use-case; just API availability.*/
CUnit_Test(os_mutex, basic)
CU_Test(os_mutex, basic)
{
os_mutex m;
os_result r;
@ -227,7 +227,7 @@ os_mutex_init_thr(
return r != os_resultSuccess; /* Return true on faulure */
}
CUnit_Test(os_mutex, init_stress)
CU_Test(os_mutex, init_stress)
{
struct os_mutex_stress threads[NUM_THREADS];
os_threadAttr tattr;
@ -259,7 +259,7 @@ CUnit_Test(os_mutex, init_stress)
printf("Ending os_mutex_init_stress\n");
}
CUnit_Test(os_mutex, lock, false)
CU_Test(os_mutex, lock, false)
{
/* Test critical section access with locking and PRIVATE scope */
printf ("Starting tc_os_mutex_lock_001\n");
@ -330,7 +330,7 @@ CUnit_Test(os_mutex, lock, false)
printf ("Ending os_mutex_lock\n");
}
CUnit_Test(os_mutex, trylock, false)
CU_Test(os_mutex, trylock, false)
{
os_result result;
@ -355,7 +355,7 @@ CUnit_Test(os_mutex, trylock, false)
printf ("Ending os_mutex_trylock\n");
}
CUnit_Test(os_mutex, destroy, false)
CU_Test(os_mutex, destroy, false)
{
/* Deinitialize mutex with PRIVATE scope and Success result */
printf ("Starting os_mutex_destroy_001\n");

View file

@ -9,11 +9,11 @@
*
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
*/
#include "CUnit/Runner.h"
#include "CUnit/Test.h"
#include "os/os.h"
/* Suite os_once*/
CUnit_Suite_Initialize(os_once)
CU_Init(os_once)
{
printf("Run os_once_Initialize\n");
@ -22,7 +22,7 @@ CUnit_Suite_Initialize(os_once)
return 0;
}
CUnit_Suite_Cleanup(os_once)
CU_Clean(os_once)
{
printf("Run os_once_Cleanup\n");
@ -40,7 +40,7 @@ static void once_func(void)
}
/* This test only checks a single-threaded use-case; mostly API availability and mere basics.*/
CUnit_Test(os_once, basic)
CU_Test(os_once, basic)
{
static os_once_t init = OS_ONCE_T_STATIC_INIT;
@ -127,7 +127,7 @@ os_once_parallel_thr(
return 0;
}
CUnit_Test(os_once, parallel)
CU_Test(os_once, parallel)
{
os_threadId threads[OS_ONCE_NUM_THREADS];
struct os_once_parallel state = {

View file

@ -9,13 +9,13 @@
*
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
*/
#include "CUnit/Runner.h"
#include "CUnit/Test.h"
#include "os/os.h"
#include "os/os_project.h"
#include <stdio.h>
CUnit_Suite_Initialize(os_report)
CU_Init(os_report)
{
os_putenv(OS_PROJECT_NAME_NOSPACE_CAPS"_ERRORFILE=vdds_test_error");
os_putenv(OS_PROJECT_NAME_NOSPACE_CAPS"_INFOFILE=vdds_test_info");
@ -42,7 +42,7 @@ void check_existence(os_result error_log_existence, os_result info_log_existence
CU_ASSERT(os_access(info_file_name, OS_ROK) == info_log_existence);
}
CUnit_Suite_Cleanup(os_report)
CU_Clean(os_report)
{
remove_logs();
@ -50,7 +50,7 @@ CUnit_Suite_Cleanup(os_report)
}
CUnit_Test(os_report, re_init)
CU_Test(os_report, re_init)
{
os_reportInit(true);
@ -72,7 +72,7 @@ CUnit_Test(os_report, re_init)
}
CUnit_Test(os_report, stack_critical)
CU_Test(os_report, stack_critical)
{
os_reportInit(true);
@ -93,7 +93,7 @@ CUnit_Test(os_report, stack_critical)
}
CUnit_Test(os_report, stack_non_critical)
CU_Test(os_report, stack_non_critical)
{
os_reportInit(true);
@ -114,7 +114,7 @@ CUnit_Test(os_report, stack_non_critical)
}
CUnit_Test(os_report, error_file_creation_critical)
CU_Test(os_report, error_file_creation_critical)
{
os_reportInit(true);
@ -128,7 +128,7 @@ CUnit_Test(os_report, error_file_creation_critical)
}
CUnit_Test(os_report, error_file_creation_fatal)
CU_Test(os_report, error_file_creation_fatal)
{
os_reportInit(true);
@ -142,7 +142,7 @@ CUnit_Test(os_report, error_file_creation_fatal)
}
CUnit_Test(os_report, info_file_creation_warning)
CU_Test(os_report, info_file_creation_warning)
{
os_reportInit(true);
@ -156,7 +156,7 @@ CUnit_Test(os_report, info_file_creation_warning)
}
CUnit_Test(os_report, info_file_creation_info)
CU_Test(os_report, info_file_creation_info)
{
os_reportInit(true);
@ -170,7 +170,7 @@ CUnit_Test(os_report, info_file_creation_info)
}
CUnit_Test(os_report, verbosity_low)
CU_Test(os_report, verbosity_low)
{
os_reportInit(true);
check_existence(os_resultFail, os_resultFail);
@ -187,7 +187,7 @@ CUnit_Test(os_report, verbosity_low)
}
CUnit_Test(os_report, verbosity_high)
CU_Test(os_report, verbosity_high)
{
os_reportInit(true);
check_existence(os_resultFail, os_resultFail);
@ -205,7 +205,7 @@ CUnit_Test(os_report, verbosity_high)
CUnit_Test(os_report, verbosity_equal)
CU_Test(os_report, verbosity_equal)
{
os_reportInit(true);
check_existence(os_resultFail, os_resultFail);
@ -222,7 +222,7 @@ CUnit_Test(os_report, verbosity_equal)
}
CUnit_Test(os_report, stack_verbosity_low)
CU_Test(os_report, stack_verbosity_low)
{
os_reportInit(true);
check_existence(os_resultFail, os_resultFail);
@ -241,7 +241,7 @@ CUnit_Test(os_report, stack_verbosity_low)
}
CUnit_Test(os_report, stack_verbosity_high)
CU_Test(os_report, stack_verbosity_high)
{
os_reportInit(true);
check_existence(os_resultFail, os_resultFail);
@ -261,7 +261,7 @@ CUnit_Test(os_report, stack_verbosity_high)
CUnit_Test(os_report, stack_verbosity_equal)
CU_Test(os_report, stack_verbosity_equal)
{
os_reportInit(true);
check_existence(os_resultFail, os_resultFail);
@ -280,7 +280,7 @@ CUnit_Test(os_report, stack_verbosity_equal)
}
CUnit_Test(os_report, no_log_append)
CU_Test(os_report, no_log_append)
{
os_reportInit(true);
check_existence(os_resultFail, os_resultFail);
@ -305,7 +305,7 @@ CUnit_Test(os_report, no_log_append)
}
CUnit_Test(os_report, log_dir)
CU_Test(os_report, log_dir)
{
os_putenv(OS_PROJECT_NAME_NOSPACE_CAPS"_LOGPATH=.");
@ -324,7 +324,7 @@ CUnit_Test(os_report, log_dir)
}
CUnit_Test(os_report, verbosity_env_value_info)
CU_Test(os_report, verbosity_env_value_info)
{
os_putenv(OS_PROJECT_NAME_NOSPACE_CAPS"_VERBOSITY=0");
os_reportInit(true);
@ -344,7 +344,7 @@ CUnit_Test(os_report, verbosity_env_value_info)
}
CUnit_Test(os_report, verbosity_env_value_error)
CU_Test(os_report, verbosity_env_value_error)
{
os_putenv(OS_PROJECT_NAME_NOSPACE_CAPS"_VERBOSITY=3");
os_reportInit(true);
@ -364,7 +364,7 @@ CUnit_Test(os_report, verbosity_env_value_error)
}
CUnit_Test(os_report, verbosity_env_value_error_as_string)
CU_Test(os_report, verbosity_env_value_error_as_string)
{
os_putenv(OS_PROJECT_NAME_NOSPACE_CAPS"_VERBOSITY=ERROR");
os_reportInit(true);
@ -384,7 +384,7 @@ CUnit_Test(os_report, verbosity_env_value_error_as_string)
}
CUnit_Test(os_report, verbosity_wrong_env_value)
CU_Test(os_report, verbosity_wrong_env_value)
{
os_putenv(OS_PROJECT_NAME_NOSPACE_CAPS"_VERBOSITY=WRONG");
os_reportInit(true);

View file

@ -9,7 +9,7 @@
*
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
*/
#include "CUnit/Runner.h"
#include "CUnit/Test.h"
#include "os/os.h"
#ifdef __VXWORKS__
@ -256,7 +256,7 @@ uint32_t concurrent_tryread_thread (_In_ void *arg)
return 0;
}
CUnit_Suite_Initialize(os_rwlock)
CU_Init(os_rwlock)
{
int result = 0;
os_osInit();
@ -270,7 +270,7 @@ CUnit_Suite_Initialize(os_rwlock)
return result;
}
CUnit_Suite_Cleanup(os_rwlock)
CU_Clean(os_rwlock)
{
int result = 0;
@ -279,7 +279,7 @@ CUnit_Suite_Cleanup(os_rwlock)
return result;
}
CUnit_Test(os_rwlock, init)
CU_Test(os_rwlock, init)
{
/* Initilalize reader/writer lock with PRIVATE scope and Success result */
printf ("Starting os_rwlock_init_001\n");
@ -292,7 +292,7 @@ CUnit_Test(os_rwlock, init)
printf ("Ending os_rwlock_init\n");
}
CUnit_Test(os_rwlock, read, false)
CU_Test(os_rwlock, read, false)
{
os_time rdelay = { 3, 0 };
struct Par par[RWLOCK_THREADS];
@ -438,7 +438,7 @@ CUnit_Test(os_rwlock, read, false)
printf ("Ending os_rwlock_read\n");
}
CUnit_Test(os_rwlock, write, false)
CU_Test(os_rwlock, write, false)
{
/* Test critical section WRITE access with locking and PRIVATE scope */
printf ("Starting os_rwlock_write_001\n");
@ -458,7 +458,7 @@ CUnit_Test(os_rwlock, write, false)
printf ("Ending tc_rwlockWrite\n");
}
CUnit_Test(rwlock, tryread, false)
CU_Test(rwlock, tryread, false)
{
os_result result;
/* Test critical section READ access with trylocking and PRIVATE scope */
@ -488,7 +488,7 @@ CUnit_Test(rwlock, tryread, false)
printf ("Ending os_rwlock_tryread\n");
}
CUnit_Test(os_rwlock, trywrite, false)
CU_Test(os_rwlock, trywrite, false)
{
os_result result;
/* Test critical section WRITE access with trylocking and PRIVATE scope */
@ -518,7 +518,7 @@ CUnit_Test(os_rwlock, trywrite, false)
printf ("Ending os_rwlock_trywrite\n");
}
CUnit_Test(os_rwlock, unlock, false)
CU_Test(os_rwlock, unlock, false)
{
os_result result;
/* Unlock rwlock with PRIVATE scope and Success result and claimed with read */
@ -550,7 +550,7 @@ CUnit_Test(os_rwlock, unlock, false)
printf ("Ending tc_rwlockUnlock\n");
}
CUnit_Test(os_rwlock, destroy, false)
CU_Test(os_rwlock, destroy, false)
{
/* Deinitialize rwlock with PRIVATE scope and Success result */
printf ("Starting os_rwlock_destroy_001\n");
@ -563,7 +563,7 @@ CUnit_Test(os_rwlock, destroy, false)
printf ("Ending tc_rwlockDestroy\n");
}
CUnit_Test(os_rwlock, destroy_shared)
CU_Test(os_rwlock, destroy_shared)
{
os_rwlock mylock;

View file

@ -9,7 +9,7 @@
*
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
*/
#include "CUnit/Runner.h"
#include "CUnit/Test.h"
#include "os/os.h"
#ifndef WINCE
@ -283,14 +283,14 @@ vsnprintfTest(
return result;
}
CUnit_Suite_Initialize(os_stdlib)
CU_Init(os_stdlib)
{
int result = 0;
os_osInit();
return result;
}
CUnit_Suite_Cleanup(os_stdlib)
CU_Clean(os_stdlib)
{
/* Remove files used to test permissions */
remove ("exec_only");
@ -303,119 +303,7 @@ CUnit_Suite_Cleanup(os_stdlib)
return 0;
}
CUnit_Test(os_stdlib, strcasecmp)
{
int res;
char *s1, *s2;
s1 = "a";
s2 = "a";
printf ("Starting os_stdlib_strcasecmp_001\n");
res = os_strcasecmp (s1,s2);
CU_ASSERT (res == 0);
printf ("Starting os_stdlib_strcasecmp_002\n");
s1 = "aa";
s2 = "a";
res = os_strcasecmp (s1,s2);
CU_ASSERT (res > 0);
printf ("Starting os_stdlib_strcasecmp_003\n");
s1 = "a";
s2 = "aa";
res = os_strcasecmp (s1,s2);
CU_ASSERT (res < 0);
printf ("Starting os_stdlib_strcasecmp_004\n");
s1 = "a";
s2 = "A";
res = os_strcasecmp (s1,s2);
CU_ASSERT (res == 0);
printf ("Starting os_stdlib_strcasecmp_005\n");
s1 = "A";
s2 = "a";
res = os_strcasecmp (s1,s2);
CU_ASSERT (res == 0);
printf ("Starting os_stdlib_strcasecmp_006\n");
s1 = "a";
s2 = "b";
res = os_strcasecmp (s1,s2);
CU_ASSERT (res < 0);
printf ("Starting os_stdlib_strcasecmp_007\n");
s1 = "b";
s2 = "a";
res = os_strcasecmp (s1,s2);
CU_ASSERT (res > 0);
printf ("Ending os_stdlib_strcasecmp\n");
}
CUnit_Test(os_stdlib, strncasecmp)
{
int res;
char *s1, *s2;
s1 = "a";
s2 = "a";
printf ("Starting os_stdlib_strncasecmp_001\n");
res = os_strncasecmp (s1,s2,2);
CU_ASSERT (res == 0);
s1 = "aa";
s2 = "a";
printf ("Starting os_stdlib_strncasecmp_002\n");
res = os_strncasecmp (s1,s2,2);
CU_ASSERT (res > 0);
s1 = "a";
s2 = "aa";
printf ("Starting os_stdlib_strncasecmp_003\n");
res = os_strncasecmp (s1,s2,2);
CU_ASSERT (res < 0);
s1 = "a";
s2 = "A";
printf ("Starting os_stdlib_strncasecmp_004\n");
res = os_strncasecmp (s1,s2,2);
CU_ASSERT (res == 0);
s1 = "A";
s2 = "a";
printf ("Starting os_stdlib_strncasecmp_005\n");
res = os_strncasecmp (s1,s2,2);
CU_ASSERT (res == 0);
s1 = "a";
s2 = "b";
printf ("Starting os_stdlib_strncasecmp_006\n");
res = os_strncasecmp (s1,s2,2);
CU_ASSERT (res < 0);
s1 = "b";
s2 = "a";
printf ("Starting os_stdlib_strncasecmp_007\n");
res = os_strncasecmp (s1,s2,2);
CU_ASSERT (res > 0);
s1 = "abcdefghijkl";
s2 = "AbCdEaGhIjKl";
printf ("Starting os_stdlib_strncasecmp_008\n");
res = os_strncasecmp (s1,s2,5);
CU_ASSERT (res == 0);
s1 = "abcdefghijkl";
s2 = "AbCdEaGhIjKl";
printf ("Starting os_stdlib_strncasecmp_009\n");
res = os_strncasecmp (s1,s2,6);
CU_ASSERT (res > 0);
printf ("Ending os_stdlib_strncasecmp\n");
}
CUnit_Test(os_stdlib, gethostname)
CU_Test(os_stdlib, gethostname)
{
int res;
os_result os_res;
@ -437,7 +325,7 @@ CUnit_Test(os_stdlib, gethostname)
printf ("Ending os_stdlib_gethostname\n");
}
CUnit_Test(os_stdlib, putenv)
CU_Test(os_stdlib, putenv)
{
os_result os_res;
@ -448,7 +336,7 @@ CUnit_Test(os_stdlib, putenv)
printf ("Ending os_stdlib_putenv\n");
}
CUnit_Test(os_stdlib, getenv)
CU_Test(os_stdlib, getenv)
{
const char *env;
os_result res;
@ -468,7 +356,7 @@ CUnit_Test(os_stdlib, getenv)
printf ("Ending os_stdlib_getenv\n");
}
CUnit_Test(os_stdlib, fileSep)
CU_Test(os_stdlib, fileSep)
{
#if defined WIN32
const char *wanted= "\\";
@ -480,7 +368,7 @@ CUnit_Test(os_stdlib, fileSep)
printf ("Ending os_stdlib_fileSep\n");
}
CUnit_Test(os_stdlib, access)
CU_Test(os_stdlib, access)
{
os_result os_res;
os_result wanted;
@ -716,7 +604,7 @@ CUnit_Test(os_stdlib, access)
printf ("Ending stdlib_os_access\n");
}
CUnit_Test(os_stdlib, vsnprintf)
CU_Test(os_stdlib, vsnprintf)
{
printf ("Starting os_stdlib_vsnprintf_001\n");
CU_ASSERT (vsnprintfTest("%s","test") == 4);
@ -726,7 +614,7 @@ CUnit_Test(os_stdlib, vsnprintf)
printf ("Ending os_stdlib_vsnprintf\n");
}
CUnit_Test(os_stdlib, strtok_r)
CU_Test(os_stdlib, strtok_r)
{
char * res;
char *strtok_r_ts1;
@ -781,7 +669,7 @@ CUnit_Test(os_stdlib, strtok_r)
printf ("Ending os_stdlib_strtok_r\n");
}
CUnit_Test(os_stdlib, index)
CU_Test(os_stdlib, index)
{
char * res;
char *index_ts1;
@ -806,7 +694,7 @@ CUnit_Test(os_stdlib, index)
printf ("Ending os_stdlib_index\n");
}
CUnit_Test(os_stdlib, flockfile)
CU_Test(os_stdlib, flockfile)
{
bool result = false;
@ -827,7 +715,7 @@ CUnit_Test(os_stdlib, flockfile)
os_osExit();
}
CUnit_Test(os_stdlib, getopt)
CU_Test(os_stdlib, getopt)
{
int c = 0;
int argc = 3;

56
src/os/tests/strcasecmp.c Normal file
View file

@ -0,0 +1,56 @@
#include "os/os.h"
#include "CUnit/Theory.h"
typedef enum { eq, lt, gt } eq_t;
CU_TheoryDataPoints(os_strcasecmp, basic) = {
CU_DataPoints(const char *, "a", "aa", "a", "a", "A", "a", "b", "a", "B", "A", "", "a"),
CU_DataPoints(const char *, "a", "a", "aa", "A", "a", "b", "a", "b", "A", "B", "a", ""),
CU_DataPoints(eq_t, eq, gt, lt, eq, eq, lt, gt, lt, gt, lt, lt, gt)
};
CU_Theory((const char *s1, const char *s2, eq_t e), os_strcasecmp, basic)
{
int r = os_strcasecmp(s1, s2);
CU_ASSERT((e == eq && r == 0) || (e == lt && r < 0) || (e == gt && r > 0));
}
CU_TheoryDataPoints(os_strncasecmp, basic) = {
CU_DataPoints(const char *, "a", "aa", "a", "A", "a", "b", "a", "B", "A", "", "a"),
CU_DataPoints(const char *, "a", "a", "aa", "a", "A", "a", "b", "A", "B", "a", ""),
CU_DataPoints(size_t, 1, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1),
CU_DataPoints(eq_t, eq, gt, lt, eq, eq, gt, lt, gt, lt, lt, gt)
};
CU_Theory((const char *s1, const char *s2, size_t n, eq_t e), os_strncasecmp, basic)
{
int r = os_strncasecmp(s1, s2, n);
CU_ASSERT((e == eq && r == 0) || (e == lt && r < 0) || (e == gt && r > 0));
}
CU_TheoryDataPoints(os_strncasecmp, empty) = {
CU_DataPoints(const char *, "a", "", "a", "", "a", ""),
CU_DataPoints(const char *, "", "a", "", "a", "", "a"),
CU_DataPoints(size_t, 1, 1, 0, 0, 2, 2),
CU_DataPoints(eq_t, gt, lt, eq, eq, gt, lt)
};
CU_Theory((const char *s1, const char *s2, size_t n, eq_t e), os_strncasecmp, empty)
{
int r = os_strncasecmp(s1, s2, n);
CU_ASSERT((e == eq && r == 0) || (e == lt && r < 0) || (e == gt && r > 0));
}
CU_TheoryDataPoints(os_strncasecmp, length) = {
CU_DataPoints(const char *, "aBcD", "AbCX", "aBcD", "AbCX", "aBcD"),
CU_DataPoints(const char *, "AbCX", "aBcD", "AbCX", "aBcD", "AbCd"),
CU_DataPoints(size_t, 3, 3, 4, 4, 5, 5),
CU_DataPoints(eq_t, eq, eq, lt, gt, eq, eq)
};
CU_Theory((const char *s1, const char *s2, size_t n, eq_t e), os_strncasecmp, length)
{
int r = os_strncasecmp(s1, s2, n);
CU_ASSERT((e == eq && r == 0) || (e == lt && r < 0) || (e == gt && r > 0));
}

View file

@ -9,7 +9,7 @@
*
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
*/
#include "CUnit/Runner.h"
#include "CUnit/Test.h"
#include "os/os.h"
long long ll;
@ -31,7 +31,7 @@ long long llmin = OS_MIN_INTEGER(long long);
long long llmax = OS_MAX_INTEGER(long long);
unsigned long long ullmax = OS_MAX_INTEGER(unsigned long long);
CUnit_Suite_Initialize(os_str_convert)
CU_Init(os_str_convert)
{
int result = 0;
os_osInit();
@ -48,7 +48,7 @@ CUnit_Suite_Initialize(os_str_convert)
return result;
}
CUnit_Suite_Cleanup(os_str_convert)
CU_Clean(os_str_convert)
{
int result = 0;
@ -57,7 +57,7 @@ CUnit_Suite_Cleanup(os_str_convert)
return result;
}
CUnit_Test(os_str_convert, strtoll)
CU_Test(os_str_convert, strtoll)
{
printf ("Starting os_strtoll_001a\n");
str = "gibberish";
@ -223,7 +223,7 @@ CUnit_Test(os_str_convert, strtoll)
printf ("Ending os_strtoll\n");
}
CUnit_Test(os_str_convert, strtoull)
CU_Test(os_str_convert, strtoull)
{
printf ("Starting os_strtoull_001a\n");
str = "0xffffffffffffffff";
@ -243,7 +243,7 @@ CUnit_Test(os_str_convert, strtoull)
printf ("Ending os_strtoull\n");
}
CUnit_Test(os_str_convert, atoll)
CU_Test(os_str_convert, atoll)
{
printf ("Starting os_atoll_001\n");
str = "10";
@ -253,7 +253,7 @@ CUnit_Test(os_str_convert, atoll)
printf ("Ending os_atoll\n");
}
CUnit_Test(os_str_convert, atoull)
CU_Test(os_str_convert, atoull)
{
printf ("Starting os_atoull_001\n");
str = "10";
@ -263,7 +263,7 @@ CUnit_Test(os_str_convert, atoull)
printf ("Ending tc_os_atoull\n");
}
CUnit_Test(os_str_convert, lltostr)
CU_Test(os_str_convert, lltostr)
{
printf ("Starting os_lltostr_001\n");
ll = llmax;
@ -304,7 +304,7 @@ CUnit_Test(os_str_convert, lltostr)
printf ("Ending os_lltostr\n");
}
CUnit_Test(os_str_convert, ulltostr)
CU_Test(os_str_convert, ulltostr)
{
printf ("Starting os_ulltostr_001\n");
ull = ullmax;

View file

@ -9,7 +9,7 @@
*
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
*/
#include "CUnit/Runner.h"
#include "CUnit/Test.h"
#include "os/os.h"
#include "assert.h"
@ -107,7 +107,7 @@ uint32_t threadMemory_thread (_In_opt_ void *args)
return 0;
}
CUnit_Suite_Initialize(os_thread)
CU_Init(os_thread)
{
int result = 0;
os_osInit();
@ -116,7 +116,7 @@ CUnit_Suite_Initialize(os_thread)
return result;
}
CUnit_Suite_Cleanup(os_thread)
CU_Clean(os_thread)
{
int result = 0;
@ -125,7 +125,7 @@ CUnit_Suite_Cleanup(os_thread)
return result;
}
CUnit_Test(os_thread, create)
CU_Test(os_thread, create)
{
int result;
os_result osResult;
@ -452,7 +452,7 @@ CUnit_Test(os_thread, create)
printf ("Ending os_thread_create\n");
}
CUnit_Test(os_thread, idself)
CU_Test(os_thread, idself)
{
os_threadId thread_os_threadId;
os_threadAttr thread_os_threadAttr;
@ -486,7 +486,7 @@ CUnit_Test(os_thread, idself)
printf ("Ending tc_threadIdSelf\n");
}
CUnit_Test(os_thread, join)
CU_Test(os_thread, join)
{
os_threadId thread_os_threadId;
os_threadAttr thread_os_threadAttr;
@ -612,7 +612,7 @@ CUnit_Test(os_thread, join)
printf ("Ending tc_threadWaitExit\n");
}
CUnit_Test(os_thread, figure_identity)
CU_Test(os_thread, figure_identity)
{
#if !defined(_WIN32)
os_threadId thread_os_threadId;
@ -718,7 +718,7 @@ CUnit_Test(os_thread, figure_identity)
printf ("Ending os_thread_figure_identity\n");
}
CUnit_Test(os_thread, attr_init)
CU_Test(os_thread, attr_init)
{
os_threadAttr thread_os_threadAttr;
/* Check default attributes: schedClass */
@ -744,7 +744,7 @@ CUnit_Test(os_thread, attr_init)
printf ("Ending os_thread_attr_init\n");
}
CUnit_Test(os_thread, memmalloc)
CU_Test(os_thread, memmalloc)
{
/* Check os_threadMemMalloc with success result for main thread */
printf ("Starting os_thread_memmalloc_001\n");
@ -772,7 +772,7 @@ CUnit_Test(os_thread, memmalloc)
printf ("Ending tc_thread_memmalloc\n");
}
CUnit_Test(os_thread, memget)
CU_Test(os_thread, memget)
{
/* Check os_threadMemGet for main thread and non allocated index */
printf ("Starting os_thread_memget_001\n");
@ -793,7 +793,7 @@ CUnit_Test(os_thread, memget)
printf ("Ending tc_thread_memget\n");
}
CUnit_Test(os_thread, memfree)
CU_Test(os_thread, memfree)
{
/* Check os_threadMemFree for main thread and non allocated index */
printf ("Starting os_thread_memfree_001\n");
@ -814,7 +814,7 @@ CUnit_Test(os_thread, memfree)
printf ("Ending os_thread_memfree\n");
}
CUnit_Test(os_thread, module)
CU_Test(os_thread, module)
{
os_threadId tid;
os_threadAttr tattr;

View file

@ -13,15 +13,15 @@
#include <stdint.h>
#include "os/os.h"
#include "CUnit/Runner.h"
#include "CUnit/Test.h"
CUnit_Suite_Initialize(os_thread_cleanup)
CU_Init(os_thread_cleanup)
{
os_osInit();
return 0;
}
CUnit_Suite_Cleanup(os_thread_cleanup)
CU_Clean(os_thread_cleanup)
{
os_osExit();
return 0;
@ -137,7 +137,7 @@ setup(
}
/* verify the cleanup routine is called */
CUnit_Test(os_thread_cleanup, push_one)
CU_Test(os_thread_cleanup, push_one)
{
int flags = THREAD_RESET_1;
struct thread_argument *targ = make_thread_argument(flags, 0, 1, 2);
@ -152,7 +152,7 @@ CUnit_Test(os_thread_cleanup, push_one)
}
/* verify all cleanup routines are called if multiple are registered */
CUnit_Test(os_thread_cleanup, push_two)
CU_Test(os_thread_cleanup, push_two)
{
int flags = THREAD_RESET_1 | THREAD_RESET_2;
struct thread_argument *targ = make_thread_argument(flags, 0, 1, 2);
@ -167,7 +167,7 @@ CUnit_Test(os_thread_cleanup, push_two)
}
/* verify the first cleanup routine is still called if second got popped */
CUnit_Test(os_thread_cleanup, push_two_pop_one_no_exec)
CU_Test(os_thread_cleanup, push_two_pop_one_no_exec)
{
int flags = THREAD_RESET_1 | THREAD_RESET_2;
struct thread_argument *targ = make_thread_argument(flags, 1, 1, 2);
@ -181,7 +181,7 @@ CUnit_Test(os_thread_cleanup, push_two_pop_one_no_exec)
free(targ);
}
CUnit_Test(os_thread_cleanup, push_two_pop_one_exec)
CU_Test(os_thread_cleanup, push_two_pop_one_exec)
{
int flags = THREAD_RESET_1 | THREAD_RESET_2 | THREAD_RUN_1;
struct thread_argument *targ = make_thread_argument(flags, 1, 1, 2);
@ -196,7 +196,7 @@ CUnit_Test(os_thread_cleanup, push_two_pop_one_exec)
}
/* verify no cleanup routines are called if all got popped */
CUnit_Test(os_thread_cleanup, push_two_pop_two_no_exec)
CU_Test(os_thread_cleanup, push_two_pop_two_no_exec)
{
int flags = THREAD_RESET_1 | THREAD_RESET_2;
struct thread_argument *targ = make_thread_argument(flags, 2, 1, 2);
@ -210,7 +210,7 @@ CUnit_Test(os_thread_cleanup, push_two_pop_two_no_exec)
free(targ);
}
CUnit_Test(os_thread_cleanup, push_two_pop_two_exec_one)
CU_Test(os_thread_cleanup, push_two_pop_two_exec_one)
{
int flags = THREAD_RESET_1 | THREAD_RESET_2 | THREAD_RUN_1;
struct thread_argument *targ = make_thread_argument(flags, 2, 1, 2);
@ -224,7 +224,7 @@ CUnit_Test(os_thread_cleanup, push_two_pop_two_exec_one)
free(targ);
}
CUnit_Test(os_thread_cleanup, push_two_pop_two_exec_both)
CU_Test(os_thread_cleanup, push_two_pop_two_exec_both)
{
int flags = THREAD_RESET_1 | THREAD_RESET_2 | THREAD_RUN_1 | THREAD_RUN_2;
struct thread_argument *targ = make_thread_argument(flags, 2, 1, 2);
@ -238,7 +238,7 @@ CUnit_Test(os_thread_cleanup, push_two_pop_two_exec_both)
free(targ);
}
CUnit_Test(os_thread_cleanup, no_interference)
CU_Test(os_thread_cleanup, no_interference)
{
int flags = THREAD_RESET_1 | THREAD_RESET_2;
struct thread_argument *targ1 = make_thread_argument(flags, 0, 1, 2);