当前位置: 首页>>代码示例>>C++>>正文


C++ TC_ERROR函数代码示例

本文整理汇总了C++中TC_ERROR函数的典型用法代码示例。如果您正苦于以下问题:C++ TC_ERROR函数的具体用法?C++ TC_ERROR怎么用?C++ TC_ERROR使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了TC_ERROR函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: pipePutTest

int pipePutTest(void)
{
	int  rv;    /* return value from pipePutTestWork() */

	rv = pipePutTestWork(all_N, ARRAY_SIZE(all_N),
						 many_all_N, ARRAY_SIZE(many_all_N));
	if (rv != TC_PASS) {
		TC_ERROR("Failed on _ALL_N/many_ALL_N test\n");
		return TC_FAIL;
	}

	rv = pipePutTestWork(one_to_N, ARRAY_SIZE(one_to_N),
						 many_one_to_N, ARRAY_SIZE(many_one_to_N));
	if (rv != TC_PASS) {
		TC_ERROR("Failed on _1_TO_N/many_1_TO_N test\n");
		return TC_FAIL;
	}

	rv = pipePutTestWork(zero_to_N, ARRAY_SIZE(zero_to_N),
						 many_zero_to_N, ARRAY_SIZE(many_zero_to_N));
	if (rv != TC_PASS) {
		TC_ERROR("Failed on _0_TO_N/many_0_TO_N test\n");
		return TC_FAIL;
	}

	return TC_PASS;
}
开发者ID:01org,项目名称:CODK-A-Firmware,代码行数:27,代码来源:pipe.c

示例2: HighPriTask

int HighPriTask(void)
{
	int  status;

	/* Wait until task is activated */
	status = task_sem_take(hpSem, TICKS_UNLIMITED);
	if (status != RC_OK) {
		TC_ERROR("%s priority task failed to wait on %s: %d\n",
				 "High", "HIGH_PRI_SEM", status);
		return TC_FAIL;
	}

	/* Wait on a semaphore along with other tasks */
	status = task_sem_take(manyBlockSem, TICKS_UNLIMITED);
	if (status != RC_OK) {
		TC_ERROR("%s priority task failed to wait on %s: %d\n",
				 "High", "MANY_BLOCKED_SEM", status);
		return TC_FAIL;
	}

	/* Inform Regression test HP task is no longer blocked on MANY_BLOCKED_SEM*/
	task_sem_give(blockHpSem);

	return TC_PASS;

}
开发者ID:32bitmicro,项目名称:zephyr,代码行数:26,代码来源:sema.c

示例3: testLowTimerGet

int testLowTimerGet(void)
{
	int  i;
	int  j;
	int  k;

	for (j = 0; j < 2; j++) {
		for (i = 0; i < NTIMERS; i++) {
			pTimer[i] = task_timer_alloc();

			for (k = 0; k < i; k++) {
				if (pTimer[i] == pTimer[k]) {
					TC_ERROR("** task_timer_alloc() did not return a unique "
							"timer ID.\n");
					return TC_FAIL;
				}
			}
		}

		/* Whitebox test to ensure that all timers were allocated. */

		if (_k_timer_free.list != NULL) {
			TC_ERROR("** Not all timers were allocated!\n");
		}

		for (i = 0; i < NTIMERS; i++) {
			task_timer_free(pTimer[i]);
		}
	}

	return TC_PASS;
}
开发者ID:01org,项目名称:CODK-A-Firmware,代码行数:32,代码来源:timer.c

示例4: testSemFiberNoWait

