Beispiel #1
0
static void test_task(void *arg)
{
	int ret;

	traceobj_enter(&trobj);

	traceobj_mark(&trobj, 6);

	ret = rt_sem_p(&sem, TM_INFINITE);
	traceobj_check(&trobj, ret, 0);

	traceobj_mark(&trobj, 7);

	traceobj_exit(&trobj);
}
Beispiel #2
0
static void rootTask(long a0, long a1, long a2, long a3, long a4,
		     long a5, long a6, long a7, long a8, long a9)
{
	TASK_ID tid;
	int ret, n;

	traceobj_enter(&trobj);

	qid = msgQCreate(NMESSAGES, sizeof(int), MSG_Q_PRIORITY);
	traceobj_assert(&trobj, qid != 0);

	traceobj_mark(&trobj, 3);

	ret = taskPrioritySet(taskIdSelf(), 10);
	traceobj_assert(&trobj, ret == OK);

	traceobj_mark(&trobj, 4);

	tid = taskSpawn("peerTask",
			11,
			0, 0, peerTask, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
	traceobj_assert(&trobj, tid != ERROR);

	traceobj_mark(&trobj, 5);

	n = 0;
	do
		ret = msgQSend(qid, (char *)&messages[n], sizeof(int), NO_WAIT, MSG_PRI_URGENT);
	while(n++ < NMESSAGES && ret != ERROR);

	traceobj_assert(&trobj, ret == ERROR && errno == S_objLib_OBJ_UNAVAILABLE && n == NMESSAGES + 1);

	traceobj_mark(&trobj, 6);

	ret = taskDelay(10);
	traceobj_assert(&trobj, ret == OK);

	traceobj_mark(&trobj, 7);

	ret = msgQNumMsgs(qid);
	traceobj_assert(&trobj, ret == 0);

	traceobj_verify(&trobj, tseq, sizeof(tseq) / sizeof(int));

	traceobj_exit(&trobj);
}
Beispiel #3
0
static void rootTask(long a0, long a1, long a2, long a3, long a4,
		     long a5, long a6, long a7, long a8, long a9)
{
	int ret, msg, n;

	traceobj_enter(&trobj);

	traceobj_mark(&trobj, 1);

	qid = msgQCreate(NMESSAGES, sizeof(msg), MSG_Q_FIFO);
	traceobj_assert(&trobj, qid != 0);

	traceobj_mark(&trobj, 2);

	for (msg = 0; msg < NMESSAGES; msg++) {
		ret = msgQSend(qid, (char *)&msg, sizeof(msg), NO_WAIT, MSG_PRI_NORMAL);
		traceobj_assert(&trobj, ret == OK);
	}

	traceobj_mark(&trobj, 3);

	ret = msgQSend(qid, (char *)&msg, sizeof(msg), WAIT_FOREVER, MSG_PRI_URGENT);
	traceobj_assert(&trobj, ret == OK);

	traceobj_mark(&trobj, 4);

	ret = msgQReceive(qid, (char *)&msg, sizeof(int), WAIT_FOREVER);
	traceobj_assert(&trobj, ret == sizeof(int) && msg == 10);

	traceobj_mark(&trobj, 5);

	for (n = 1; n < NMESSAGES; n++) { /* peer task read #0 already. */
		ret = msgQReceive(qid, (char *)&msg, sizeof(int), WAIT_FOREVER);
		traceobj_assert(&trobj, ret == sizeof(int) && msg == n);
	}

	traceobj_mark(&trobj, 6);

	ret = msgQReceive(qid, (char *)&msg, sizeof(int), WAIT_FOREVER);
	traceobj_assert(&trobj, ret == ERROR && errno == S_objLib_OBJ_DELETED);

	traceobj_mark(&trobj, 7);

	traceobj_exit(&trobj);
}
Beispiel #4
0
static void peerTask(long a0, long a1, long a2, long a3, long a4,
		     long a5, long a6, long a7, long a8, long a9)
{
	int ret, msg, n;

	traceobj_enter(&trobj);

	n = 1;
	do {
		traceobj_mark(&trobj, 1);
		ret = msgQReceive(qid, (char *)&msg, sizeof(int), NO_WAIT);
		traceobj_assert(&trobj, ret == sizeof(int));
		traceobj_assert(&trobj, msg == messages[NMESSAGES - n]);
		traceobj_mark(&trobj, 2);
	} while(n++ < NMESSAGES);

	traceobj_exit(&trobj);
}
Beispiel #5
0
static void rr_task(void *arg)
{
	int ret, n;

	traceobj_enter(&trobj);

	ret = rt_task_slice(NULL, RR_QUANTUM);
	traceobj_check(&trobj, ret, 0);

	ret = rt_sem_p(&sem, TM_INFINITE);
	traceobj_check(&trobj, ret, 0);

	for (n = 0; n < 1000000; n++) {
		d *= 0.99;
		f = d / 16;
	}

	traceobj_exit(&trobj);
}
Beispiel #6
0
static void rootTask(long a0, long a1, long a2, long a3, long a4,
		     long a5, long a6, long a7, long a8, long a9)
{
	ULONG start;
	int ret;

	traceobj_enter(&trobj);

	sem_id = semCCreate(SEM_Q_PRIORITY, 0);
	traceobj_assert(&trobj, sem_id != 0);

	start = tickGet();
	ret = semTake(sem_id, WAIT_TIME);
	traceobj_assert(&trobj, ret == ERROR && errno == S_objLib_OBJ_TIMEOUT);
	traceobj_assert(&trobj, tickGet() - start >= MIN_WAIT);

	start = tickGet();
	ret = semTake(sem_id, WAIT_TIME);
	traceobj_assert(&trobj, ret == ERROR && errno == S_objLib_OBJ_TIMEOUT);
	traceobj_assert(&trobj, tickGet() - start >= MIN_WAIT);

	start = tickGet();
	ret = semTake(sem_id, WAIT_TIME);
	traceobj_assert(&trobj, ret == ERROR && errno == S_objLib_OBJ_TIMEOUT);
	traceobj_assert(&trobj, tickGet() - start >= MIN_WAIT);

	ret = semGive(sem_id);
	traceobj_assert(&trobj, ret == OK);
	ret = semTake(sem_id, WAIT_TIME);
	traceobj_assert(&trobj, ret == OK);
	ret = semGive(sem_id);
	traceobj_assert(&trobj, ret == OK);
	ret = semGive(sem_id);
	traceobj_assert(&trobj, ret == OK);
	ret = semTake(sem_id, WAIT_FOREVER);
	traceobj_assert(&trobj, ret == OK);
	ret = semTake(sem_id, WAIT_FOREVER);
	traceobj_assert(&trobj, ret == OK);

	traceobj_exit(&trobj);
}
Beispiel #7
0
static void peerTask(long a0, long a1, long a2, long a3, long a4,
		     long a5, long a6, long a7, long a8, long a9)
{
	int ret, msg;

	traceobj_enter(&trobj);

	traceobj_mark(&trobj, 8);

	ret = msgQReceive(qid, (char *)&msg, sizeof(int), WAIT_FOREVER);
	traceobj_assert(&trobj, ret == sizeof(int) && msg == 0);

	traceobj_mark(&trobj, 9);

	ret = msgQDelete(qid);
	traceobj_assert(&trobj, ret == OK);

	traceobj_mark(&trobj, 10);

	traceobj_exit(&trobj);
}
Beispiel #8
0
static void task(u_long a0, u_long a1, u_long a2, u_long a3)
{
	u_long events;
	int ret;

	traceobj_enter(&trobj);

	traceobj_mark(&trobj, 1);

	ret = tm_evafter(200, 0x1, &timer_id);
	traceobj_assert(&trobj, ret == SUCCESS);

	traceobj_mark(&trobj, 2);

	ret = ev_receive(0x3, EV_WAIT|EV_ALL, 300, &events);
	traceobj_assert(&trobj, ret == ERR_TIMEOUT);
	traceobj_mark(&trobj, 3);

	ret = ev_receive(0x2, EV_NOWAIT|EV_ANY, 0, &events);
	traceobj_assert(&trobj, ret == ERR_NOEVS);
	traceobj_mark(&trobj, 4);

	events = 0;
	ret = ev_receive(0x1, EV_NOWAIT|EV_ALL, 0, &events);
	traceobj_assert(&trobj, ret == SUCCESS && events == 0x1);
	traceobj_mark(&trobj, 5);

	events = 0;
	ret = ev_receive(0x1, EV_WAIT|EV_ALL, 400, &events);
	traceobj_assert(&trobj, ret == ERR_TIMEOUT);
	traceobj_mark(&trobj, 6);

	ret = tm_cancel(timer_id);
	traceobj_assert(&trobj, ret == ERR_BADTMID);

	traceobj_exit(&trobj);
}
Beispiel #9
0
static void peerTask(long a0, long a1, long a2, long a3, long a4,
		     long a5, long a6, long a7, long a8, long a9)
{
	TASK_ID rtid;
	int ret;

	traceobj_enter(&trobj);

	traceobj_mark(&trobj, 1);

	rtid = taskNameToId("rootTask");
	traceobj_assert(&trobj, rtid != ERROR);

	traceobj_mark(&trobj, 2);

	ret = semTake(sem_id, NO_WAIT);
	traceobj_assert(&trobj, ret == ERROR && errno == S_objLib_OBJ_UNAVAILABLE);

	traceobj_mark(&trobj, 3);

	ret = semTake(sem_id, 100);
	traceobj_assert(&trobj, ret == ERROR && errno == S_objLib_OBJ_TIMEOUT);

	traceobj_mark(&trobj, 4);

	ret = taskResume(rtid);
	traceobj_assert(&trobj, ret == OK);

	traceobj_mark(&trobj, 5);

	ret = semTake(sem_id, WAIT_FOREVER);
	traceobj_assert(&trobj, ret == OK);

	traceobj_mark(&trobj, 6);

	traceobj_exit(&trobj);
}
Beispiel #10
0
static void task(u_long a0, u_long a1, u_long a2, u_long a3)
{
	unsigned long date, time, ticks;
	int ret;

	traceobj_enter(&trobj);

	traceobj_mark(&trobj, 3);

	ret = tm_set(TEST_DATE, TEST_TIME, TEST_TICKS);
	traceobj_assert(&trobj, ret == SUCCESS);

	ret = tm_wkwhen(WAKEUP_DATE, WAKEUP_TIME, WAKEUP_TICKS);
	traceobj_assert(&trobj, ret == SUCCESS);

	ret = tm_get(&date, &time, &ticks);
	traceobj_assert(&trobj, ret == SUCCESS);
	traceobj_assert(&trobj, date == WAKEUP_DATE);
	traceobj_assert(&trobj, time == WAKEUP_TIME);

	traceobj_mark(&trobj, 4);

	traceobj_exit(&trobj);
}
Beispiel #11
0
static void rootTask(long a0, long a1, long a2, long a3, long a4,
		     long a5, long a6, long a7, long a8, long a9)
{
	int j, res, k, chunks;
	const int putBytes = 10;
	const int nrChunks = 3;
	const int rngBytes = putBytes * nrChunks;
	char buffer[putBytes];
	char bigBuffer[putBytes * 2 * nrChunks];
	int bytesPut;
	int bytesGot;
	int expectedCounter = 0;
	int checkCounter = 0;
	RING_ID rng;
	char not_a_ring[32];

	traceobj_enter(&trobj);
	ADD_CONTENT(buffer, sizeof(buffer), expectedCounter);
	rng = rngCreate(1);
	traceobj_assert(&trobj, rngIsEmpty(rng));
	memset(buffer, 0, sizeof(buffer));
	buffer[0] = 17;
	rngBufPut(rng, buffer, 1);
	traceobj_assert(&trobj, rngIsFull(rng));
	rngBufGet(rng, buffer, 1);
	traceobj_assert(&trobj, rngIsEmpty(rng));
	buffer[0] = 34;
	rngBufPut(rng, buffer, 1);
	traceobj_assert(&trobj, rngIsFull(rng));
	expectedCounter = 0;
	rngDelete(rng);

	/* Here real vxWorks 6.6 just return ERROR */
	memset(not_a_ring, 0, sizeof(not_a_ring));
	errnoSet(0);
	res = rngBufPut((RING_ID) & not_a_ring[0], buffer, 1);
	traceobj_assert(&trobj, res == ERROR);

/*	rng = rngCreate(1 * 1024 * 1024 * 1024);
	traceobj_assert(&trobj, res == ERROR);
	traceobj_assert(&trobj, errnoGet() == S_memLib_NOT_ENOUGH_MEMORY);
 */
	rng = rngCreate(rngBytes);
	traceobj_assert(&trobj, rng != 0);
	traceobj_assert(&trobj, rngIsEmpty(rng));
	traceobj_assert(&trobj, !rngIsFull(rng));

	/* Fill a few chunks */
	for (chunks = 0; chunks < nrChunks; chunks++) {
		traceobj_assert(&trobj,
				rngNBytes(rng) == chunks * (int)sizeof(buffer));
		traceobj_assert(&trobj,
				rngFreeBytes(rng) ==
				rngBytes - chunks * (int)sizeof(buffer));
		for (j = 0; j < (int)sizeof(buffer); j++) {
			buffer[j] = (char)j + (int)sizeof(buffer) * chunks;
		}
		ADD_CONTENT(buffer, sizeof(buffer), checkCounter);
		bytesPut = rngBufPut(rng, &buffer[0], sizeof(buffer));
		traceobj_assert(&trobj, bytesPut == sizeof(buffer));
		traceobj_assert(&trobj, !rngIsEmpty(rng));
		traceobj_assert(&trobj,
				rngIsFull(rng) == (nrChunks - 1 == chunks));
		traceobj_assert(&trobj,
				rngFreeBytes(rng) ==
				rngBytes - bytesPut * (chunks + 1));
		traceobj_assert(&trobj,
				rngNBytes(rng) ==
				(chunks + 1) * (int)sizeof(buffer));
	}
	traceobj_assert(&trobj, rngIsFull(rng));
	ADD_CONTENT(buffer, sizeof(buffer), checkCounter);
	bytesPut = rngBufPut(rng, &buffer[0], sizeof(buffer));
	traceobj_assert(&trobj, bytesPut == 0);
	traceobj_assert(&trobj, rngIsFull(rng));

	/* Read chunks back and check content */
	for (chunks = 0; chunks < nrChunks; chunks++) {
		memset(buffer, 0, sizeof(buffer));
		traceobj_assert(&trobj,
				rngNBytes(rng) ==
				(nrChunks - chunks) * (int)sizeof(buffer));
		traceobj_assert(&trobj,
				rngFreeBytes(rng) ==
				chunks * (int)sizeof(buffer));
		bytesGot = rngBufGet(rng, &buffer[0], sizeof(buffer));
		traceobj_assert(&trobj, bytesGot == (int)sizeof(buffer));
		CHECK_CONTENT(buffer, bytesGot, expectedCounter);
		traceobj_assert(&trobj, !rngIsFull(rng));
		traceobj_assert(&trobj,
				rngIsEmpty(rng) == (chunks == nrChunks - 1));

		traceobj_assert(&trobj,
				rngFreeBytes(rng) ==
				(chunks + 1) * (int)sizeof(buffer));
		traceobj_assert(&trobj,
				rngNBytes(rng) ==
				(nrChunks - chunks - 1) * (int)sizeof(buffer));
	}

	/* Testing filling too many */
	ADD_CONTENT(bigBuffer, sizeof(bigBuffer), checkCounter)
	bytesPut = rngBufPut(rng, &bigBuffer[0], sizeof(bigBuffer));
	traceobj_assert(&trobj, bytesPut == rngBytes);
	traceobj_assert(&trobj, !rngIsEmpty(rng));
	traceobj_assert(&trobj, rngIsFull(rng));
	traceobj_assert(&trobj, rngFreeBytes(rng) == 0);
	traceobj_assert(&trobj, rngNBytes(rng) == rngBytes);

	/* Getting too many */
	memset(bigBuffer, 0, sizeof(bigBuffer));
	bytesGot = rngBufGet(rng, &bigBuffer[0], sizeof(bigBuffer));
	traceobj_assert(&trobj, bytesGot == rngBytes);
	traceobj_assert(&trobj, rngIsEmpty(rng));
	traceobj_assert(&trobj, !rngIsFull(rng));
	traceobj_assert(&trobj, rngFreeBytes(rng) == rngBytes);
	traceobj_assert(&trobj, rngNBytes(rng) == 0);

	/* Now we need to adjust our expectedCounter */
	expectedCounter += sizeof(buffer);

	CHECK_CONTENT(bigBuffer, bytesGot, expectedCounter);

	ADD_CONTENT(bigBuffer, sizeof(bigBuffer), checkCounter);
	bytesPut = rngBufPut(rng, &bigBuffer[0], sizeof(bigBuffer));
	traceobj_assert(&trobj, bytesPut == rngBytes);
	rngFlush(rng);
	traceobj_assert(&trobj, rngIsEmpty(rng));
	traceobj_assert(&trobj, !rngIsFull(rng));
	traceobj_assert(&trobj, rngFreeBytes(rng) == rngBytes);
	traceobj_assert(&trobj, rngNBytes(rng) == 0);
	while (bytesGot > 0) {
		bytesGot = rngBufGet(rng, &bigBuffer[0], sizeof(bigBuffer));
		CHECK_CONTENT(bigBuffer, bytesGot, expectedCounter);
	}
	rngDelete(rng);

	chunks = 10;
	rng = rngCreate(chunks);
	bytesPut = 5;
	traceobj_assert(&trobj, rngFreeBytes(rng) > bytesPut);
	checkCounter = 0xaa;
	expectedCounter = checkCounter;
	for (j = 0; j < bytesPut; j++) {
		rngPutAhead(rng, checkCounter, j);
		checkCounter++;
	}
	rngMoveAhead(rng, bytesPut);
	bytesGot = rngBufGet(rng, &bigBuffer[0], sizeof(bigBuffer));
	traceobj_assert(&trobj, bytesGot == bytesPut);
	CHECK_CONTENT(bigBuffer, bytesGot, expectedCounter);

	/* Check also wrap-around */
	bytesPut = chunks -2;
	traceobj_assert(&trobj, rngFreeBytes(rng) > bytesPut);
	checkCounter = 0xaa;
	expectedCounter = checkCounter;
	for (j = 0; j < bytesPut; j++) {
		rngPutAhead(rng, checkCounter, j);
		checkCounter++;
	}
	rngMoveAhead(rng, bytesPut);
	bytesGot = rngBufGet(rng, &bigBuffer[0], sizeof(bigBuffer));
	traceobj_assert(&trobj, bytesGot == bytesPut);
	CHECK_CONTENT(bigBuffer, bytesGot, expectedCounter);
	rngDelete(rng);

	traceobj_exit(&trobj);
}
Beispiel #12
0
static void main_task(void *arg)
{
	traceobj_enter(&trobj);
	traceobj_assert(&trobj, arg == (void *)(long)0xdeadbeef);
	traceobj_exit(&trobj);
}
Beispiel #13
0
static void rootTask(long a0, long a1, long a2, long a3, long a4,
		     long a5, long a6, long a7, long a8, long a9)
{
	int ret;

	traceobj_enter(&trobj);

	traceobj_mark(&trobj, 6);

	ret = taskPrioritySet(taskIdSelf(), 11);
	traceobj_assert(&trobj, ret == OK);

	traceobj_mark(&trobj, 7);

	sem_id = semMCreate(0xffffffff);
	traceobj_assert(&trobj, sem_id == 0 && errno == S_semLib_INVALID_OPTION);

	traceobj_mark(&trobj, 8);

	sem_id = semMCreate(SEM_Q_PRIORITY|SEM_DELETE_SAFE|SEM_INVERSION_SAFE);
	traceobj_assert(&trobj, sem_id != 0);

	traceobj_mark(&trobj, 9);

	ret = semTake(sem_id, WAIT_FOREVER);
	traceobj_assert(&trobj, ret == OK);

	traceobj_mark(&trobj, 10);

	ret = semTake(sem_id, WAIT_FOREVER);
	traceobj_assert(&trobj, ret == OK);

	traceobj_mark(&trobj, 11);

	ret = semGive(sem_id);
	traceobj_assert(&trobj, ret == OK);

	traceobj_mark(&trobj, 12);

	ret = semGive(sem_id);
	traceobj_assert(&trobj, ret == OK);

	traceobj_mark(&trobj, 13);

	ret = semGive(sem_id);
	traceobj_assert(&trobj, ret == ERROR && errno == S_semLib_INVALID_OPERATION);

	traceobj_mark(&trobj, 14);

	ret = semTake(sem_id, WAIT_FOREVER);
	traceobj_assert(&trobj, ret == OK);

	traceobj_mark(&trobj, 15);

	ret = taskSuspend(taskIdSelf());
	traceobj_assert(&trobj, ret == OK);

	traceobj_mark(&trobj, 16);

	ret = semGive(sem_id);
	traceobj_assert(&trobj, ret == OK);

	traceobj_mark(&trobj, 17);

	traceobj_exit(&trobj);
}