stricter warning checks and the corresponding fixes
Signed-off-by: Erik Boasson <eb@ilities.com>
This commit is contained in:
parent
87e4780446
commit
b7487b18a6
101 changed files with 1756 additions and 1615 deletions
|
@ -36,8 +36,8 @@ static const size_t nof_allocsizes = sizeof allocsizes / sizeof *allocsizes;
|
|||
|
||||
CUnit_Test(os_heap, os_malloc)
|
||||
{
|
||||
for(int i = 0; i < nof_allocsizes; i++) {
|
||||
for(int j = 0; j < nof_allocsizes; j++) {
|
||||
for(size_t i = 0; i < nof_allocsizes; i++) {
|
||||
for(size_t j = 0; j < nof_allocsizes; j++) {
|
||||
size_t s = allocsizes[i] * allocsizes[j]; /* Allocates up to 1MB */
|
||||
void *ptr = os_malloc(s);
|
||||
CU_ASSERT_PTR_NOT_EQUAL(ptr, NULL); /* os_malloc is supposed to abort on failure */
|
||||
|
@ -50,8 +50,8 @@ CUnit_Test(os_heap, os_malloc)
|
|||
|
||||
CUnit_Test(os_heap, os_malloc_0)
|
||||
{
|
||||
for(int i = 0; i < nof_allocsizes; i++) {
|
||||
for(int j = 0; j < nof_allocsizes; j++) {
|
||||
for(size_t i = 0; i < nof_allocsizes; i++) {
|
||||
for(size_t j = 0; j < nof_allocsizes; j++) {
|
||||
size_t s = allocsizes[i] * allocsizes[j]; /* Allocates up to 1MB */
|
||||
char *ptr = os_malloc_0(s);
|
||||
CU_ASSERT_PTR_NOT_EQUAL(ptr, NULL); /* os_malloc_0 is supposed to abort on failure */
|
||||
|
@ -66,11 +66,11 @@ CUnit_Test(os_heap, os_malloc_0)
|
|||
|
||||
CUnit_Test(os_heap, os_calloc)
|
||||
{
|
||||
for(int i = 0; i < nof_allocsizes; i++) {
|
||||
for(int j = 0; j < nof_allocsizes; j++) {
|
||||
for(size_t i = 0; i < nof_allocsizes; i++) {
|
||||
for(size_t j = 0; j < nof_allocsizes; j++) {
|
||||
char *ptr = os_calloc(allocsizes[i], allocsizes[j]);
|
||||
CU_ASSERT_PTR_NOT_EQUAL(ptr, NULL); /* os_calloc is supposed to abort on failure */
|
||||
if(allocsizes[i] * allocsizes[j]) {
|
||||
if(allocsizes[i] * allocsizes[j] > 0) {
|
||||
CU_ASSERT (ptr[0] == 0 && !memcmp(ptr, ptr + 1, (allocsizes[i] * allocsizes[j]) - 1)); /* os_calloc should memset properly */
|
||||
}
|
||||
os_free(ptr);
|
||||
|
@ -84,8 +84,8 @@ CUnit_Test(os_heap, os_realloc)
|
|||
char *ptr = NULL;
|
||||
size_t unchanged, s, prevs = 0;
|
||||
|
||||
for(int i = 0; i < nof_allocsizes; i++) {
|
||||
for(int j = 0; j < nof_allocsizes; j++) {
|
||||
for(size_t i = 0; i < nof_allocsizes; i++) {
|
||||
for(size_t j = 0; j < nof_allocsizes; j++) {
|
||||
s = allocsizes[i] * allocsizes[j]; /* Allocates up to 1MB */
|
||||
printf("os_realloc(%p) %zu -> %zu\n", ptr, prevs, s);
|
||||
ptr = os_realloc(ptr, s);
|
||||
|
@ -107,8 +107,8 @@ static const size_t nof_allocsizes_s = sizeof allocsizes_s / sizeof *allocsizes_
|
|||
|
||||
CUnit_Test(os_heap, os_malloc_s)
|
||||
{
|
||||
for(int i = 0; i < nof_allocsizes_s; i++) {
|
||||
for(int j = 0; j < nof_allocsizes_s; j++) {
|
||||
for(size_t i = 0; i < nof_allocsizes_s; i++) {
|
||||
for(size_t j = 0; j < nof_allocsizes_s; j++) {
|
||||
size_t s = allocsizes_s[i] * allocsizes_s[j]; /* Allocates up to 8MB */
|
||||
void *ptr = os_malloc_s(s); /* If s == 0, os_malloc_s should still return a pointer */
|
||||
if(ptr) {
|
||||
|
@ -126,8 +126,8 @@ CUnit_Test(os_heap, os_malloc_s)
|
|||
|
||||
CUnit_Test(os_heap, os_malloc_0_s)
|
||||
{
|
||||
for(int i = 0; i < nof_allocsizes_s; i++) {
|
||||
for(int j = 0; j < nof_allocsizes_s; j++) {
|
||||
for(size_t i = 0; i < nof_allocsizes_s; i++) {
|
||||
for(size_t j = 0; j < nof_allocsizes_s; j++) {
|
||||
size_t s = allocsizes_s[i] * allocsizes_s[j]; /* Allocates up to 8MB */
|
||||
char *ptr = os_malloc_0_s(s); /* If s == 0, os_malloc_0_s should still return a pointer */
|
||||
if(ptr) {
|
||||
|
@ -147,8 +147,8 @@ CUnit_Test(os_heap, os_malloc_0_s)
|
|||
|
||||
CUnit_Test(os_heap, os_calloc_s)
|
||||
{
|
||||
for(int i = 0; i < nof_allocsizes_s; i++) {
|
||||
for(int j = 0; j < nof_allocsizes_s; j++) {
|
||||
for(size_t i = 0; i < nof_allocsizes_s; i++) {
|
||||
for(size_t j = 0; j < nof_allocsizes_s; j++) {
|
||||
size_t s = allocsizes_s[i] * allocsizes_s[j];
|
||||
char *ptr = os_calloc_s(allocsizes_s[i], allocsizes_s[j]); /* If either one is 0, os_calloc_s should still return a pointer */
|
||||
if(ptr) {
|
||||
|
@ -171,8 +171,8 @@ CUnit_Test(os_heap, os_realloc_s)
|
|||
char *newptr, *ptr = NULL;
|
||||
size_t unchanged, s, prevs = 0;
|
||||
|
||||
for(int i = 0; i < nof_allocsizes_s; i++) {
|
||||
for(int j = 0; j < nof_allocsizes_s; j++) {
|
||||
for(size_t i = 0; i < nof_allocsizes_s; i++) {
|
||||
for(size_t j = 0; j < nof_allocsizes_s; j++) {
|
||||
s = allocsizes_s[i] * allocsizes_s[j]; /* Allocates up to 8MB */
|
||||
newptr = os_realloc_s(ptr, s);
|
||||
printf("%p = os_realloc_s(%p) %zu -> %zu\n", newptr, ptr, prevs, s);
|
||||
|
|
|
@ -179,7 +179,7 @@ CUnit_Test(os_iter, object_indices)
|
|||
OS_WARNING_MSVC_ON(28020);
|
||||
|
||||
CU_ASSERT_PTR_NULL(num);
|
||||
num = os_iterObject(iter, os_iterLength(iter));
|
||||
num = os_iterObject(iter, (int32_t)os_iterLength(iter));
|
||||
CU_ASSERT_PTR_NULL(num);
|
||||
num = os_iterObject(iter, -6);
|
||||
CU_ASSERT_PTR_NULL(num);
|
||||
|
@ -187,7 +187,7 @@ CUnit_Test(os_iter, object_indices)
|
|||
CU_ASSERT_PTR_EQUAL(num, &one);
|
||||
num = os_iterObject(iter, -5);
|
||||
CU_ASSERT_PTR_EQUAL(num, &one);
|
||||
num = os_iterObject(iter, os_iterLength(iter) - 1);
|
||||
num = os_iterObject(iter, (int32_t)os_iterLength(iter) - 1);
|
||||
CU_ASSERT_PTR_EQUAL(num, &five);
|
||||
num = os_iterObject(iter, -1);
|
||||
CU_ASSERT_PTR_EQUAL(num, &five);
|
||||
|
@ -210,7 +210,7 @@ CUnit_Test(os_iter, take_indices)
|
|||
num = os_iterTake(iter, OS_ITER_LENGTH);
|
||||
OS_WARNING_MSVC_ON(28020);
|
||||
CU_ASSERT_PTR_NULL(num);
|
||||
num = os_iterTake(iter, os_iterLength(iter));
|
||||
num = os_iterTake(iter, (int32_t)os_iterLength(iter));
|
||||
CU_ASSERT_PTR_NULL(num);
|
||||
num = os_iterTake(iter, -6);
|
||||
CU_ASSERT_PTR_NULL(num);
|
||||
|
|
|
@ -117,7 +117,7 @@ os_once_parallel_thr(
|
|||
case OS_ONCE_STATE_GO:
|
||||
os_once(&state->init1, &once1_func);
|
||||
os_once(&state->init2, &once2_func);
|
||||
/* Fallthrough intentional */
|
||||
/* FALLS THROUGH */
|
||||
default:
|
||||
done = true;
|
||||
break;
|
||||
|
|
|
@ -31,52 +31,52 @@ static FILE *file;
|
|||
#define FLOCKFILE_THREAD2_INPUT2 "thread2_flockfile_proc: *** input 2 ***"
|
||||
|
||||
#define defSignal(signal) \
|
||||
static os_cond signal;\
|
||||
static bool signal##_set = false;
|
||||
static os_cond signal;\
|
||||
static bool signal##_set = false;
|
||||
|
||||
#define initSignal(signal, mutex) \
|
||||
os_condInit(&signal, &mutex);\
|
||||
signal##_set = false;
|
||||
os_condInit(&signal, &mutex);\
|
||||
signal##_set = false;
|
||||
|
||||
#define sendSignal(signal, mutex) \
|
||||
os_mutexLock(&mutex);\
|
||||
/* signaling */ \
|
||||
signal##_set = true; \
|
||||
os_condSignal(&signal);\
|
||||
os_mutexUnlock(&mutex);
|
||||
os_mutexLock(&mutex);\
|
||||
/* signaling */ \
|
||||
signal##_set = true; \
|
||||
os_condSignal(&signal);\
|
||||
os_mutexUnlock(&mutex);
|
||||
|
||||
#define waitForSignal(signal, mutex) \
|
||||
os_mutexLock(&mutex);\
|
||||
while(!signal##_set) { \
|
||||
/* waiting for signal */ \
|
||||
os_condWait(&signal, &mutex);\
|
||||
/* received */ \
|
||||
} /* else already signal received */ \
|
||||
os_mutexUnlock(&mutex);
|
||||
os_mutexLock(&mutex);\
|
||||
while(!signal##_set) { \
|
||||
/* waiting for signal */ \
|
||||
os_condWait(&signal, &mutex);\
|
||||
/* received */ \
|
||||
} /* else already signal received */ \
|
||||
os_mutexUnlock(&mutex);
|
||||
|
||||
#define timedWaitSignal(signal, mutex, time) \
|
||||
{ \
|
||||
os_time duration = time; \
|
||||
os_time startTime, currentTime; \
|
||||
os_result rc; \
|
||||
os_mutexLock(&mutex); \
|
||||
startTime = os_timeGetElapsed(); \
|
||||
while(!signal##_set) { \
|
||||
/* waiting for signal */ \
|
||||
rc = os_condTimedWait(&signal, &mutex, &duration); \
|
||||
/* signal received or timeout */ \
|
||||
if(rc == os_resultTimeout) { \
|
||||
break; \
|
||||
} else { \
|
||||
currentTime = os_timeGetElapsed(); \
|
||||
if(os_timeCompare(os_timeSub(currentTime, startTime), wait_time_out) >= 0) { \
|
||||
break; \
|
||||
} \
|
||||
duration = os_timeSub(wait_time_out, os_timeSub(currentTime, startTime)); \
|
||||
} \
|
||||
} /* else already signal received */ \
|
||||
os_mutexUnlock(&mutex);\
|
||||
}
|
||||
{ \
|
||||
os_time duration = time; \
|
||||
os_time startTime, currentTime; \
|
||||
os_result rc; \
|
||||
os_mutexLock(&mutex); \
|
||||
startTime = os_timeGetElapsed(); \
|
||||
while(!signal##_set) { \
|
||||
/* waiting for signal */ \
|
||||
rc = os_condTimedWait(&signal, &mutex, &duration); \
|
||||
/* signal received or timeout */ \
|
||||
if(rc == os_resultTimeout) { \
|
||||
break; \
|
||||
} else { \
|
||||
currentTime = os_timeGetElapsed(); \
|
||||
if(os_timeCompare(os_timeSub(currentTime, startTime), wait_time_out) >= 0) { \
|
||||
break; \
|
||||
} \
|
||||
duration = os_timeSub(wait_time_out, os_timeSub(currentTime, startTime)); \
|
||||
} \
|
||||
} /* else already signal received */ \
|
||||
os_mutexUnlock(&mutex);\
|
||||
}
|
||||
|
||||
static os_mutex mutex;
|
||||
static bool do_locking;
|
||||
|
@ -93,176 +93,178 @@ defSignal(do_action2);
|
|||
defSignal(do_action3);
|
||||
|
||||
static uint32_t thread1_flockfile_proc(void* args) {
|
||||
int result = 0;
|
||||
int result = 0;
|
||||
(void)args;
|
||||
|
||||
/* thread1: start */
|
||||
sendSignal(thread1_started, mutex);
|
||||
/* thread1: start */
|
||||
sendSignal(thread1_started, mutex);
|
||||
|
||||
waitForSignal(do_action1, mutex);
|
||||
if(do_locking) os_flockfile(file);
|
||||
/* Thread1: writing input 1 to the file */
|
||||
result = fputs(FLOCKFILE_THREAD1_INPUT1, file);
|
||||
CU_ASSERT(result >= 0);
|
||||
waitForSignal(do_action1, mutex);
|
||||
if(do_locking) os_flockfile(file);
|
||||
/* Thread1: writing input 1 to the file */
|
||||
result = fputs(FLOCKFILE_THREAD1_INPUT1, file);
|
||||
CU_ASSERT(result >= 0);
|
||||
|
||||
sendSignal(action1_done, mutex);
|
||||
sendSignal(action1_done, mutex);
|
||||
|
||||
waitForSignal(do_action3, mutex);
|
||||
/* Thread1: writing input 3 to the file */
|
||||
result = fputs(FLOCKFILE_THREAD1_INPUT3, file);
|
||||
CU_ASSERT(result >= 0);
|
||||
if(do_locking) os_funlockfile(file);
|
||||
/* thread1: end */
|
||||
waitForSignal(do_action3, mutex);
|
||||
/* Thread1: writing input 3 to the file */
|
||||
result = fputs(FLOCKFILE_THREAD1_INPUT3, file);
|
||||
CU_ASSERT(result >= 0);
|
||||
if(do_locking) os_funlockfile(file);
|
||||
/* thread1: end */
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static uint32_t thread2_flockfile_proc(void* args) {
|
||||
int result = 0;
|
||||
int result = 0;
|
||||
(void)args;
|
||||
|
||||
/* thread2: start */
|
||||
sendSignal(thread2_started, mutex);
|
||||
/* thread2: start */
|
||||
sendSignal(thread2_started, mutex);
|
||||
|
||||
waitForSignal(do_action2, mutex);
|
||||
/* Thread2: writing input 2 to the file */
|
||||
result = fputs(FLOCKFILE_THREAD2_INPUT2, file);
|
||||
CU_ASSERT(result >= 0);
|
||||
waitForSignal(do_action2, mutex);
|
||||
/* Thread2: writing input 2 to the file */
|
||||
result = fputs(FLOCKFILE_THREAD2_INPUT2, file);
|
||||
CU_ASSERT(result >= 0);
|
||||
|
||||
sendSignal(action2_done, mutex);
|
||||
/* thread2: end */
|
||||
sendSignal(action2_done, mutex);
|
||||
/* thread2: end */
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool doFlockfileTest(bool lock) {
|
||||
bool testPassed = true;
|
||||
bool strcmpResult = true;
|
||||
os_result result;
|
||||
os_threadAttr threadAttr;
|
||||
os_threadId thread1;
|
||||
os_threadId thread2;
|
||||
int FLOCKFILE_INPUT_MAX = sizeof(FLOCKFILE_THREAD1_INPUT1);
|
||||
bool testPassed = true;
|
||||
bool strcmpResult = true;
|
||||
os_result result;
|
||||
os_threadAttr threadAttr;
|
||||
os_threadId thread1;
|
||||
os_threadId thread2;
|
||||
int FLOCKFILE_INPUT_MAX = sizeof(FLOCKFILE_THREAD1_INPUT1);
|
||||
|
||||
do_locking = lock;
|
||||
do_locking = lock;
|
||||
|
||||
char *buffer = os_malloc(sizeof(char) * FLOCKFILE_INPUT_MAX);
|
||||
char *buffer = os_malloc(sizeof(char) * (unsigned)FLOCKFILE_INPUT_MAX);
|
||||
|
||||
file = tmpfile();
|
||||
file = tmpfile();
|
||||
|
||||
os_mutexInit(&mutex);
|
||||
os_mutexInit(&mutex);
|
||||
|
||||
/* initialize all signal conditions */
|
||||
os_mutexLock(&mutex);
|
||||
initSignal(thread1_started, mutex);
|
||||
initSignal(thread2_started, mutex);
|
||||
initSignal(action1_done, mutex);
|
||||
initSignal(action2_done, mutex);
|
||||
/* initialize all signal conditions */
|
||||
os_mutexLock(&mutex);
|
||||
initSignal(thread1_started, mutex);
|
||||
initSignal(thread2_started, mutex);
|
||||
initSignal(action1_done, mutex);
|
||||
initSignal(action2_done, mutex);
|
||||
|
||||
initSignal(do_action1, mutex);
|
||||
initSignal(do_action2, mutex);
|
||||
initSignal(do_action3, mutex);
|
||||
os_mutexUnlock(&mutex);
|
||||
initSignal(do_action1, mutex);
|
||||
initSignal(do_action2, mutex);
|
||||
initSignal(do_action3, mutex);
|
||||
os_mutexUnlock(&mutex);
|
||||
|
||||
/* create threads... */
|
||||
os_threadAttrInit(&threadAttr);
|
||||
/* create threads... */
|
||||
os_threadAttrInit(&threadAttr);
|
||||
|
||||
result = os_threadCreate(
|
||||
&thread1,
|
||||
"thread 1",
|
||||
&threadAttr,
|
||||
thread1_flockfile_proc,
|
||||
NULL);
|
||||
CU_ASSERT(result == os_resultSuccess);
|
||||
result = os_threadCreate(
|
||||
&thread1,
|
||||
"thread 1",
|
||||
&threadAttr,
|
||||
thread1_flockfile_proc,
|
||||
NULL);
|
||||
CU_ASSERT(result == os_resultSuccess);
|
||||
|
||||
result = os_threadCreate(
|
||||
&thread2,
|
||||
"thread 2",
|
||||
&threadAttr,
|
||||
thread2_flockfile_proc,
|
||||
NULL);
|
||||
CU_ASSERT(result == os_resultSuccess);
|
||||
result = os_threadCreate(
|
||||
&thread2,
|
||||
"thread 2",
|
||||
&threadAttr,
|
||||
thread2_flockfile_proc,
|
||||
NULL);
|
||||
CU_ASSERT(result == os_resultSuccess);
|
||||
|
||||
/* wait for threads to start */
|
||||
waitForSignal(thread1_started, mutex);
|
||||
waitForSignal(thread2_started, mutex);
|
||||
/* wait for threads to start */
|
||||
waitForSignal(thread1_started, mutex);
|
||||
waitForSignal(thread2_started, mutex);
|
||||
|
||||
/* get thread one to do its first thing */
|
||||
sendSignal(do_action1, mutex);
|
||||
/* get thread one to do its first thing */
|
||||
sendSignal(do_action1, mutex);
|
||||
|
||||
/* wait for thread 1 to acknowledge */
|
||||
timedWaitSignal(action1_done, mutex, wait_time_out);
|
||||
/* wait for thread 1 to acknowledge */
|
||||
timedWaitSignal(action1_done, mutex, wait_time_out);
|
||||
|
||||
/* kick thead 2 */
|
||||
sendSignal(do_action2, mutex);
|
||||
/* kick thead 2 */
|
||||
sendSignal(do_action2, mutex);
|
||||
|
||||
/* wait for thread 2 to acknowledge */
|
||||
timedWaitSignal(action2_done, mutex, wait_time_out);
|
||||
/* wait for thread 2 to acknowledge */
|
||||
timedWaitSignal(action2_done, mutex, wait_time_out);
|
||||
|
||||
/* kick thread 1, again */
|
||||
sendSignal(do_action3, mutex);
|
||||
/* kick thread 1, again */
|
||||
sendSignal(do_action3, mutex);
|
||||
|
||||
/* wait for threads to shutdown */
|
||||
result = os_threadWaitExit(thread1,NULL);
|
||||
CU_ASSERT(result == os_resultSuccess);
|
||||
/* wait for threads to shutdown */
|
||||
result = os_threadWaitExit(thread1,NULL);
|
||||
CU_ASSERT(result == os_resultSuccess);
|
||||
|
||||
result = os_threadWaitExit(thread2,NULL);
|
||||
CU_ASSERT(result == os_resultSuccess);
|
||||
result = os_threadWaitExit(thread2,NULL);
|
||||
CU_ASSERT(result == os_resultSuccess);
|
||||
|
||||
/* if lock then Expected action order: 1 3 2
|
||||
* else Expected action order: 1 2 3 */
|
||||
/* if lock then Expected action order: 1 3 2
|
||||
* else Expected action order: 1 2 3 */
|
||||
|
||||
rewind(file);
|
||||
rewind(file);
|
||||
|
||||
if(lock) {
|
||||
if(fgets(buffer, FLOCKFILE_INPUT_MAX, file) > 0) {
|
||||
strcmpResult = (strcmp(buffer, FLOCKFILE_THREAD1_INPUT1) == 0);
|
||||
CU_ASSERT(strcmpResult);
|
||||
testPassed = testPassed && strcmpResult; /* update flag indicating overall test state */
|
||||
}
|
||||
if(fgets(buffer, FLOCKFILE_INPUT_MAX, file) > 0) {
|
||||
strcmpResult = (strcmp(buffer, FLOCKFILE_THREAD1_INPUT3) == 0);
|
||||
CU_ASSERT(strcmpResult);
|
||||
testPassed = testPassed && strcmpResult; /* update flag indicating overall test state */
|
||||
}
|
||||
if(fgets(buffer, FLOCKFILE_INPUT_MAX, file) > 0) {
|
||||
strcmpResult = (strcmp(buffer, FLOCKFILE_THREAD2_INPUT2) == 0);
|
||||
CU_ASSERT(strcmpResult);
|
||||
testPassed = testPassed && strcmpResult; /* update flag indicating overall test state */
|
||||
}
|
||||
} else {
|
||||
if(fgets(buffer, FLOCKFILE_INPUT_MAX, file) > 0) {
|
||||
strcmpResult = (strcmp(buffer, FLOCKFILE_THREAD1_INPUT1) == 0);
|
||||
CU_ASSERT(strcmpResult);
|
||||
testPassed = testPassed && strcmpResult; /* update flag indicating overall test state */
|
||||
}
|
||||
if(fgets(buffer, FLOCKFILE_INPUT_MAX, file) > 0) {
|
||||
strcmpResult = (strcmp(buffer, FLOCKFILE_THREAD2_INPUT2) == 0);
|
||||
CU_ASSERT(strcmpResult);
|
||||
testPassed = testPassed && strcmpResult; /* update flag indicating overall test state */
|
||||
}
|
||||
if(fgets(buffer, FLOCKFILE_INPUT_MAX, file) > 0) {
|
||||
strcmpResult = (strcmp(buffer, FLOCKFILE_THREAD1_INPUT3) == 0);
|
||||
CU_ASSERT(strcmpResult);
|
||||
testPassed = testPassed && strcmpResult; /* update flag indicating overall test state */
|
||||
}
|
||||
}
|
||||
if(lock) {
|
||||
if(fgets(buffer, FLOCKFILE_INPUT_MAX, file) > (char*)0) {
|
||||
strcmpResult = (strcmp(buffer, FLOCKFILE_THREAD1_INPUT1) == 0);
|
||||
CU_ASSERT(strcmpResult);
|
||||
testPassed = testPassed && strcmpResult; /* update flag indicating overall test state */
|
||||
}
|
||||
if(fgets(buffer, FLOCKFILE_INPUT_MAX, file) > (char*)0) {
|
||||
strcmpResult = (strcmp(buffer, FLOCKFILE_THREAD1_INPUT3) == 0);
|
||||
CU_ASSERT(strcmpResult);
|
||||
testPassed = testPassed && strcmpResult; /* update flag indicating overall test state */
|
||||
}
|
||||
if(fgets(buffer, FLOCKFILE_INPUT_MAX, file) > (char*)0) {
|
||||
strcmpResult = (strcmp(buffer, FLOCKFILE_THREAD2_INPUT2) == 0);
|
||||
CU_ASSERT(strcmpResult);
|
||||
testPassed = testPassed && strcmpResult; /* update flag indicating overall test state */
|
||||
}
|
||||
} else {
|
||||
if(fgets(buffer, FLOCKFILE_INPUT_MAX, file) > (char*)0) {
|
||||
strcmpResult = (strcmp(buffer, FLOCKFILE_THREAD1_INPUT1) == 0);
|
||||
CU_ASSERT(strcmpResult);
|
||||
testPassed = testPassed && strcmpResult; /* update flag indicating overall test state */
|
||||
}
|
||||
if(fgets(buffer, FLOCKFILE_INPUT_MAX, file) > (char*)0) {
|
||||
strcmpResult = (strcmp(buffer, FLOCKFILE_THREAD2_INPUT2) == 0);
|
||||
CU_ASSERT(strcmpResult);
|
||||
testPassed = testPassed && strcmpResult; /* update flag indicating overall test state */
|
||||
}
|
||||
if(fgets(buffer, FLOCKFILE_INPUT_MAX, file) > (char*)0) {
|
||||
strcmpResult = (strcmp(buffer, FLOCKFILE_THREAD1_INPUT3) == 0);
|
||||
CU_ASSERT(strcmpResult);
|
||||
testPassed = testPassed && strcmpResult; /* update flag indicating overall test state */
|
||||
}
|
||||
}
|
||||
|
||||
/* cleanup */
|
||||
os_free(buffer);
|
||||
fclose(file);
|
||||
/* cleanup */
|
||||
os_free(buffer);
|
||||
fclose(file);
|
||||
|
||||
os_mutexLock(&mutex);
|
||||
os_condDestroy(&do_action1);
|
||||
os_condDestroy(&do_action2);
|
||||
os_condDestroy(&do_action3);
|
||||
os_mutexLock(&mutex);
|
||||
os_condDestroy(&do_action1);
|
||||
os_condDestroy(&do_action2);
|
||||
os_condDestroy(&do_action3);
|
||||
|
||||
os_condDestroy(&thread1_started);
|
||||
os_condDestroy(&thread2_started);
|
||||
os_condDestroy(&action1_done);
|
||||
os_condDestroy(&action2_done);
|
||||
os_mutexUnlock(&mutex);
|
||||
os_mutexDestroy(&mutex);
|
||||
/* doFlockfileTest */
|
||||
return testPassed;
|
||||
os_condDestroy(&thread1_started);
|
||||
os_condDestroy(&thread2_started);
|
||||
os_condDestroy(&action1_done);
|
||||
os_condDestroy(&action2_done);
|
||||
os_mutexUnlock(&mutex);
|
||||
os_mutexDestroy(&mutex);
|
||||
/* doFlockfileTest */
|
||||
return testPassed;
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -806,64 +808,64 @@ CUnit_Test(os_stdlib, index)
|
|||
|
||||
CUnit_Test(os_stdlib, flockfile)
|
||||
{
|
||||
bool result = false;
|
||||
bool result = false;
|
||||
|
||||
os_osInit();
|
||||
os_osInit();
|
||||
|
||||
/* Check writing in a FILE from multiple threads without using os_flockfile. */
|
||||
printf ("Starting os_stdlib_flockfile_001\n");
|
||||
result = doFlockfileTest(false);
|
||||
CU_ASSERT (result);
|
||||
/* Check writing in a FILE from multiple threads without using os_flockfile. */
|
||||
printf ("Starting os_stdlib_flockfile_001\n");
|
||||
result = doFlockfileTest(false);
|
||||
CU_ASSERT (result);
|
||||
|
||||
/* Check writing in a FILE from multiple threads using os_flockfile in the first thread. */
|
||||
printf ("Starting os_stdlib_flockfile_002\n");
|
||||
result = doFlockfileTest(true);
|
||||
CU_ASSERT (result);
|
||||
/* Check writing in a FILE from multiple threads using os_flockfile in the first thread. */
|
||||
printf ("Starting os_stdlib_flockfile_002\n");
|
||||
result = doFlockfileTest(true);
|
||||
CU_ASSERT (result);
|
||||
|
||||
printf ("Ending os_stdlib_flockfile\n");
|
||||
printf ("Ending os_stdlib_flockfile\n");
|
||||
|
||||
os_osExit();
|
||||
os_osExit();
|
||||
}
|
||||
|
||||
CUnit_Test(os_stdlib, getopt)
|
||||
{
|
||||
int c = 0;
|
||||
int argc = 3;
|
||||
char *argv001[] = {"", "-a", "-b"};
|
||||
char *argv002[] = {"", "-c", "foo"};
|
||||
char *argv003[] = {"", "-d"};
|
||||
int c = 0;
|
||||
int argc = 3;
|
||||
char *argv001[] = {"", "-a", "-b"};
|
||||
char *argv002[] = {"", "-c", "foo"};
|
||||
char *argv003[] = {"", "-d"};
|
||||
|
||||
/* Check correct functioning of os_getopt */
|
||||
printf ("Starting os_stdlib_getopt_001\n");
|
||||
c = os_getopt(argc, argv001, "abc:");
|
||||
CU_ASSERT (c == 'a');
|
||||
c = os_getopt(argc, argv001, "abc:");
|
||||
CU_ASSERT (c == 'b');
|
||||
c = os_getopt(argc, argv001, "abc:");
|
||||
CU_ASSERT (c == -1);
|
||||
/* Check correct functioning of os_getopt */
|
||||
printf ("Starting os_stdlib_getopt_001\n");
|
||||
c = os_getopt(argc, argv001, "abc:");
|
||||
CU_ASSERT (c == 'a');
|
||||
c = os_getopt(argc, argv001, "abc:");
|
||||
CU_ASSERT (c == 'b');
|
||||
c = os_getopt(argc, argv001, "abc:");
|
||||
CU_ASSERT (c == -1);
|
||||
|
||||
/* Check correct functioning of os_set_optind and os_get_optind */
|
||||
printf ("Starting os_stdlib_getopt_002\n");
|
||||
os_set_optind(1);
|
||||
CU_ASSERT (os_get_optind() == 1);
|
||||
/* Check correct functioning of os_set_optind and os_get_optind */
|
||||
printf ("Starting os_stdlib_getopt_002\n");
|
||||
os_set_optind(1);
|
||||
CU_ASSERT (os_get_optind() == 1);
|
||||
|
||||
/* Check correct functioning of os_get_optarg */
|
||||
printf ("Starting os_stdlib_getopt_003\n");
|
||||
c = os_getopt (argc, argv002, "c:");
|
||||
CU_ASSERT (c == 'c');
|
||||
CU_ASSERT (strcmp(os_get_optarg(), "foo") == 0);
|
||||
c = os_getopt(argc, argv002, "c:");
|
||||
CU_ASSERT (c == -1);
|
||||
/* Check correct functioning of os_get_optarg */
|
||||
printf ("Starting os_stdlib_getopt_003\n");
|
||||
c = os_getopt (argc, argv002, "c:");
|
||||
CU_ASSERT (c == 'c');
|
||||
CU_ASSERT (strcmp(os_get_optarg(), "foo") == 0);
|
||||
c = os_getopt(argc, argv002, "c:");
|
||||
CU_ASSERT (c == -1);
|
||||
|
||||
/* Check correct functioning of os_set_opterr, os_get_opterr and os_get_optopt */
|
||||
printf ("Starting os_stdlib_getopt_004\n");
|
||||
argc = 2;
|
||||
os_set_optind(1);
|
||||
os_set_opterr(0);
|
||||
CU_ASSERT(os_get_opterr() == 0)
|
||||
c = os_getopt (argc, argv003, "c:");
|
||||
CU_ASSERT (c == '?');
|
||||
CU_ASSERT (os_get_optopt() == 'd');
|
||||
/* Check correct functioning of os_set_opterr, os_get_opterr and os_get_optopt */
|
||||
printf ("Starting os_stdlib_getopt_004\n");
|
||||
argc = 2;
|
||||
os_set_optind(1);
|
||||
os_set_opterr(0);
|
||||
CU_ASSERT(os_get_opterr() == 0)
|
||||
c = os_getopt (argc, argv003, "c:");
|
||||
CU_ASSERT (c == '?');
|
||||
CU_ASSERT (os_get_optopt() == 'd');
|
||||
|
||||
printf ("Ending os_stdlib_getopt\n");
|
||||
printf ("Ending os_stdlib_getopt\n");
|
||||
}
|
||||
|
|
|
@ -57,8 +57,7 @@ uint32_t get_threadExit_thread (void *args)
|
|||
{
|
||||
os_threadId * threadId = args;
|
||||
uint32_t id;
|
||||
os_result ret = os_threadWaitExit (*threadId, &id);
|
||||
|
||||
(void)os_threadWaitExit (*threadId, &id);
|
||||
return id;
|
||||
}
|
||||
|
||||
|
@ -69,14 +68,6 @@ uint32_t threadIdentity_thread (_In_ void *args)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static uint32_t threadMain(_In_opt_ void *args)
|
||||
{
|
||||
OS_UNUSED_ARG(args);
|
||||
threadCalled = 1;
|
||||
sleepMsec(500);
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32_t threadMemory_thread (_In_opt_ void *args)
|
||||
{
|
||||
OS_UNUSED_ARG(args);
|
||||
|
@ -137,6 +128,7 @@ CUnit_Suite_Cleanup(os_thread)
|
|||
CUnit_Test(os_thread, create)
|
||||
{
|
||||
int result;
|
||||
os_result osResult;
|
||||
os_threadId thread_os_threadId;
|
||||
os_threadAttr thread_os_threadAttr;
|
||||
#ifndef WIN32
|
||||
|
@ -147,16 +139,16 @@ CUnit_Test(os_thread, create)
|
|||
(check thread creation and check argument passing) */
|
||||
printf ("Starting os_thread_create_001\n");
|
||||
os_threadAttrInit (&thread_os_threadAttr);
|
||||
result = os_threadCreate (&thread_os_threadId, "ThreadCreate1", &thread_os_threadAttr, &new_thread, "os_threadCreate");
|
||||
CU_ASSERT (result == os_resultSuccess);
|
||||
if (result == os_resultSuccess) {
|
||||
osResult = os_threadCreate (&thread_os_threadId, "ThreadCreate1", &thread_os_threadAttr, &new_thread, "os_threadCreate");
|
||||
CU_ASSERT (osResult == os_resultSuccess);
|
||||
if (osResult == os_resultSuccess) {
|
||||
#ifdef _WRS_KERNEL
|
||||
taskDelay(1 * sysClkRateGet());
|
||||
#endif
|
||||
result = os_threadWaitExit (thread_os_threadId, NULL);
|
||||
CU_ASSERT (result == os_resultSuccess);
|
||||
osResult = os_threadWaitExit (thread_os_threadId, NULL);
|
||||
CU_ASSERT (osResult == os_resultSuccess);
|
||||
|
||||
if (result == os_resultSuccess) {
|
||||
if (osResult == os_resultSuccess) {
|
||||
result = strcmp (arg_result, "os_threadCreate");
|
||||
CU_ASSERT (result == 0);
|
||||
if (result == 0)
|
||||
|
@ -176,11 +168,11 @@ CUnit_Test(os_thread, create)
|
|||
printf ("Starting s_thread_create_003\n");
|
||||
os_threadAttrInit (&thread_os_threadAttr);
|
||||
thread_os_threadAttr.schedClass = OS_SCHED_DEFAULT;
|
||||
result = os_threadCreate (&thread_os_threadId, "ThreadCreate3", &thread_os_threadAttr, &new_thread, "os_threadCreate");
|
||||
CU_ASSERT (result == os_resultSuccess);
|
||||
osResult = os_threadCreate (&thread_os_threadId, "ThreadCreate3", &thread_os_threadAttr, &new_thread, "os_threadCreate");
|
||||
CU_ASSERT (osResult == os_resultSuccess);
|
||||
|
||||
#if !(defined _WRS_KERNEL || defined WIN32)
|
||||
if (result == os_resultSuccess) {
|
||||
if (osResult == os_resultSuccess) {
|
||||
int policy;
|
||||
struct sched_param sched_param;
|
||||
|
||||
|
@ -192,8 +184,8 @@ CUnit_Test(os_thread, create)
|
|||
} else {
|
||||
CU_ASSERT (policy == SCHED_OTHER);
|
||||
}
|
||||
result = os_threadWaitExit (thread_os_threadId, NULL);
|
||||
CU_ASSERT (result == os_resultSuccess);
|
||||
osResult = os_threadWaitExit (thread_os_threadId, NULL);
|
||||
CU_ASSERT (osResult == os_resultSuccess);
|
||||
} else {
|
||||
printf ("os_threadCreate failed.\n");
|
||||
}
|
||||
|
@ -205,9 +197,9 @@ CUnit_Test(os_thread, create)
|
|||
printf ("Starting os_thread_create_004\n");
|
||||
os_threadAttrInit (&thread_os_threadAttr);
|
||||
thread_os_threadAttr.schedClass = OS_SCHED_TIMESHARE;
|
||||
result = os_threadCreate (&thread_os_threadId, "ThreadCreate4", &thread_os_threadAttr, &new_thread, "os_threadCreate");
|
||||
CU_ASSERT (result == os_resultSuccess);
|
||||
if (result == os_resultSuccess) {
|
||||
osResult = os_threadCreate (&thread_os_threadId, "ThreadCreate4", &thread_os_threadAttr, &new_thread, "os_threadCreate");
|
||||
CU_ASSERT (osResult == os_resultSuccess);
|
||||
if (osResult == os_resultSuccess) {
|
||||
#ifndef WIN32
|
||||
int policy;
|
||||
struct sched_param sched_param;
|
||||
|
@ -222,7 +214,7 @@ CUnit_Test(os_thread, create)
|
|||
}
|
||||
#endif /* WIN32 */
|
||||
|
||||
result = os_threadWaitExit (thread_os_threadId, NULL);
|
||||
osResult = os_threadWaitExit (thread_os_threadId, NULL);
|
||||
} else {
|
||||
printf ("os_threadCreate failed.\n");
|
||||
}
|
||||
|
@ -241,9 +233,9 @@ CUnit_Test(os_thread, create)
|
|||
os_threadAttrInit (&thread_os_threadAttr);
|
||||
thread_os_threadAttr.schedClass = OS_SCHED_REALTIME;
|
||||
thread_os_threadAttr.schedPriority = sched_get_priority_min (SCHED_FIFO);
|
||||
result = os_threadCreate (&thread_os_threadId, "ThreadCreate5", &thread_os_threadAttr, &new_thread, "os_threadCreate");
|
||||
CU_ASSERT (result == os_resultSuccess);
|
||||
if (result == os_resultSuccess) {
|
||||
osResult = os_threadCreate (&thread_os_threadId, "ThreadCreate5", &thread_os_threadAttr, &new_thread, "os_threadCreate");
|
||||
CU_ASSERT (osResult == os_resultSuccess);
|
||||
if (osResult == os_resultSuccess) {
|
||||
int policy;
|
||||
struct sched_param sched_param;
|
||||
|
||||
|
@ -255,7 +247,7 @@ CUnit_Test(os_thread, create)
|
|||
} else {
|
||||
printf ("pthread_getschedparam failed\n");
|
||||
}
|
||||
result = os_threadWaitExit (thread_os_threadId, NULL);
|
||||
osResult = os_threadWaitExit (thread_os_threadId, NULL);
|
||||
} else {
|
||||
printf ("os_threadCreate failed\n");
|
||||
}
|
||||
|
@ -274,16 +266,16 @@ CUnit_Test(os_thread, create)
|
|||
#else
|
||||
thread_os_threadAttr.schedPriority = sched_get_priority_min (SCHED_OTHER);
|
||||
#endif
|
||||
result = os_threadCreate (&thread_os_threadId, "ThreadCreate6", &thread_os_threadAttr, &new_thread, "os_threadCreate");
|
||||
osResult = os_threadCreate (&thread_os_threadId, "ThreadCreate6", &thread_os_threadAttr, &new_thread, "os_threadCreate");
|
||||
#ifdef _WRS_KERNEL
|
||||
if (result == os_resultSuccess)
|
||||
if (osResult == os_resultSuccess)
|
||||
printf ("os_threadCreate failed - Expected failure from VXWORKS\n");
|
||||
else
|
||||
printf ("OS_SCHED_TIMESHARE not supported\n");
|
||||
#else
|
||||
CU_ASSERT (result == os_resultSuccess);
|
||||
CU_ASSERT (osResult == os_resultSuccess);
|
||||
|
||||
if (result == os_resultSuccess) {
|
||||
if (osResult == os_resultSuccess) {
|
||||
int policy;
|
||||
struct sched_param sched_param;
|
||||
|
||||
|
@ -295,7 +287,7 @@ CUnit_Test(os_thread, create)
|
|||
} else {
|
||||
printf ("pthread_getschedparam failed\n");
|
||||
}
|
||||
result = os_threadWaitExit (thread_os_threadId, NULL);
|
||||
osResult = os_threadWaitExit (thread_os_threadId, NULL);
|
||||
} else {
|
||||
printf ("os_threadCreate failed.\n");
|
||||
}
|
||||
|
@ -314,17 +306,17 @@ CUnit_Test(os_thread, create)
|
|||
#else
|
||||
thread_os_threadAttr.schedPriority = sched_get_priority_max (SCHED_OTHER);
|
||||
#endif
|
||||
result = os_threadCreate (&thread_os_threadId, "ThreadCreate7", &thread_os_threadAttr, &new_thread, "os_threadCreate");
|
||||
osResult = os_threadCreate (&thread_os_threadId, "ThreadCreate7", &thread_os_threadAttr, &new_thread, "os_threadCreate");
|
||||
#ifdef _WRS_KERNEL
|
||||
if (result == os_resultSuccess) {
|
||||
if (osResult == os_resultSuccess) {
|
||||
printf ("os_threadCreate failed - Expected failure from VXWORKS\n");
|
||||
} else {
|
||||
printf ("OS_SCHED_TIMESHARE not supported\n");
|
||||
}
|
||||
#else
|
||||
CU_ASSERT (result == os_resultSuccess);
|
||||
CU_ASSERT (osResult == os_resultSuccess);
|
||||
|
||||
if (result == os_resultSuccess) {
|
||||
if (osResult == os_resultSuccess) {
|
||||
int policy;
|
||||
struct sched_param sched_param;
|
||||
|
||||
|
@ -336,7 +328,7 @@ CUnit_Test(os_thread, create)
|
|||
} else {
|
||||
printf ("pthread_getschedparam failed\n");
|
||||
}
|
||||
result = os_threadWaitExit (thread_os_threadId, NULL);
|
||||
osResult = os_threadWaitExit (thread_os_threadId, NULL);
|
||||
} else {
|
||||
printf ("os_threadCreate failed.\n");
|
||||
}
|
||||
|
@ -363,10 +355,10 @@ CUnit_Test(os_thread, create)
|
|||
#else
|
||||
thread_os_threadAttr.schedPriority = sched_get_priority_min (SCHED_FIFO);
|
||||
#endif
|
||||
result = os_threadCreate (&thread_os_threadId, "ThreadCreate8", &thread_os_threadAttr, &new_thread, "os_threadCreate");
|
||||
CU_ASSERT (result == os_resultSuccess);
|
||||
osResult = os_threadCreate (&thread_os_threadId, "ThreadCreate8", &thread_os_threadAttr, &new_thread, "os_threadCreate");
|
||||
CU_ASSERT (osResult == os_resultSuccess);
|
||||
|
||||
if (result == os_resultSuccess) {
|
||||
if (osResult == os_resultSuccess) {
|
||||
#ifdef _WRS_KERNEL
|
||||
TASK_ID id;
|
||||
int pri;
|
||||
|
@ -390,7 +382,7 @@ CUnit_Test(os_thread, create)
|
|||
printf ("pthread_getschedparam failed.\n");
|
||||
}
|
||||
#endif /* _WRS_KERNEL */
|
||||
result = os_threadWaitExit (thread_os_threadId, NULL);
|
||||
osResult = os_threadWaitExit (thread_os_threadId, NULL);
|
||||
} else {
|
||||
printf ("os_threadCreate failed.\n");
|
||||
}
|
||||
|
@ -417,10 +409,10 @@ CUnit_Test(os_thread, create)
|
|||
#else
|
||||
thread_os_threadAttr.schedPriority = sched_get_priority_max (SCHED_FIFO);
|
||||
#endif
|
||||
result = os_threadCreate (&thread_os_threadId, "ThreadCreate9", &thread_os_threadAttr, &new_thread, "os_threadCreate");
|
||||
CU_ASSERT (result == os_resultSuccess);
|
||||
osResult = os_threadCreate (&thread_os_threadId, "ThreadCreate9", &thread_os_threadAttr, &new_thread, "os_threadCreate");
|
||||
CU_ASSERT (osResult == os_resultSuccess);
|
||||
|
||||
if (result == os_resultSuccess) {
|
||||
if (osResult == os_resultSuccess) {
|
||||
#ifdef _WRS_KERNEL
|
||||
int status;
|
||||
sleepSeconds (2);
|
||||
|
@ -440,7 +432,7 @@ CUnit_Test(os_thread, create)
|
|||
printf ("pthread_getschedparam failed.\n");
|
||||
}
|
||||
#endif
|
||||
result = os_threadWaitExit (thread_os_threadId, NULL);
|
||||
osResult = os_threadWaitExit (thread_os_threadId, NULL);
|
||||
} else {
|
||||
printf ("os_threadCreate failed.\n");
|
||||
}
|
||||
|
@ -464,23 +456,23 @@ CUnit_Test(os_thread, idself)
|
|||
{
|
||||
os_threadId thread_os_threadId;
|
||||
os_threadAttr thread_os_threadAttr;
|
||||
int result;
|
||||
os_result osResult;
|
||||
uint32_t result_from_thread;
|
||||
|
||||
/* Check if own thread ID is correctly provided */
|
||||
printf ("Starting tc_os_threadIdSelf_001\n");
|
||||
os_threadAttrInit (&thread_os_threadAttr);
|
||||
result = os_threadCreate (&thread_os_threadId, "OwnThreadId", &thread_os_threadAttr, &threadId_thread, NULL);
|
||||
CU_ASSERT (result == os_resultSuccess);
|
||||
osResult = os_threadCreate (&thread_os_threadId, "OwnThreadId", &thread_os_threadAttr, &threadId_thread, NULL);
|
||||
CU_ASSERT (osResult == os_resultSuccess);
|
||||
|
||||
if (result == os_resultSuccess) {
|
||||
if (osResult == os_resultSuccess) {
|
||||
#ifdef _WRS_KERNEL
|
||||
sleepSeconds(1);
|
||||
#endif
|
||||
result = os_threadWaitExit (thread_os_threadId, &result_from_thread);
|
||||
CU_ASSERT (result == os_resultSuccess);
|
||||
osResult = os_threadWaitExit (thread_os_threadId, &result_from_thread);
|
||||
CU_ASSERT (osResult == os_resultSuccess);
|
||||
|
||||
if (result == os_resultSuccess) {
|
||||
if (osResult == os_resultSuccess) {
|
||||
uintmax_t tmp_thread_os_threadId = os_threadIdToInteger(thread_os_threadId);
|
||||
CU_ASSERT (thread_id_from_thread == tmp_thread_os_threadId);
|
||||
CU_ASSERT (result_from_thread == (uint32_t)tmp_thread_os_threadId);
|
||||
|
@ -498,24 +490,24 @@ CUnit_Test(os_thread, join)
|
|||
{
|
||||
os_threadId thread_os_threadId;
|
||||
os_threadAttr thread_os_threadAttr;
|
||||
int result;
|
||||
os_result osResult;
|
||||
uint32_t result_from_thread;
|
||||
|
||||
/* Wait for thread to terminate and get the return value with Success result,
|
||||
while thread is still running */
|
||||
printf("Starting os_thread_join_001\n");
|
||||
os_threadAttrInit (&thread_os_threadAttr);
|
||||
result = os_threadCreate (&thread_os_threadId, "threadWaitExit", &thread_os_threadAttr, &threadId_thread, (void *)1);
|
||||
CU_ASSERT (result == os_resultSuccess);
|
||||
osResult = os_threadCreate (&thread_os_threadId, "threadWaitExit", &thread_os_threadAttr, &threadId_thread, (void *)1);
|
||||
CU_ASSERT (osResult == os_resultSuccess);
|
||||
|
||||
if (result == os_resultSuccess) {
|
||||
if (osResult == os_resultSuccess) {
|
||||
#ifdef _WRS_KERNEL
|
||||
sleepSeconds(1);
|
||||
#endif
|
||||
result = os_threadWaitExit (thread_os_threadId, &result_from_thread);
|
||||
CU_ASSERT (result == os_resultSuccess);
|
||||
osResult = os_threadWaitExit (thread_os_threadId, &result_from_thread);
|
||||
CU_ASSERT (osResult == os_resultSuccess);
|
||||
|
||||
if (result == os_resultSuccess) {
|
||||
if (osResult == os_resultSuccess) {
|
||||
CU_ASSERT (thread_id_from_thread == os_threadIdToInteger(thread_os_threadId));
|
||||
CU_ASSERT (result_from_thread == (uint32_t)thread_id_from_thread);
|
||||
} else {
|
||||
|
@ -529,17 +521,17 @@ CUnit_Test(os_thread, join)
|
|||
while thread is already terminated */
|
||||
printf ("Starting os_thread_join_002\n");
|
||||
os_threadAttrInit (&thread_os_threadAttr);
|
||||
result = os_threadCreate (&thread_os_threadId, "threadWaitExit", &thread_os_threadAttr, &threadId_thread, NULL);
|
||||
CU_ASSERT (result == os_resultSuccess);
|
||||
osResult = os_threadCreate (&thread_os_threadId, "threadWaitExit", &thread_os_threadAttr, &threadId_thread, NULL);
|
||||
CU_ASSERT (osResult == os_resultSuccess);
|
||||
|
||||
if (result == os_resultSuccess) {
|
||||
if (osResult == os_resultSuccess) {
|
||||
#ifdef _WRS_KERNEL
|
||||
sleepSeconds(1);
|
||||
#endif
|
||||
result = os_threadWaitExit (thread_os_threadId, &result_from_thread);
|
||||
CU_ASSERT(result == os_resultSuccess);
|
||||
osResult = os_threadWaitExit (thread_os_threadId, &result_from_thread);
|
||||
CU_ASSERT(osResult == os_resultSuccess);
|
||||
|
||||
if (result == os_resultSuccess) {
|
||||
if (osResult == os_resultSuccess) {
|
||||
CU_ASSERT (thread_id_from_thread == os_threadIdToInteger(thread_os_threadId));
|
||||
CU_ASSERT (result_from_thread == (uint32_t)thread_id_from_thread);
|
||||
} else {
|
||||
|
@ -552,15 +544,15 @@ CUnit_Test(os_thread, join)
|
|||
/* Get thread return value with Fail result because result is already read */
|
||||
printf ("Starting tc_os_thread_join_003\n");
|
||||
os_threadAttrInit (&thread_os_threadAttr);
|
||||
result = os_threadCreate (&thread_os_threadId, "threadWaitExit", &thread_os_threadAttr, &threadId_thread, NULL);
|
||||
CU_ASSERT (result == os_resultSuccess);
|
||||
osResult = os_threadCreate (&thread_os_threadId, "threadWaitExit", &thread_os_threadAttr, &threadId_thread, NULL);
|
||||
CU_ASSERT (osResult == os_resultSuccess);
|
||||
|
||||
if (result == os_resultSuccess) {
|
||||
if (osResult == os_resultSuccess) {
|
||||
#ifdef _WRS_KERNEL
|
||||
sleepSeconds(1);
|
||||
#endif
|
||||
result = os_threadWaitExit (thread_os_threadId, NULL);
|
||||
CU_ASSERT (result == os_resultSuccess);
|
||||
osResult = os_threadWaitExit (thread_os_threadId, NULL);
|
||||
CU_ASSERT (osResult == os_resultSuccess);
|
||||
} else {
|
||||
printf ("os_threadCreate failed.\n");
|
||||
}
|
||||
|
@ -572,23 +564,23 @@ CUnit_Test(os_thread, join)
|
|||
os_threadAttrInit (&thread_os_threadAttr);
|
||||
{
|
||||
os_threadId threadWait1;
|
||||
os_result result1;
|
||||
os_result osResult1;
|
||||
|
||||
result = os_threadCreate (&thread_os_threadId, "threadToWaitFor", &thread_os_threadAttr, &threadId_thread, (void*) 1);
|
||||
CU_ASSERT (result == os_resultSuccess);
|
||||
result1 = os_threadCreate (&threadWait1, "waitingThread1", &thread_os_threadAttr, &get_threadExit_thread, &thread_os_threadId);
|
||||
CU_ASSERT (result1 == os_resultSuccess);
|
||||
osResult = os_threadCreate (&thread_os_threadId, "threadToWaitFor", &thread_os_threadAttr, &threadId_thread, (void*) 1);
|
||||
CU_ASSERT (osResult == os_resultSuccess);
|
||||
osResult1 = os_threadCreate (&threadWait1, "waitingThread1", &thread_os_threadAttr, &get_threadExit_thread, &thread_os_threadId);
|
||||
CU_ASSERT (osResult1 == os_resultSuccess);
|
||||
|
||||
if (result == os_resultSuccess && result1 == os_resultSuccess)
|
||||
if (osResult == os_resultSuccess && osResult1 == os_resultSuccess)
|
||||
{
|
||||
#ifdef _WRS_KERNEL
|
||||
sleepSeconds(1);
|
||||
#endif
|
||||
result1 = os_threadWaitExit (threadWait1, NULL);
|
||||
osResult1 = os_threadWaitExit (threadWait1, NULL);
|
||||
|
||||
if (result1 != os_resultSuccess) {
|
||||
if (osResult1 != os_resultSuccess) {
|
||||
printf ("os_threadWaitExit 1 failed\n");
|
||||
CU_ASSERT (result1 == os_resultSuccess);
|
||||
CU_ASSERT (osResult1 == os_resultSuccess);
|
||||
}
|
||||
} else {
|
||||
printf ("os_threadCreate failed.\n");
|
||||
|
@ -602,16 +594,16 @@ CUnit_Test(os_thread, join)
|
|||
return value address - not interrested */
|
||||
printf ("Starting tc_os_threadWaitExit_005\n");
|
||||
os_threadAttrInit (&thread_os_threadAttr);
|
||||
result = os_threadCreate (&thread_os_threadId, "threadWaitExit", &thread_os_threadAttr, &threadId_thread, NULL);
|
||||
CU_ASSERT (result == os_resultSuccess);
|
||||
osResult = os_threadCreate (&thread_os_threadId, "threadWaitExit", &thread_os_threadAttr, &threadId_thread, NULL);
|
||||
CU_ASSERT (osResult == os_resultSuccess);
|
||||
|
||||
if (result == os_resultSuccess) {
|
||||
if (osResult == os_resultSuccess) {
|
||||
#ifdef _WRS_KERNEL
|
||||
sleepSeconds(1);
|
||||
#endif
|
||||
result = os_threadWaitExit (thread_os_threadId, NULL);
|
||||
CU_ASSERT (result == os_resultSuccess);
|
||||
if (result != os_resultSuccess)
|
||||
osResult = os_threadWaitExit (thread_os_threadId, NULL);
|
||||
CU_ASSERT (osResult == os_resultSuccess);
|
||||
if (osResult != os_resultSuccess)
|
||||
printf ("os_threadWaitExit failed.\n");
|
||||
} else {
|
||||
printf ("os_threadCreate failed.\n");
|
||||
|
@ -627,7 +619,7 @@ CUnit_Test(os_thread, figure_identity)
|
|||
os_threadAttr thread_os_threadAttr;
|
||||
char threadId[512];
|
||||
char thread_name[512];
|
||||
int result;
|
||||
os_result osResult;
|
||||
#endif /* WIN32 */
|
||||
|
||||
/* Figure out the identity of the thread, where it's name is known */
|
||||
|
@ -636,17 +628,17 @@ CUnit_Test(os_thread, figure_identity)
|
|||
/* Untested because the identifier does not contain the name on Windows */
|
||||
#else
|
||||
os_threadAttrInit (&thread_os_threadAttr);
|
||||
result = os_threadCreate (&thread_os_threadId, "threadFigureIdentity", &thread_os_threadAttr, &threadIdentity_thread, threadId);
|
||||
CU_ASSERT (result == os_resultSuccess);
|
||||
osResult = os_threadCreate (&thread_os_threadId, "threadFigureIdentity", &thread_os_threadAttr, &threadIdentity_thread, threadId);
|
||||
CU_ASSERT (osResult == os_resultSuccess);
|
||||
|
||||
if (result == os_resultSuccess) {
|
||||
if (osResult == os_resultSuccess) {
|
||||
#ifdef _WRS_KERNEL
|
||||
sleepSeconds(1);
|
||||
#endif
|
||||
result = os_threadWaitExit (thread_os_threadId, NULL);
|
||||
CU_ASSERT (result == os_resultSuccess);
|
||||
osResult = os_threadWaitExit (thread_os_threadId, NULL);
|
||||
CU_ASSERT (osResult == os_resultSuccess);
|
||||
|
||||
if (result == os_resultSuccess) {
|
||||
if (osResult == os_resultSuccess) {
|
||||
uintmax_t threadNumeric = 0;
|
||||
#ifdef _WRS_KERNEL
|
||||
int dum;
|
||||
|
@ -714,12 +706,12 @@ CUnit_Test(os_thread, figure_identity)
|
|||
{
|
||||
char threadId[512];
|
||||
char threadIdString[512];
|
||||
unsigned int threadIdLen;
|
||||
int32_t threadIdLen;
|
||||
|
||||
(void)snprintf (threadIdString, sizeof(threadIdString), "0x%"PRIxMAX, os_threadIdToInteger(os_threadIdSelf()));
|
||||
threadIdLen = os_threadFigureIdentity (threadId, sizeof(threadId));
|
||||
|
||||
CU_ASSERT (threadIdLen == strlen(threadIdString));
|
||||
CU_ASSERT (threadIdLen == (int32_t)strlen(threadIdString));
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue