#if (INCLUDE__UBINOS__UBIK_TEST == 1)
#if ( !(UBINOS__UBIK_TEST__EXCLUDE_TASKTESTSET3 == 1) && !(UBINOS__UBIK_TEST__EXCLUDE_MUTEXTESTSET == 1) && !(UBINOS__UBIK_TEST__EXCLUDE_SIGNALTESTSET == 1) && \
!(UBINOS__UBIK_TEST__EXCLUDE_CONDVTESTSET == 1) && !(UBINOS__UBIK_TEST__EXCLUDE_SEMTESTSET == 1) && !(UBINOS__UBIK_TEST__EXCLUDE_MSGQTESTSET == 1) )
#include <stdio.h>
#define SIGOBJCOUNT 5
static void tasktest07_task1func(void * arg) {
int r;
int i;
int j;
unsigned int waittick =
ubik_timemstotick(UBINOS__UBIK_TEST__TASKWAITTIMEMS * UBINOS__UBIK_TEST__TASKLOOPCOUNT);
unsigned char msg[UBINOS__UBIK_TEST__MSGQSIZE];
void * sigobj_a[SIGOBJCOUNT];
int sigtype_a[SIGOBJCOUNT];
void * param_a[SIGOBJCOUNT];
param_a[4] = (void *) msg;
if (0 != r) {
printf("task 1: fail at task_setmaxwaitsigobj(), err=%d\n", r);
goto end0;
}
for (i=0; i<UBINOS__UBIK_TEST__TASKLOOPCOUNT * 1; i++) {
printf("1");
}
printf("\n");
printf("task 1 waits for multiple signals (without all option)\n");
if (0 != r) {
printf("task 1: fail at mutex_lock(), err=%d\n", r);
goto end0;
}
if (0 != r) {
printf("task 1: fail at task_waitforsigobjs(), err=%d\n", r);
goto end0;
}
if (0 != r) {
printf("task 1: fail at mutex_unlock(), err=%d\n", r);
goto end0;
}
for (i=0; i<SIGOBJCOUNT; i++) {
switch (i) {
case 0:
case 1:
case 2:
case 3:
case 5:
if (-1 != sigtype_a[i]) {
printf("task 1: sigtype_a[%d] value is wrong\n", i);
goto end0;
}
break;
case 4:
if (0 != sigtype_a[i]) {
printf("task 1: sigtype_a[%d] value is wrong\n", i);
goto end0;
}
for (j=0; j<UBINOS__UBIK_TEST__MSGQSIZE; j++) {
if (j != msg[j]) {
printf("task 1: received message is wrong\n");
goto end0;
}
}
break;
}
}
for (i=0; i<UBINOS__UBIK_TEST__TASKLOOPCOUNT * 1; i++) {
printf("1");
}
printf("\n");
printf("task 1 waits for multiple signals with all option\n");
if (0 != r) {
printf("task 1: fail at mutex_lock(), err=%d\n", r);
goto end0;
}
if (0 != r) {
printf("task 1: fail at task_waitforsigobjs(), err=%d\n", r);
goto end0;
}
if (0 != r) {
printf("task 1: fail at mutex_unlock(), err=%d\n", r);
goto end0;
}
for (i=0; i<SIGOBJCOUNT; i++) {
switch (i) {
case 0:
case 1:
case 2:
case 3:
if (0 != sigtype_a[i]) {
printf("task 1: sigtype_a[%d] value is wrong\n", i);
goto end0;
}
break;
case 4:
if (0 != sigtype_a[i]) {
printf("task 1: sigtype_a[%d] value is wrong\n", i);
goto end0;
}
for (j=0; j<UBINOS__UBIK_TEST__MSGQSIZE; j++) {
if ((UBINOS__UBIK_TEST__MSGQSIZE - j) != msg[j]) {
printf("task 1: received message is wrong\n");
goto end0;
}
}
break;
}
}
for (i=0; i<UBINOS__UBIK_TEST__TASKLOOPCOUNT * 1; i++) {
printf("1");
}
printf("\n");
printf("task 1 unlocks mutex\n");
if (0 != r) {
printf("task 1: fail at mutex_unlock(), err=%d\n", r);
goto end0;
}
printf("\n");
printf("task 1 wakes up\n");
for (i=0; i<UBINOS__UBIK_TEST__TASKLOOPCOUNT * 1; i++) {
printf("1");
}
printf("\n");
printf(
"task 1 waits for multiple signals with all option and timeout (for %d ms)\n",
ubik_ticktotimems(waittick * 2));
if (0 != r) {
printf("task 1: fail at mutex_lock(), err=%d\n", r);
goto end0;
}
printf("task 1: fail at task_waitforsigobjs(), err=%d\n", r);
goto end0;
}
if (0 != r) {
printf("task 1: fail at mutex_unlock(), err=%d\n", r);
goto end0;
}
printf("\n");
printf("task 1 wakes up\n");
for (i=0; i<SIGOBJCOUNT; i++) {
switch (i) {
case 0:
case 1:
case 2:
case 4:
printf("task 1: sigtype_a[%d] value is wrong\n", i);
goto end0;
}
break;
case 3:
if (0 != sigtype_a[i]) {
printf("task 1: sigtype_a[%d] value is wrong\n", i);
goto end0;
}
break;
}
}
for (i=0; i<UBINOS__UBIK_TEST__TASKLOOPCOUNT * 1; i++) {
printf("1");
}
printf("\n");
end0:
printf("task 1 ends\n");
}
static void tasktest07_task2func(void * arg) {
int r;
int i;
unsigned char msg[UBINOS__UBIK_TEST__MSGQSIZE];
printf("task 2 locks mutex\n");
if (0 != r) {
printf("task 2: fail at mutex_lock(), err=%d\n", r);
goto end0;
}
for (i=0; i<UBINOS__UBIK_TEST__TASKLOOPCOUNT * 2; i++) {
printf("2");
}
printf("\n");
printf("task 2 sends one signal\n");
for (i=0; i<UBINOS__UBIK_TEST__MSGQSIZE; i++) {
msg[i] = i;
}
if (0 != r) {
printf("task 2: fail at msgq_send(), err=%d\n", r);
goto end0;
}
for (i=0; i<UBINOS__UBIK_TEST__TASKLOOPCOUNT * 1; i++) {
printf("2");
}
printf("\n");
printf("task 2 sends one signal\n");
for (i=0; i<UBINOS__UBIK_TEST__MSGQSIZE; i++) {
msg[i] = UBINOS__UBIK_TEST__MSGQSIZE - i;
}
if (0 != r) {
printf("task 2: fail at msgq_send(), err=%d\n", r);
goto end0;
}
for (i=0; i<UBINOS__UBIK_TEST__TASKLOOPCOUNT * 1; i++) {
printf("2");
}
printf("\n");
printf("task 2 sends all other signals\n");
if (0 != r) {
printf("task 2: fail at mutex_unlock(), err=%d\n", r);
goto end0;
}
if (0 != r) {
printf("task 2: fail at signal_send(), err=%d\n", r);
goto end0;
}
if (0 != r) {
printf("task 2: fail at mutex_lock(), err=%d\n", r);
goto end0;
}
if (0 != r) {
printf("task 2: fail at condv_signal(), err=%d\n", r);
goto end0;
}
if (0 != r) {
printf("task 2: fail at mutex_unlock(), err=%d\n", r);
goto end0;
}
if (0 != r) {
printf("task 2: fail at sem_give(), err=%d\n", r);
goto end0;
}
printf("task 2 locks mutex\n");
if (0 != r) {
printf("task 2: fail at mutex_lock(), err=%d\n", r);
goto end0;
}
for (i=0; i<UBINOS__UBIK_TEST__TASKLOOPCOUNT * 2; i++) {
printf("2");
}
printf("\n");
printf("task 2 sends one signal\n");
if (0 != r) {
printf("task 2: fail at sem_give(), err=%d\n", r);
goto end0;
}
for (i=0; i<UBINOS__UBIK_TEST__TASKLOOPCOUNT * 2; i++) {
printf("2");
}
printf("\n");
printf("task 2 unlocks mutex\n");
if (0 != r) {
printf("task 2: fail at mutex_unlock(), err=%d\n", r);
goto end0;
}
end0:
printf("task 2 ends\n");
}
int r;
int r2;
unsigned int count1;
unsigned int count2;
unsigned int sleepvalue =
ubik_timemstotick(UBINOS__UBIK_TEST__TASKWAITTIMEMS) * UBINOS__UBIK_TEST__TASKLOOPCOUNT / 3;
printf("\n");
printf("<test>\n");
printf("<name>ubik_test_tasktest07</name>\n");
printf("<description>Test on wait for multiple signal objects function of task</description>\n");
printf("<message>\n");
if (0 != r) {
printf("fail at mutex_create(), err=%d\n", r);
r = -1;
goto end0;
}
if (0 != r) {
printf("fail at mutex_create(), err=%d\n", r);
r = -1;
goto end0;
}
if (0 != r) {
printf("fail at mutex_create(), err=%d\n", r);
r = -1;
goto end0;
}
if (0 != r) {
printf("fail at mutex_create(), err=%d\n", r);
r = -1;
goto end0;
}
if (0 != r) {
printf("fail at mutex_create(), err=%d\n", r);
r = -1;
goto end0;
}
if (0 != r) {
printf("fail at mutex_create(), err=%d\n", r);
r = -1;
goto end0;
}
printf("create task 2\n");
if (0 != r) {
printf("fail at task_create_noautodel(), err=%d\n", r);
r = -1;
goto end1;
}
printf("\n");
printf("checking\n");
printf("\n");
printf("check point 01: ");
printf("fail\n");
r = -1;
goto end2;
}
printf("pass\n");
printf("\n");
printf("create task 1\n");
if (0 != r) {
printf("fail at task_create_noautodel(), err=%d\n", r);
r = -1;
goto end2;
}
printf("\n");
printf("checking\n");
printf("\n");
printf("check point 02: ");
printf("fail\n");
r = -1;
goto end2;
}
printf("pass\n");
printf("\n");
printf("checking\n");
printf("\n");
printf("check point 03: ");
printf("fail\n");
r = -1;
goto end2;
}
printf("pass\n");
printf("\n");
printf("checking\n");
printf("\n");
printf("check point 04: ");
printf("fail\n");
r = -1;
goto end2;
}
printf("pass\n");
printf("\n");
printf("checking\n");
printf("\n");
printf("check point 05: ");
printf("fail\n");
r = -1;
goto end2;
}
printf("pass\n");
printf("\n");
printf("checking\n");
printf("\n");
printf("check point 06: ");
printf("fail\n");
r = -1;
goto end2;
}
printf("pass\n");
printf("\n");
printf("checking\n");
printf("\n");
printf("check point 07: ");
printf("fail\n");
r = -1;
goto end2;
}
printf("pass\n");
printf("\n");
printf("checking\n");
printf("\n");
printf("check point 08: ");
printf("fail\n");
r = -1;
goto end2;
}
printf("pass\n");
printf("\n");
printf("checking\n");
printf("\n");
printf("check point 09: ");
printf("fail\n");
r = -1;
goto end2;
}
printf("pass\n");
printf("\n");
printf("checking\n");
printf("\n");
printf("check point 10: ");
printf("fail\n");
r = -1;
goto end2;
}
printf("pass\n");
printf("\n");
printf("checking\n");
printf("\n");
printf("check point 11: ");
printf("fail\n");
r = -1;
goto end2;
}
printf("pass\n");
printf("\n");
printf("checking\n");
printf("\n");
printf("check point 12: ");
printf("fail\n");
r = -1;
goto end2;
}
printf("pass\n");
printf("\n");
printf("checking\n");
printf("\n");
printf("check point 13: ");
printf("fail\n");
r = -1;
goto end2;
}
printf("pass\n");
r = 0;
end2:
if (0 != r2) {
printf("fail at task_join_and_delete(), err=%d\n", r2);
r = -1;
}
end1:
if (0 != r2) {
printf("fail at mutex_delete(), err=%d\n", r2);
r = -1;
}
}
if (0 != r2) {
printf("fail at mutex_delete(), err=%d\n", r2);
r = -1;
}
}
if (0 != r2) {
printf("fail at signal_delete(), err=%d\n", r2);
r = -1;
}
}
if (0 != r2) {
printf("fail at condv_delete(), err=%d\n", r2);
r = -1;
}
}
if (0 != r2) {
printf("fail at sem_delete(), err=%d\n", r2);
r = -1;
}
}
if (0 != r2) {
printf("fail at msgq_delete(), err=%d\n", r2);
r = -1;
}
}
end0:
r = -1;
}
else {
r = 0;
}
printf("</message>\n");
printf("<result>");
if (0 == r) {
printf("pass");
}
else {
printf("fail");
}
printf("</result>\n");
printf("</test>\n");
printf("\n");
return r;
}
#endif
#endif
void bsp_busywait(unsigned int count)
unsigned int bsp_getbusywaitcountperms(void)
int condv_delete(condv_pt *condv_p)
int condv_signal(condv_pt condv)
int condv_create(condv_pt *condv_p)
int msgq_delete(msgq_pt *msgq_p)
int msgq_send(msgq_pt msgq, unsigned char *msg)
int msgq_create(msgq_pt *msgq_p, unsigned int msgsize, unsigned int maxcount)
int mutex_unlock(mutex_pt mutex)
int mutex_create(mutex_pt *mutex_p)
int mutex_delete(mutex_pt *mutex_p)
int mutex_lock(mutex_pt mutex)
int sem_delete(sem_pt *sem_p)
int sem_create(sem_pt *sem_p)
int signal_send(signal_pt signal, int sigtype)
int signal_delete(signal_pt *signal_p)
int signal_create(signal_pt *signal_p)
stdlib (Standard Library) API
int task_setmaxwaitsigobj(task_pt task, int max)
int task_create_noautodel(task_pt *task_p, taskfunc_ft func, void *arg, int priority, unsigned int stackdepth, const char *name)
int task_join_and_delete(task_pt *task_p, int *result_p, int count)
int task_waitforsigobjs_timed(void **sigobj_p, int *sigtype_p, void **param_p, int count, unsigned int waitopt, unsigned int tick)
#define TASK_WAITOPT__ALL
Definition: task.h:332
int task_waitforsigobjs(void **sigobj_p, int *sigtype_p, void **param_p, int count, unsigned int waitopt)
int task_sleep(unsigned int tick)
int task_getpriority(task_pt task)
#define NULL
Definition: type.h:42
unsigned int ubik_ticktotimems(unsigned int tick)
#define UBIK_ERR__TIMEOUT
Definition: ubik.h:32
unsigned int ubik_timemstotick(unsigned int timems)
volatile unsigned int _g_ubik_test_count1
태스크 별 시험 진행 상황을 저장하는 전역 변수 1
task_pt _g_ubik_test_task_a[4]
시험 용 태스크 배열
volatile unsigned int _g_ubik_test_count2
태스크 별 시험 진행 상황을 저장하는 전역 변수 2
int ubik_test_tasktest07(void)
Test on wait for multiple signal objects function of task.
mutex_pt _g_ubik_test_mutex2
시험 용 뮤택스 2
condv_pt _g_ubik_test_condv
시험 용 상태변수
signal_pt _g_ubik_test_signal
시험 용 시그널
volatile unsigned int _g_ubik_test_result
시험 결과를 저장하는 전역 변수
mutex_pt _g_ubik_test_mutex
시험 용 뮤택스
sem_pt _g_ubik_test_sem
시험 용 세마포어
msgq_pt _g_ubik_test_msgq
시험 용 메시지큐