#if !(UBINOS__UBIK_TEST__EXCLUDE_TASKTESTSET3 == 1)
#include <stdio.h>
static void tasktest08_task1func(void * arg) {
int r;
int i;
unsigned int waittick =
ubik_timemstotick(UBINOS__UBIK_TEST__TASKWAITTIMEMS * UBINOS__UBIK_TEST__TASKLOOPCOUNT);
unsigned int remainingtick;
unsigned int temp;
for (i=0; i<UBINOS__UBIK_TEST__TASKLOOPCOUNT * 1; i++) {
printf("1");
}
printf("\r\n");
printf(
"task 1 waits for first signal with timeout (for %d ms)\r\n",
ubik_ticktotimems(waittick * 3));
if (0 != r) {
printf("task 1: fail at signal_wait_timed(), err=%d\r\n", r);
goto end0;
}
temp = waittick * 2;
if (temp > remainingtick) {
temp = temp - remainingtick;
}
else {
temp = remainingtick - temp;
}
temp = temp * 100 / (waittick * 2);
if (5 < temp) {
printf("task 1: return value of task_getremainingtimeout function is wrong (%d)\r\n", temp);
goto end0;
}
for (i=0; i<UBINOS__UBIK_TEST__TASKLOOPCOUNT * 1; i++) {
printf("1");
}
printf("\r\n");
remainingtick -= waittick;
printf(
"task 1 waits for second signal with timeout (for %d ms)\r\n",
ubik_ticktotimems(remainingtick));
printf("task 1: fail at signal_wait_timed(), err=%d\r\n", r);
goto end0;
}
printf("\r\n");
printf("task 1 wakes up\r\n");
if (0 != remainingtick) {
printf("task 1: return value of task_getremainingtimeout function is wrong (%d)\r\n", remainingtick);
goto end0;
}
for (i=0; i<UBINOS__UBIK_TEST__TASKLOOPCOUNT * 1; i++) {
printf("1");
}
printf("\r\n");
end0:
printf("task 1 ends\r\n");
}
static void tasktest08_task2func(void * arg) {
int r;
int i;
for (i=0; i<UBINOS__UBIK_TEST__TASKLOOPCOUNT * 2; i++) {
printf("2");
}
printf("\r\n");
printf("task 2 sends first signal\r\n");
if (0 != r) {
printf("task 2: fail at signal_send(), err=%d\r\n", r);
goto end0;
}
for (i=0; i<UBINOS__UBIK_TEST__TASKLOOPCOUNT * 2; i++) {
printf("2");
}
printf("\r\n");
end0:
printf("task 2 ends\r\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("\r\n");
printf("<test>\r\n");
printf("<name>ubik_test_tasktest08</name>\r\n");
printf("<description>Test on get remaining timeout tick function of task</description>\n\r");
printf("<message>\n\r");
if (0 != r) {
printf("fail at signal_create(), err=%d\r\n", r);
r = -1;
goto end0;
}
printf("create task 2\r\n");
if (0 != r) {
printf("fail at task_create(), err=%d\r\n", r);
r = -1;
goto end1;
}
printf("\r\n");
printf("checking\r\n");
printf("\r\n");
printf("check point 01: ");
printf("fail\r\n");
r = -1;
goto end2;
}
printf("pass\r\n");
printf("\r\n");
printf("create task 1\r\n");
if (0 != r) {
printf("fail at task_create(), err=%d\r\n", r);
r = -1;
goto end2;
}
printf("\r\n");
printf("checking\r\n");
printf("\r\n");
printf("check point 02: ");
printf("fail\r\n");
r = -1;
goto end2;
}
printf("pass\r\n");
printf("\r\n");
printf("checking\r\n");
printf("\r\n");
printf("check point 03: ");
printf("fail\r\n");
r = -1;
goto end2;
}
printf("pass\r\n");
printf("\r\n");
printf("checking\r\n");
printf("\r\n");
printf("check point 04: ");
printf("fail\r\n");
r = -1;
goto end2;
}
printf("pass\r\n");
printf("\r\n");
printf("checking\r\n");
printf("\r\n");
printf("check point 05: ");
printf("fail\r\n");
r = -1;
goto end2;
}
printf("pass\r\n");
printf("\r\n");
printf("checking\r\n");
printf("\r\n");
printf("check point 06: ");
printf("fail\r\n");
r = -1;
goto end2;
}
printf("pass\r\n");
printf("\r\n");
printf("checking\r\n");
printf("\r\n");
printf("check point 07: ");
printf("fail\r\n");
r = -1;
goto end2;
}
printf("pass\r\n");
r = 0;
end2:
if (0 != r2) {
printf("fail at task_join(), err=%d\r\n", r2);
r = -1;
}
end1:
if (0 != r2) {
printf("fail at signal_delete(), err=%d\r\n", r2);
r = -1;
}
end0:
r = -1;
}
else {
r = 0;
}
printf("</message>\n\r");
printf("<result>");
if (0 == r) {
printf("pass");
}
else {
printf("fail");
}
printf("</result>\r\n");
printf("</test>\r\n");
printf("\r\n");
return r;
}
#endif