int testSemFiberNoWait(void)
{
	int  i;

	TC_PRINT("Giving and taking a semaphore in a fiber (non-blocking)\n");

	/*
	 * Give the semaphore many times and then make sure that it can only be
	 * taken that many times.
	 */

	for (i = 0; i < 32; i++) {
		nano_fiber_sem_give(&testSem);
	}

	for (i = 0; i < 32; i++) {
		if (nano_fiber_sem_take(&testSem) != 1) {
			TC_ERROR(" *** Expected nano_fiber_sem_take() to succeed, not fail\n");
			goto errorReturn;
		}
	}

	if (nano_fiber_sem_take(&testSem) != 0) {
		TC_ERROR(" *** Expected  nano_fiber_sem_take() to fail, not succeed\n");
		goto errorReturn;
	}

	return TC_PASS;

errorReturn:
	fiberDetectedFailure = 1;
	return TC_FAIL;
}
开发者ID:01org,项目名称:CODK-A-Firmware,代码行数:33,代码来源:sema.c

示例5: testSemTaskNoWait

int testSemTaskNoWait(void)
{
	int  i;     /* loop counter */

	TC_PRINT("Giving and taking a semaphore in a task (non-blocking)\n");

	/*
	 * Give the semaphore many times and then make sure that it can only be
	 * taken that many times.
	 */

	for (i = 0; i < 32; i++) {
		nano_task_sem_give(&testSem);
	}

	for (i = 0; i < 32; i++) {
		if (nano_task_sem_take(&testSem) != 1) {
			TC_ERROR(" *** Expected nano_task_sem_take() to succeed, not fail\n");
			goto errorReturn;
		}
	}

	if (nano_task_sem_take(&testSem) != 0) {
		TC_ERROR(" *** Expected  nano_task_sem_take() to fail, not succeed!\n");
		goto errorReturn;
	}

	return TC_PASS;

errorReturn:
	return TC_FAIL;
}
开发者ID:01org,项目名称:CODK-A-Firmware,代码行数:32,代码来源:sema.c

示例6: idt_stub_test

int idt_stub_test(void)
{
	struct segment_descriptor *p_idt_entry;
	u32_t offset;

	/* Check for the interrupt stub */
	p_idt_entry = (struct segment_descriptor *)
		      (_idt_base_address + (TEST_SOFT_INT << 3));
	offset = (u32_t)(&int_stub);
	if (DTE_OFFSET(p_idt_entry) != offset) {
		TC_ERROR("Failed to find offset of int_stub (0x%x) at vector %d\n",
			 offset, TEST_SOFT_INT);
		return TC_FAIL;
	}

	/* Check for the exception stub */
	p_idt_entry = (struct segment_descriptor *)
		      (_idt_base_address + (IV_DIVIDE_ERROR << 3));
	offset = (u32_t)(&_EXCEPTION_STUB_NAME(exc_divide_error_handler, 0));
	if (DTE_OFFSET(p_idt_entry) != offset) {
		TC_ERROR("Failed to find offset of exc stub (0x%x) at vector %d\n",
			 offset, IV_DIVIDE_ERROR);
		return TC_FAIL;
	}

	/*
	 * If the other fields are wrong, the system will crash when the exception
	 * and software interrupt are triggered so we don't check them.
	 */
	return TC_PASS;
}
开发者ID:bboozzoo,项目名称:zephyr,代码行数:31,代码来源:static_idt.c

示例7: do_test_multiple_waiters

static int do_test_multiple_waiters(void)
{
	int ii;

	/* pend all fibers one the same lifo */
	for (ii = 0; ii < NUM_WAITERS; ii++) {
		task_fiber_start(fiber_multi_waiters_stacks[ii], FIBER_STACKSIZE,
						 fiber_multi_waiters, ii, 0, FIBER_PRIORITY, 0);
	}

	/* wake up all the fibers: the task is preempted each time */
	for (ii = 0; ii < NUM_WAITERS; ii++) {
		nano_task_lifo_put(&multi_waiters, &multi_waiters_items[ii]);
	}

	/* reply_multi_waiters will have been given once for each fiber */
	for (ii = 0; ii < NUM_WAITERS; ii++) {
		if (!nano_task_sem_take(&reply_multi_waiters, TICKS_NONE)) {
			TC_ERROR(" *** Cannot take sem supposedly given by waiters.\n");
			return TC_FAIL;
		}
	}

	TC_PRINT("Task took multi-waiter reply semaphore %d times, as expected.\n",
			 NUM_WAITERS);

	if (nano_task_lifo_get(&multi_waiters, TICKS_NONE)) {
		TC_ERROR(" *** multi_waiters should have been empty.\n");
		return TC_FAIL;
	}

	return TC_PASS;
}
开发者ID:32bitmicro,项目名称:zephyr,代码行数:33,代码来源:lifo.c

示例8: testSemWait

int testSemWait(void)
{
	if (fiberDetectedFailure != 0) {
		TC_ERROR(" *** Failure detected in the fiber.");
		return TC_FAIL;
	}

	nano_task_sem_give(&testSem);    /* Wake the fiber. */

	if (semTestState != STS_TASK_WOKE_FIBER) {
		TC_ERROR(" *** Expected task to wake fiber.  It did not.\n");
		return TC_FAIL;
	}

	TC_PRINT("Semaphore from the task woke the fiber\n");

	nano_task_sem_take_wait(&testSem);   /* Wait on <testSem> */

	if (semTestState != STS_FIBER_WOKE_TASK) {
		TC_ERROR(" *** Expected fiber to wake task.  It did not.\n");
		return TC_FAIL;
	}

	TC_PRINT("Semaphore from the fiber woke the task\n");

	nano_task_sem_take_wait(&testSem);  /* Wait on <testSem> again. */

	if (semTestState != STS_ISR_WOKE_TASK) {
		TC_ERROR(" *** Expected ISR to wake task.  It did not.\n");
		return TC_FAIL;
	}

	TC_PRINT("Semaphore from the ISR woke the task.\n");
	return TC_PASS;
}
开发者ID:01org,项目名称:CODK-A-Firmware,代码行数:35,代码来源:sema.c

示例9: pool_block_get_wait_test

int pool_block_get_wait_test(void)
{
	int rv;

	rv = k_mem_pool_alloc(&POOL_ID, &block_list[0], 3000, K_FOREVER);
	if (rv != 0) {
		TC_ERROR("k_mem_pool_alloc(3000) expected %d, got %d\n", 0, rv);
		return TC_FAIL;
	}

	k_sem_give(&ALTERNATE_SEM);    /* Wake alternate_task */
	evidence = 0;
	rv = k_mem_pool_alloc(&POOL_ID, &block_list[1], 128, K_FOREVER);
	if (rv != 0) {
		TC_ERROR("k_mem_pool_alloc(128) expected %d, got %d\n", 0, rv);
		return TC_FAIL;
	}

	switch (evidence) {
	case 0:
		TC_ERROR("k_mem_pool_alloc(128) did not block!\n");
		return TC_FAIL;
	case 1:
		break;
	case 2:
	default:
		TC_ERROR("Rescheduling did not occur "
			 "after k_mem_pool_free()\n");
		return TC_FAIL;
	}

	k_mem_pool_free(&block_list[1]);

	return TC_PASS;
}
开发者ID:bboozzoo,项目名称:zephyr,代码行数:35,代码来源:pool.c

示例10: fiber1

void fiber1(void)
{
	void   *pData;      /* pointer to FIFO object get from the queue */
	int     count = 0;  /* counter */

	/* Wait for fiber1 to be activated. */
	nano_fiber_sem_take_wait(&nanoSemObj1);

	/* Wait for data to be added to <nanoFifoObj> by task */
	pData = nano_fiber_fifo_get_wait(&nanoFifoObj);
	if (pData != pPutList1[0]) {
		TC_ERROR("fiber1 (1) - expected 0x%x, got 0x%x\n",
				 pPutList1[0], pData);
		retCode = TC_FAIL;
		return;
	}

	/* Wait for data to be added to <nanoFifoObj2> by fiber3 */
	pData = nano_fiber_fifo_get_wait(&nanoFifoObj2);
	if (pData != pPutList2[0]) {
		TC_ERROR("fiber1 (2) - expected 0x%x, got 0x%x\n",
				 pPutList2[0], pData);
		retCode = TC_FAIL;
		return;
	}

	nano_fiber_sem_take_wait(&nanoSemObj1);   /* Wait for fiber1 to be reactivated */

	TC_PRINT("Test Fiber FIFO Get\n\n");
	/* Get all FIFOs */
	while ((pData = nano_fiber_fifo_get(&nanoFifoObj)) != NULL) {
		TC_PRINT("FIBER FIFO Get: count = %d, ptr is %p\n", count, pData);
		if ((count >= NUM_FIFO_ELEMENT) || (pData != pPutList1[count])) {
			TCERR1(count);
			retCode = TC_FAIL;
			return;
		}
		count++;
	}

	TC_END_RESULT(retCode);
	PRINT_LINE;

	/*
	 * Entries in the FIFO queue have to be unique.
	 * Put data.
	 */
	TC_PRINT("Test Fiber FIFO Put\n");
	TC_PRINT("\nFIBER FIFO Put Order: ");
	for (int i=0; i<NUM_FIFO_ELEMENT; i++) {
		nano_fiber_fifo_put(&nanoFifoObj, pPutList2[i]);
		TC_PRINT(" %p,", pPutList2[i]);
	}
	TC_PRINT("\n");
	PRINT_LINE;

	/* Give semaphore to allow the main task to run */
	nano_fiber_sem_give(&nanoSemObjTask);

} /* fiber1 */
开发者ID:01org,项目名称:CODK-A-Firmware,代码行数:60,代码来源:fifo.c

示例11: pipeGetWaitTest

int pipeGetWaitTest(void)
{
	int  rv;         /* return code from pipeGetWaitTestWork() */
	int  bytesRead;  /* # of bytes read from task_pipe_get_waitait() */

	task_sem_give(altSem);   /* Wake AlternateTask */

	rv = pipeGetWaitTestWork(wait_all_N, ARRAY_SIZE(wait_all_N));
	if (rv != TC_PASS) {
		TC_ERROR("Failed on _ALL_N test\n");
		return TC_FAIL;
	}

	rv = pipeGetWaitTestWork(wait_one_to_N, ARRAY_SIZE(wait_one_to_N));
	if (rv != TC_PASS) {
		TC_ERROR("Failed on _1_TO_N test\n");
		return TC_FAIL;
	}

	rv = task_pipe_get_wait(pipeId, rxBuffer, PIPE_SIZE,
							&bytesRead, _0_TO_N);
	if (rv != RC_FAIL) {
		TC_ERROR("Expected return code of %d, not %d\n", RC_FAIL, rv);
		return TC_FAIL;
	}

	return TC_PASS;
}
开发者ID:01org,项目名称:CODK-A-Firmware,代码行数:28,代码来源:pipe.c

示例12: pipePutTimeoutHelper

int pipePutTimeoutHelper(void)
{
	int  i;         /* loop counter */
	int  rv;        /* return value from task_pipe_get_wait_timeout() */
	int  bytesRead; /* # of bytes read from task_pipe_get_wait_timeout() */

	(void)task_sem_take_wait(altSem);    /* Wait until test is ready */

	/* 1. task_pipe_get_wait_timeout() will force a context switch to RegressionTask() */
	rv = task_pipe_get_wait_timeout(pipeId, rxBuffer, PIPE_SIZE,
									&bytesRead, _ALL_N, ONE_SECOND);
	if ((rv != RC_OK) || (bytesRead != PIPE_SIZE)) {
		TC_ERROR("Expected return code %d, not %d\n"
				 "Expected %d bytes to be read, not %d\n",
				 RC_OK, rv, PIPE_SIZE, bytesRead);
		return TC_FAIL;
	}

	/* 2. task_pipe_get_wait_timeout() will force a context switch to RegressionTask(). */
	rv = task_pipe_get_wait_timeout(pipeId, rxBuffer, PIPE_SIZE,
									&bytesRead, _1_TO_N, ONE_SECOND);
	if ((rv != RC_OK) || (bytesRead != PIPE_SIZE)) {
		TC_ERROR("Expected return code %d, not %d\n"
				 "Expected %d bytes to be read, not %d\n",
				 RC_OK, rv, PIPE_SIZE, bytesRead);
		return TC_FAIL;
	}

	/*
	 * Before emptying the pipe, check that task_pipe_get_wait_timeout() fails when
	 * using the _0_TO_N option.
	 */

	rv = task_pipe_get_wait_timeout(pipeId, rxBuffer, PIPE_SIZE / 2,
									&bytesRead, _0_TO_N, ONE_SECOND);
	if (rv != RC_FAIL) {
		TC_ERROR("Expected return code %d, not %d\n", RC_FAIL, rv);
		return TC_FAIL;
	}

	/* 3. Empty the pipe in two reads */
	for (i = 0; i < 2; i++) {
		rv = task_pipe_get(pipeId, rxBuffer, PIPE_SIZE / 2,
						   &bytesRead, _0_TO_N);
		if ((rv != RC_OK) || (bytesRead != PIPE_SIZE / 2)) {
			TC_ERROR("Expected return code %d, not %d\n"
					 "Expected %d bytes to be read, not %d\n",
					 RC_OK, rv, PIPE_SIZE / 2, bytesRead);
			return TC_FAIL;
		}
	}

	task_sem_give(regSem);

	return TC_PASS;
}
开发者ID:01org,项目名称:CODK-A-Firmware,代码行数:56,代码来源:pipe.c

示例13: testMapGetAllBlocks

int testMapGetAllBlocks(void **p)
{
	int retValue;  /* task_mem_map_xxx interface return value */
	void *errPtr;  /* Pointer to block */

	TC_PRINT("Function %s\n", __func__);

	/* Number of blocks in the map is defined in MDEF file */
	for (int i = 0; i < NUMBLOCKS; i++) {
		/* Verify number of used blocks in the map */
		retValue = task_mem_map_used_get(MAP_LgBlks);
		if (verifyRetValue(i, retValue)) {
			TC_PRINT("MAP_LgBlks used %d blocks\n", retValue);
		} else {
			TC_ERROR("Failed task_mem_map_used_get for MAP_LgBlks, i=%d, retValue=%d\n",
				i, retValue);
			return TC_FAIL;
		}

		/* Get memory block */
		retValue = task_mem_map_alloc(MAP_LgBlks, &p[i], TICKS_NONE);
		if (verifyRetValue(RC_OK, retValue)) {
			TC_PRINT("  task_mem_map_alloc OK, p[%d] = %p\n", i, p[i]);
		} else {
			TC_ERROR("Failed task_mem_map_alloc, i=%d, retValue %d\n",
				i, retValue);
			return TC_FAIL;
		}

	} /* for */

	/* Verify number of used blocks in the map - expect all blocks are used */
	retValue = task_mem_map_used_get(MAP_LgBlks);
	if (verifyRetValue(NUMBLOCKS, retValue)) {
		TC_PRINT("MAP_LgBlks used %d blocks\n", retValue);
	} else {
		TC_ERROR("Failed task_mem_map_used_get for MAP_LgBlks, retValue %d\n",
			retValue);
		return TC_FAIL;
	}

	/* Try to get one more block and it should fail */
	retValue = task_mem_map_alloc(MAP_LgBlks, &errPtr, TICKS_NONE);
	if (verifyRetValue(RC_FAIL, retValue)) {
		TC_PRINT("  task_mem_map_alloc RC_FAIL expected as all (%d) blocks are used.\n",
			NUMBLOCKS);
	} else {
		TC_ERROR("Failed task_mem_map_alloc, expect RC_FAIL, got %d\n", retValue);
		return TC_FAIL;
	}

	PRINT_LINE;

	return TC_PASS;
}  /* testMapGetAllBlocks */
开发者ID:32bitmicro,项目名称:zephyr,代码行数:55,代码来源:map.c

示例14: RegressionTask

void RegressionTask(void)
{
	uint32_t nCalls = 0;
	int      status;

	TC_START("Test Microkernel Critical Section API\n");

	task_sem_give(ALT_SEM);      /* Activate AlternateTask() */

	nCalls = criticalLoop(nCalls);

	/* Wait for AlternateTask() to complete */
	status = task_sem_take_wait_timeout(REGRESS_SEM, TEST_TIMEOUT);
	if (status != RC_OK) {
		TC_ERROR("Timed out waiting for REGRESS_SEM\n");
		goto errorReturn;
	}

	if (criticalVar != nCalls + altTaskIterations) {
		TC_ERROR("Unexpected value for <criticalVar>.  Expected %d, got %d\n",
				 nCalls + altTaskIterations, criticalVar);
		goto errorReturn;
	}
	TC_PRINT("Obtained expected <criticalVar> value of %u\n", criticalVar);

	TC_PRINT("Enabling time slicing ...\n");

	sys_scheduler_time_slice_set(1, 10);

	task_sem_give(ALT_SEM);      /* Re-activate AlternateTask() */

	nCalls = criticalLoop(nCalls);

	/* Wait for AlternateTask() to finish */
	status = task_sem_take_wait_timeout(REGRESS_SEM, TEST_TIMEOUT);
	if (status != RC_OK) {
		TC_ERROR("Timed out waiting for REGRESS_SEM\n");
		goto errorReturn;
	}

	if (criticalVar != nCalls + altTaskIterations) {
		TC_ERROR("Unexpected value for <criticalVar>.  Expected %d, got %d\n",
				 nCalls + altTaskIterations, criticalVar);
		goto errorReturn;
	}
	TC_PRINT("Obtained expected <criticalVar> value of %u\n", criticalVar);

	TC_END_RESULT(TC_PASS);
	TC_END_REPORT(TC_PASS);
	return;

errorReturn:
	TC_END_RESULT(TC_FAIL);
	TC_END_REPORT(TC_FAIL);
}
开发者ID:01org,项目名称:CODK-A-Firmware,代码行数:55,代码来源:critical.c

示例15: main

void main(void)
{
	/* Fake personalization and additional_input
	 * (replace by appropriate values)
	 * e.g.: hostname+timestamp
	 */
	uint8_t additional_input[] = "additional input";
	uint8_t personalization[] = "HOSTNAME";
	uint32_t size = (1 << 15);
	uint32_t result = TC_PASS;
	struct tc_hmac_prng_struct h;
	uint8_t random[size];
	uint8_t seed[128];
	uint32_t i;

	TC_START("Performing HMAC-PRNG tests:");
	TC_PRINT("HMAC-PRNG test#1 (init, reseed, generate):\n");

	/* Fake seed (replace by a a truly random seed): */
	for (i = 0; i < (uint32_t)sizeof(seed); ++i) {
		seed[i] = i;
	}

	TC_PRINT("HMAC-PRNG test#1 (init):\n");
	if (tc_hmac_prng_init(&h, personalization,
			      sizeof(personalization)) == 0) {
		TC_ERROR("HMAC-PRNG initialization failed.\n");
		result = TC_FAIL;
		goto exitTest;
	}
	TC_END_RESULT(result);

	TC_PRINT("HMAC-PRNG test#1 (reseed):\n");
	if (tc_hmac_prng_reseed(&h, seed, sizeof(seed), additional_input,
				sizeof(additional_input)) == 0) {
		TC_ERROR("HMAC-PRNG reseed failed.\n");
		result = TC_FAIL;
		goto exitTest;
	}
	TC_END_RESULT(result);

	TC_PRINT("HMAC-PRNG test#1 (generate):\n");
	if (tc_hmac_prng_generate(random, size, &h) < 1) {
		TC_ERROR("HMAC-PRNG generate failed.\n");
		result = TC_FAIL;
		goto exitTest;
	}
	TC_END_RESULT(result);

	TC_PRINT("All HMAC tests succeeded!\n");

exitTest:
	TC_END_RESULT(result);
	TC_END_REPORT(result);
}
开发者ID:sunkaizhu,项目名称:zephyr,代码行数:55,代码来源:test_hmac_prng.c


注:本文中的TC_ERROR函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。