diff options
Diffstat (limited to 'samples/microkernel/test')
25 files changed, 1760 insertions, 1751 deletions
diff --git a/samples/microkernel/test/test_critical/src/critical.c b/samples/microkernel/test/test_critical/src/critical.c index eee77f0df..967da786f 100644 --- a/samples/microkernel/test/test_critical/src/critical.c +++ b/samples/microkernel/test/test_critical/src/critical.c @@ -87,7 +87,7 @@ uint32_t criticalLoop(uint32_t count) while (task_tick_get_32() < ticks + NUM_TICKS) { task_offload_to_fiber(criticalRtn, &criticalVar); count++; - } + } return count; } @@ -138,18 +138,18 @@ void RegressionTask(void) nCalls = criticalLoop(nCalls); - /* Wait for AlternateTask() to complete */ + /* 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); + nCalls + altTaskIterations, criticalVar); goto errorReturn; - } + } TC_PRINT("Obtained expected <criticalVar> value of %u\n", criticalVar); TC_PRINT("Enabling time slicing ...\n"); @@ -160,18 +160,18 @@ void RegressionTask(void) nCalls = criticalLoop(nCalls); - /* Wait for AlternateTask() to finish */ + /* 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); + nCalls + altTaskIterations, criticalVar); goto errorReturn; - } + } TC_PRINT("Obtained expected <criticalVar> value of %u\n", criticalVar); TC_END_RESULT(TC_PASS); diff --git a/samples/microkernel/test/test_events/src/test_fiber.c b/samples/microkernel/test/test_events/src/test_fiber.c index bcf444b80..61db5233e 100644 --- a/samples/microkernel/test/test_events/src/test_fiber.c +++ b/samples/microkernel/test/test_events/src/test_fiber.c @@ -64,27 +64,27 @@ static char fiberStack[FIBER_STACK_SIZE]; /* test fiber stack size */ * RETURNS: N/A */ static void testFiberEntry(void) - { - /* signal event for eventWaitTest() */ - /* single test */ +{ + /* signal event for eventWaitTest() */ + /* single test */ nano_fiber_sem_take_wait(&fiberSem); fiber_event_send(EVENT_ID); - /* test in cycle */ + /* test in cycle */ nano_fiber_sem_take_wait(&fiberSem); fiber_event_send(EVENT_ID); - /* signal event for eventTimeoutTest() */ + /* signal event for eventTimeoutTest() */ nano_fiber_sem_take_wait(&fiberSem); fiber_event_send(EVENT_ID); - /* - * Signal two events for fiberEventSignalTest (). - * It has to detect only one - */ + /* + * Signal two events for fiberEventSignalTest (). + * It has to detect only one + */ nano_fiber_sem_take_wait(&fiberSem); fiber_event_send(EVENT_ID); fiber_event_send(EVENT_ID); - } +} /******************************************************************************* * @@ -94,8 +94,8 @@ static void testFiberEntry(void) */ void testFiberInit(void) - { +{ nano_sem_init(&fiberSem); task_fiber_start(fiberStack, FIBER_STACK_SIZE, (nano_fiber_entry_t)testFiberEntry, - 0, 0, FIBER_PRIORITY, 0); - } + 0, 0, FIBER_PRIORITY, 0); +} diff --git a/samples/microkernel/test/test_fp_sharing/src/main.c b/samples/microkernel/test/test_fp_sharing/src/main.c index d4612ec1e..2ab4ffc11 100644 --- a/samples/microkernel/test/test_fp_sharing/src/main.c +++ b/samples/microkernel/test/test_fp_sharing/src/main.c @@ -207,8 +207,9 @@ void load_store_low(void) */ floatRegInitByte = MAIN_FLOAT_REG_CHECK_BYTE; - for (bufIx = 0; bufIx < SIZEOF_FP_REG_SET; ++bufIx) + for (bufIx = 0; bufIx < SIZEOF_FP_REG_SET; ++bufIx) { ((unsigned char *)&floatRegSetLoad)[bufIx] = floatRegInitByte++; + } /* Keep cranking forever, or until an error is detected. */ @@ -353,8 +354,9 @@ void load_store_high(void) floatRegInitByte = FIBER_FLOAT_REG_CHECK_BYTE; - for (bufIx = 0; bufIx < SIZEOF_FP_REG_SET; ++bufIx) + for (bufIx = 0; bufIx < SIZEOF_FP_REG_SET; ++bufIx) { floatRegisterSetBytePtr[bufIx] = floatRegInitByte++; + } /* * Utilize an architecture specific function to load all the floating @@ -395,9 +397,10 @@ void load_store_high(void) /* periodically issue progress report */ - if ((++load_store_high_count % 100) == 0) + if ((++load_store_high_count % 100) == 0) { PRINT_DATA("Load and store OK after %u (high) + %u (low) tests\n", load_store_high_count, load_store_low_count); + } #if (MAX_TESTS != 0) /* terminate testing if specified limit has been reached */ diff --git a/samples/microkernel/test/test_libs/src/libraries.c b/samples/microkernel/test/test_libs/src/libraries.c index 574e9432d..361a0fde0 100644 --- a/samples/microkernel/test/test_libs/src/libraries.c +++ b/samples/microkernel/test/test_libs/src/libraries.c @@ -165,15 +165,15 @@ char buffer[BUFSIZE]; int memset_test(void) { - TC_PRINT ("\tmemset ...\t"); + TC_PRINT("\tmemset ...\t"); - memset (buffer, 'a', BUFSIZE); + memset(buffer, 'a', BUFSIZE); if (buffer[0] != 'a' || buffer[BUFSIZE-1] != 'a') { - TC_PRINT ("failed\n"); + TC_PRINT("failed\n"); return TC_FAIL; } - TC_PRINT ("passed\n"); + TC_PRINT("passed\n"); return TC_PASS; } @@ -186,16 +186,16 @@ int memset_test(void) int strlen_test(void) { - TC_PRINT ("\tstrlen ...\t"); + TC_PRINT("\tstrlen ...\t"); - memset (buffer, '\0', BUFSIZE); - memset (buffer, 'b', 5); /* 5 is BUFSIZE / 2 */ + memset(buffer, '\0', BUFSIZE); + memset(buffer, 'b', 5); /* 5 is BUFSIZE / 2 */ if (strlen(buffer) != 5) { - TC_PRINT ("failed\n"); + TC_PRINT("failed\n"); return TC_FAIL; } - TC_PRINT ("passed\n"); + TC_PRINT("passed\n"); return TC_PASS; } @@ -206,32 +206,32 @@ int strlen_test(void) * RETURNS: TC_PASS or TC_FAIL */ -int strcmp_test (void) +int strcmp_test(void) { strcpy(buffer, "eeeee"); - TC_PRINT ("\tstrcmp less ...\t"); + TC_PRINT("\tstrcmp less ...\t"); if (strcmp(buffer, "fffff") >= 0) { - TC_PRINT ("failed\n"); + TC_PRINT("failed\n"); return TC_FAIL; } else { - TC_PRINT ("passed\n"); + TC_PRINT("passed\n"); } - TC_PRINT ("\tstrcmp equal ...\t"); + TC_PRINT("\tstrcmp equal ...\t"); if (strcmp(buffer, "eeeee") != 0) { - TC_PRINT ("failed\n"); + TC_PRINT("failed\n"); return TC_FAIL; } else { - TC_PRINT ("passed\n"); + TC_PRINT("passed\n"); } - TC_PRINT ("\tstrcmp greater ...\t"); + TC_PRINT("\tstrcmp greater ...\t"); if (strcmp(buffer, "ddddd") <= 0) { - TC_PRINT ("failed\n"); + TC_PRINT("failed\n"); return TC_FAIL; } else { - TC_PRINT ("passed\n"); + TC_PRINT("passed\n"); } return TC_PASS; @@ -244,32 +244,32 @@ int strcmp_test (void) * RETURNS: TC_PASS or TC_FAIL */ -int strncmp_test (void) +int strncmp_test(void) { strncpy(buffer, "eeeeeeeeeeee", BUFSIZE); - TC_PRINT ("\tstrncmp 0 ...\t"); + TC_PRINT("\tstrncmp 0 ...\t"); if (strncmp(buffer, "fffff", 0) != 0) { - TC_PRINT ("failed\n"); + TC_PRINT("failed\n"); return TC_FAIL; } else { - TC_PRINT ("passed\n"); + TC_PRINT("passed\n"); } - TC_PRINT ("\tstrncmp 3 ...\t"); + TC_PRINT("\tstrncmp 3 ...\t"); if (strncmp(buffer, "eeeff", 3) != 0) { - TC_PRINT ("failed\n"); + TC_PRINT("failed\n"); return TC_FAIL; } else { - TC_PRINT ("passed\n"); + TC_PRINT("passed\n"); } - TC_PRINT ("\tstrncmp 10 ...\t"); + TC_PRINT("\tstrncmp 10 ...\t"); if (strncmp(buffer, "eeeeeeeeeeeff", BUFSIZE) != 0) { - TC_PRINT ("failed\n"); + TC_PRINT("failed\n"); return TC_FAIL; } else { - TC_PRINT ("passed\n"); + TC_PRINT("passed\n"); } return TC_PASS; @@ -283,19 +283,19 @@ int strncmp_test (void) * RETURNS: TC_PASS or TC_FAIL */ -int strcpy_test (void) +int strcpy_test(void) { - TC_PRINT ("\tstrcpy ...\t"); + TC_PRINT("\tstrcpy ...\t"); - memset (buffer, '\0', BUFSIZE); + memset(buffer, '\0', BUFSIZE); strcpy(buffer, "10 chars!!\0"); if (strcmp(buffer, "10 chars!!\0") != 0) { - TC_PRINT ("failed\n"); + TC_PRINT("failed\n"); return TC_FAIL; } - TC_PRINT ("passed\n"); + TC_PRINT("passed\n"); return TC_PASS; } @@ -306,20 +306,20 @@ int strcpy_test (void) * RETURNS: TC_PASS or TC_FAIL */ -int strncpy_test (void) +int strncpy_test(void) { - TC_PRINT ("\tstrncpy ...\t"); + TC_PRINT("\tstrncpy ...\t"); - memset (buffer, '\0', BUFSIZE); + memset(buffer, '\0', BUFSIZE); strncpy(buffer, "This is over 10 characters", BUFSIZE); /* Purposely different values */ if (strncmp(buffer, "This is over 20 characters", BUFSIZE) != 0) { - TC_PRINT ("failed\n"); + TC_PRINT("failed\n"); return TC_FAIL; } - TC_PRINT ("passed\n"); + TC_PRINT("passed\n"); return TC_PASS; } @@ -330,27 +330,27 @@ int strncpy_test (void) * RETURNS: TC_PASS or TC_FAIL */ -int strchr_test (void) +int strchr_test(void) { char *rs = NULL; - TC_PRINT ("\tstrchr ...\t"); + TC_PRINT("\tstrchr ...\t"); - memset (buffer, '\0', BUFSIZE); + memset(buffer, '\0', BUFSIZE); strncpy(buffer, "Copy 10", BUFSIZE); rs = strchr(buffer, '1'); if (!rs) { - TC_PRINT ("failed\n"); + TC_PRINT("failed\n"); return TC_FAIL; } if (strncmp(rs, "10", 2) != 0) { - TC_PRINT ("failed\n"); + TC_PRINT("failed\n"); return TC_FAIL; } - TC_PRINT ("passed\n"); + TC_PRINT("passed\n"); return TC_PASS; } @@ -366,7 +366,7 @@ int stringTest(void) TC_PRINT("Testing string.h library ...\n"); if (memset_test() || strlen_test() || strcmp_test() || strcpy_test() || - strncpy_test() || strncmp_test() || strchr_test()) { + strncpy_test() || strncmp_test() || strchr_test()) { return TC_FAIL; } @@ -388,8 +388,8 @@ int RegressionTask(void) { TC_PRINT("Validating access to supported libraries\n"); - if (limitsTest () || stdboolTest () || stddefTest () || - stdintTest () || stringTest ()) { + if (limitsTest() || stdboolTest() || stddefTest() || + stdintTest() || stringTest()) { TC_PRINT("Library validation failed\n"); return TC_FAIL; } diff --git a/samples/microkernel/test/test_mail/src/mail.c b/samples/microkernel/test/test_mail/src/mail.c index d6457d8ab..320f9365e 100644 --- a/samples/microkernel/test/test_mail/src/mail.c +++ b/samples/microkernel/test/test_mail/src/mail.c @@ -65,10 +65,10 @@ are not (yet) tested include: /* defines */ -#define MSGSIZE 16 /* Standard message data size */ -#define XFER_PRIO 5 /* standard message transfer priority */ -#define MSG_INFO1 1234 /* Message info test value */ -#define MSG_INFO2 666 /* Message info test value */ +#define MSGSIZE 16 /* Standard message data size */ +#define XFER_PRIO 5 /* standard message transfer priority */ +#define MSG_INFO1 1234 /* Message info test value */ +#define MSG_INFO2 666 /* Message info test value */ /* locals */ @@ -99,18 +99,18 @@ extern kmemory_pool_t smallBlkszPool; * rx_task to receiverTask - destination for the message * mailbox to inMbox * +* @param inMsg The message being received. +* @param inMbox Mail box to receive the message. +* @param receiverTask Destination for the message. +* @param dataArea Pointer to (optional) buffer to send. +* @param dataSize Size of (optional) buffer to send. +* @param info Additional (optional) info to send. +* * RETURNS: N/A */ -static void setMsg_Sender - ( - struct k_msg *inMsg, /* the message being received */ - kmbox_t inMbox, /* mail box to receive the message */ - ktask_t receiverTask, /* destination for the message */ - void *dataArea, /* pointer to (optional) buffer to send */ - uint32_t dataSize, /* size of (optional) buffer to send */ - uint32_t info /* additional (optional) info to send */ - ) +static void setMsg_Sender(struct k_msg *inMsg, kmbox_t inMbox, ktask_t receiverTask, + void *dataArea, uint32_t dataSize, uint32_t info) { inMsg->rx_task = receiverTask; inMsg->mailbox = inMbox; @@ -129,17 +129,17 @@ static void setMsg_Sender * tx_task to senderTask - receiver tries to get message from this source * mailbox to inMbox * +* @param inMsg Message descriptor. +* @param inMbox Mail box to receive from. +* @param senderTask Sending task to receive from. +* @param inBuffer Incoming data area +* @param inBufferSize Size of incoming data area. +* * RETURNS: N/A */ -static void setMsg_Receiver - ( - struct k_msg *inMsg, /* message descriptor */ - kmbox_t inMbox, /* mail box to receive from */ - ktask_t senderTask, /* sending task to receive from */ - void *inBuffer, /* incoming data area */ - uint32_t inBufferSize /* size of incoming data area */ - ) +static void setMsg_Receiver(struct k_msg *inMsg, kmbox_t inMbox, ktask_t senderTask, + void *inBuffer, uint32_t inBufferSize) { inMsg->mailbox = inMbox; inMsg->tx_task = senderTask; @@ -154,15 +154,14 @@ static void setMsg_Receiver * * setMsg_RecvBuf - sets rx_data field in msg and clears buffer * +* @param inMsg The message being received. +* @param inBuffer Incoming data area. +* @param inBufferSize Size of incoming data area. +* * RETURNS: N/A */ -static void setMsg_RecvBuf - ( - struct k_msg *inMsg, /* the message being received */ - char *inBuffer, /* incoming data area */ - uint32_t inBufferSize /* size of incoming data area */ - ) +static void setMsg_RecvBuf(struct k_msg *inMsg, char *inBuffer, uint32_t inBufferSize) { inMsg->rx_data = inBuffer; inMsg->size = inBufferSize; diff --git a/samples/microkernel/test/test_mail/src/main.c b/samples/microkernel/test/test_mail/src/main.c index 639acdf11..b3e1ce99a 100644 --- a/samples/microkernel/test/test_mail/src/main.c +++ b/samples/microkernel/test/test_mail/src/main.c @@ -66,15 +66,15 @@ static ksem_t resultSems[] = { SEM_TASKDONE, SEM_TASKFAIL, ENDLIST }; /* globals */ ktask_t msgSenderTask = MSGSENDERTASK; -ktask_t msgRcvrTask = MSGRCVRTASK; +ktask_t msgRcvrTask = MSGRCVRTASK; -ksem_t semSync1 = SEM_SYNC1; -ksem_t semSync2 = SEM_SYNC2; +ksem_t semSync1 = SEM_SYNC1; +ksem_t semSync2 = SEM_SYNC2; -kmbox_t myMbox = MYMBOX; -kmbox_t noRcvrMbox = NORCVRMBOX; +kmbox_t myMbox = MYMBOX; +kmbox_t noRcvrMbox = NORCVRMBOX; -kmemory_pool_t testPool = TESTPOOL; +kmemory_pool_t testPool = TESTPOOL; kmemory_pool_t smallBlkszPool = SMALLBLKSZPOOL; /******************************************************************************* @@ -88,11 +88,11 @@ kmemory_pool_t smallBlkszPool = SMALLBLKSZPOOL; */ void MsgSenderTaskEntry(void) - { +{ extern int MsgSenderTask(void); task_sem_give(resultSems[MsgSenderTask()]); - } +} /******************************************************************************* * @@ -105,11 +105,11 @@ void MsgSenderTaskEntry(void) */ void MsgRcvrTaskEntry(void) - { +{ extern int MsgRcvrTask(void); task_sem_give(resultSems[MsgRcvrTask()]); - } +} /******************************************************************************* * @@ -122,31 +122,31 @@ void MsgRcvrTaskEntry(void) */ void MonitorTaskEntry(void) - { +{ ksem_t result; int tasksDone; PRINT_DATA("Starting mailbox tests\n"); PRINT_LINE; - /* - * the various test tasks start executing automatically; - * wait for all tasks to complete or a failure to occur, - * then issue the appropriate test case summary message - */ + /* + * the various test tasks start executing automatically; + * wait for all tasks to complete or a failure to occur, + * then issue the appropriate test case summary message + */ for (tasksDone = 0; tasksDone < NUM_TEST_TASKS; tasksDone++) { - result = task_sem_group_take_wait_timeout(resultSems, TIMEOUT); - if (result != resultSems[TC_PASS]) { - if (result != resultSems[TC_FAIL]) { - TC_ERROR("Monitor task timed out\n"); + result = task_sem_group_take_wait_timeout(resultSems, TIMEOUT); + if (result != resultSems[TC_PASS]) { + if (result != resultSems[TC_FAIL]) { + TC_ERROR("Monitor task timed out\n"); + } + TC_END_RESULT(TC_FAIL); + TC_END_REPORT(TC_FAIL); + return; } - TC_END_RESULT(TC_FAIL); - TC_END_REPORT(TC_FAIL); - return; - } } TC_END_RESULT(TC_PASS); TC_END_REPORT(TC_PASS); - } +} diff --git a/samples/microkernel/test/test_mutex/src/mutex.c b/samples/microkernel/test/test_mutex/src/mutex.c index 7bd274cd0..dea0ca38c 100644 --- a/samples/microkernel/test/test_mutex/src/mutex.c +++ b/samples/microkernel/test/test_mutex/src/mutex.c @@ -89,19 +89,19 @@ static int tcRC = TC_PASS; /* test case return code */ */ void Task10(void) - { +{ int rv; task_sleep(3 * ONE_SECOND + HALF_SECOND); - /* Wait and boost owner priority to 10 */ + /* Wait and boost owner priority to 10 */ rv = task_mutex_lock_wait_timeout(Mutex4, ONE_SECOND); if (rv != RC_TIME) { tcRC = TC_FAIL; TC_ERROR("Failed to timeout on mutex 0x%x\n", Mutex4); return; - } - } /* Task10 */ + } +} /* Task10 */ /******************************************************************************* @@ -112,29 +112,29 @@ void Task10(void) */ void Task15(void) - { +{ int rv; task_sleep(3 * ONE_SECOND + 3 * FOURTH_SECOND); - /* - * Wait for the mutex. There is a higher priority level task waiting - * on the mutex, so request will not immediately contribute to raising - * the priority of the owning task (RegressionTask). When Task10 times out - * this task will become the highest priority waiting task. The priority - * of the owning task (RegressionTask) will not drop back to 20, but will - * instead drop to 15. - */ + /* + * Wait for the mutex. There is a higher priority level task waiting + * on the mutex, so request will not immediately contribute to raising + * the priority of the owning task (RegressionTask). When Task10 times out + * this task will become the highest priority waiting task. The priority + * of the owning task (RegressionTask) will not drop back to 20, but will + * instead drop to 15. + */ rv = task_mutex_lock_wait_timeout(Mutex4, 2 * ONE_SECOND); if (rv != RC_OK) { tcRC = TC_FAIL; TC_ERROR("Failed to take mutex 0x%x\n", Mutex4); return; - } + } task_mutex_unlock(Mutex4); - } +} /******************************************************************************* * @@ -144,27 +144,27 @@ void Task15(void) */ void Task20(void) - { +{ int rv; task_sleep(2 * ONE_SECOND + HALF_SECOND); - /* - * Wait and boost owner priority to 20. While waiting, another task of - * a very low priority level will also wait for the mutex. Task20 is - * expected to time out around the 5.5 second mark. When it times out, - * Task45 will become the only waiting task for this mutex and the - * priority of the owning task RegressionTask will drop to 25. - */ + /* + * Wait and boost owner priority to 20. While waiting, another task of + * a very low priority level will also wait for the mutex. Task20 is + * expected to time out around the 5.5 second mark. When it times out, + * Task45 will become the only waiting task for this mutex and the + * priority of the owning task RegressionTask will drop to 25. + */ rv = task_mutex_lock_wait_timeout(Mutex3, 3 * ONE_SECOND); if (rv != RC_TIME) { tcRC = TC_FAIL; TC_ERROR("Failed to timeout on mutex 0x%x\n", Mutex3); return; - } + } - } /* Task20 */ +} /* Task20 */ /******************************************************************************* * @@ -174,7 +174,7 @@ void Task20(void) */ void Task25(void) - { +{ int rv; task_sleep(ONE_SECOND + HALF_SECOND); @@ -184,10 +184,10 @@ void Task25(void) tcRC = TC_FAIL; TC_ERROR("Failed to take mutex 0x%x\n", Mutex2); return; - } + } task_mutex_unlock(Mutex2); - } /* Task25 */ +} /* Task25 */ /******************************************************************************* * @@ -197,7 +197,7 @@ void Task25(void) */ void Task30(void) - { +{ int rv; task_sleep(HALF_SECOND); /* Allow lower priority task to run */ @@ -208,17 +208,17 @@ void Task30(void) tcRC = TC_FAIL; TC_ERROR("Failed to NOT take locked mutex 0x%x\n", Mutex1); return; - } + } rv = task_mutex_lock_wait(Mutex1); /* Wait and boost owner priority to 30 */ if (rv != RC_OK) { tcRC = TC_FAIL; TC_ERROR("Failed to take mutex 0x%x\n", Mutex1); return; - } + } task_mutex_unlock(Mutex1); - } +} /******************************************************************************* * @@ -228,7 +228,7 @@ void Task30(void) */ void Task45(void) - { +{ int rv; task_sleep(3 * ONE_SECOND + HALF_SECOND); @@ -237,9 +237,9 @@ void Task45(void) tcRC = TC_FAIL; TC_ERROR("Failed to take mutex 0x%x\n", Mutex2); return; - } - task_mutex_unlock(Mutex3); } + task_mutex_unlock(Mutex3); +} /******************************************************************************* * @@ -251,7 +251,7 @@ void Task45(void) */ void RegressionTask(void) - { +{ int rv; int i; kmutex_t mutexes[4] = {Mutex1, Mutex2, Mutex3, Mutex4}; @@ -263,41 +263,41 @@ void RegressionTask(void) PRINT_LINE; - /* - * 1st iteration: Take Mutex1; Task30 waits on Mutex1 - * 2nd iteration: Take Mutex2: Task25 waits on Mutex2 - * 3rd iteration: Take Mutex3; Task20 waits on Mutex3 - * 4th iteration: Take Mutex4; Task10 waits on Mutex4 - */ + /* + * 1st iteration: Take Mutex1; Task30 waits on Mutex1 + * 2nd iteration: Take Mutex2: Task25 waits on Mutex2 + * 3rd iteration: Take Mutex3; Task20 waits on Mutex3 + * 4th iteration: Take Mutex4; Task10 waits on Mutex4 + */ for (i = 0; i < 4; i++) { rv = task_mutex_lock(mutexes[i]); if (rv != RC_OK) { - TC_ERROR("Failed to lock mutex 0x%x\n", mutexes[i]); - tcRC = TC_FAIL; - goto errorReturn; - } + TC_ERROR("Failed to lock mutex 0x%x\n", mutexes[i]); + tcRC = TC_FAIL; + goto errorReturn; + } task_sleep(ONE_SECOND); rv = task_priority_get(); if (rv != priority[i]) { - TC_ERROR("Expected priority %d, not %d\n", priority[i], rv); - tcRC = TC_FAIL; - goto errorReturn; - } + TC_ERROR("Expected priority %d, not %d\n", priority[i], rv); + tcRC = TC_FAIL; + goto errorReturn; + } if (tcRC != TC_PASS) { /* Catch any errors from other tasks */ - goto errorReturn; - } + goto errorReturn; } + } - /* ~ 4 seconds have passed */ + /* ~ 4 seconds have passed */ TC_PRINT("Done LOCKING! Current priority = %d\n", task_priority_get()); task_sleep(ONE_SECOND); /* Task10 should time out */ - /* ~ 5 seconds have passed */ + /* ~ 5 seconds have passed */ rv = task_priority_get(); if (rv != 15) { @@ -305,7 +305,7 @@ void RegressionTask(void) TC_ERROR("Expected priority %d, not %d\n", 15, rv); tcRC = TC_FAIL; goto errorReturn; - } + } task_mutex_unlock(Mutex4); rv = task_priority_get(); @@ -314,40 +314,40 @@ void RegressionTask(void) TC_ERROR("Expected priority %d, not %d\n", 20, rv); tcRC = TC_FAIL; goto errorReturn; - } + } task_sleep(ONE_SECOND); /* Task20 should time out */ - /* ~ 6 seconds have passed */ + /* ~ 6 seconds have passed */ for (i = 0; i < 3; i++) { rv = task_priority_get(); if (rv != dropPri[i]) { - TC_ERROR("Expected priority %d, not %d\n", dropPri[i], rv); - tcRC = TC_FAIL; - goto errorReturn; - } + TC_ERROR("Expected priority %d, not %d\n", dropPri[i], rv); + tcRC = TC_FAIL; + goto errorReturn; + } task_mutex_unlock(giveMutex[i]); if (tcRC != TC_PASS) { - goto errorReturn; - } + goto errorReturn; } + } rv = task_priority_get(); if (rv != 40) { TC_ERROR("Expected priority %d, not %d\n", 40, rv); tcRC = TC_FAIL; goto errorReturn; - } + } task_sleep(ONE_SECOND); /* Give Task45 time to run */ if (tcRC != TC_PASS) { goto errorReturn; - } + } errorReturn: TC_END_RESULT(tcRC); TC_END_REPORT(tcRC); - } /* RegressionTask */ +} /* RegressionTask */ diff --git a/samples/microkernel/test/test_pipe/src/main.c b/samples/microkernel/test/test_pipe/src/main.c index f52b32ee8..ce37a2cac 100644 --- a/samples/microkernel/test/test_pipe/src/main.c +++ b/samples/microkernel/test/test_pipe/src/main.c @@ -82,11 +82,11 @@ kpipe_t pipeId = PIPE_ID; */ void RegressionTaskEntry(void) - { +{ extern int RegressionTask(void); task_sem_give(resultSems[RegressionTask()]); - } +} /******************************************************************************* * @@ -99,11 +99,11 @@ void RegressionTaskEntry(void) */ void AlternateTaskEntry(void) - { +{ extern int AlternateTask(void); task_sem_give(resultSems[AlternateTask()]); - } +} /******************************************************************************* * @@ -116,31 +116,31 @@ void AlternateTaskEntry(void) */ void MonitorTaskEntry(void) - { +{ ksem_t result; int tasksDone; PRINT_DATA("Starting pipe tests\n"); PRINT_LINE; - /* - * the various test tasks start executing automatically; - * wait for all tasks to complete or a failure to occur, - * then issue the appropriate test case summary message - */ + /* + * the various test tasks start executing automatically; + * wait for all tasks to complete or a failure to occur, + * then issue the appropriate test case summary message + */ for (tasksDone = 0; tasksDone < NUM_TEST_TASKS; tasksDone++) { - result = task_sem_group_take_wait_timeout(resultSems, TIMEOUT); - if (result != resultSems[TC_PASS]) { - if (result != resultSems[TC_FAIL]) { - TC_ERROR("Monitor task timed out\n"); + result = task_sem_group_take_wait_timeout(resultSems, TIMEOUT); + if (result != resultSems[TC_PASS]) { + if (result != resultSems[TC_FAIL]) { + TC_ERROR("Monitor task timed out\n"); + } + TC_END_RESULT(TC_FAIL); + TC_END_REPORT(TC_FAIL); + return; } - TC_END_RESULT(TC_FAIL); - TC_END_REPORT(TC_FAIL); - return; - } } TC_END_RESULT(TC_PASS); TC_END_REPORT(TC_PASS); - } +} diff --git a/samples/microkernel/test/test_pipe/src/pipe.c b/samples/microkernel/test/test_pipe/src/pipe.c index 871faf6df..256b208e8 100644 --- a/samples/microkernel/test/test_pipe/src/pipe.c +++ b/samples/microkernel/test/test_pipe/src/pipe.c @@ -64,7 +64,7 @@ typedef struct { K_PIPE_OPTION options; /* options for task_pipe_XXX() APIs */ int sent; /* expected # of bytes sent */ int rcode; /* expected return code */ - } SIZE_EXPECT; +} SIZE_EXPECT; /* locals */ @@ -180,7 +180,7 @@ void microObjectsInit(void) for (i = 0; i < sizeof(rxBuffer); i++) { txBuffer[i] = (char) i; - } + } } /******************************************************************************* @@ -199,9 +199,9 @@ int receiveBufferCheck(char *buffer, int size) for (j = 0; j < size; j++) { if (buffer[j] != (char) j) { - return j; - } + return j; } + } return size; } @@ -230,76 +230,76 @@ int pipePutHelperWork(SIZE_EXPECT *singleItems, int nSingles, for (i = 0; i < nSingles; i++) { (void)task_sem_take_wait(altSem); for (j = 0; j < sizeof(rxBuffer); j++) { - rxBuffer[j] = 0; - } + rxBuffer[j] = 0; + } rv = task_pipe_get(pipeId, rxBuffer, singleItems[i].size, - &bytesReceived, singleItems[i].options); + &bytesReceived, singleItems[i].options); if (rv != singleItems[i].rcode) { - TC_ERROR("task_pipe_get(%d bytes) : Expected %d not %d.\n" - " bytesReceived = %d\n", - singleItems[i].size, singleItems[i].rcode, - rv, bytesReceived); - return TC_FAIL; - } + TC_ERROR("task_pipe_get(%d bytes) : Expected %d not %d.\n" + " bytesReceived = %d\n", + singleItems[i].size, singleItems[i].rcode, + rv, bytesReceived); + return TC_FAIL; + } if (bytesReceived != singleItems[i].sent) { - TC_ERROR("task_pipe_get(%d) : " - "Expected %d bytes to be received, not %d\n", - singleItems[i].size, singleItems[i].sent, bytesReceived); - return TC_FAIL; - } + TC_ERROR("task_pipe_get(%d) : " + "Expected %d bytes to be received, not %d\n", + singleItems[i].size, singleItems[i].sent, bytesReceived); + return TC_FAIL; + } index = receiveBufferCheck(rxBuffer, bytesReceived); if (index != bytesReceived) { - TC_ERROR("pipePutHelper: rxBuffer[%d] is %d, not %d\n", - index, rxBuffer[index], index); - return TC_FAIL; - } + TC_ERROR("pipePutHelper: rxBuffer[%d] is %d, not %d\n", + index, rxBuffer[index], index); + return TC_FAIL; + } task_sem_give(counterSem); task_sem_give(regSem); - } + } - /* - * Get items from the pipe. There should be more than one item - * stored in it. - */ + /* + * Get items from the pipe. There should be more than one item + * stored in it. + */ (void)task_sem_take_wait(altSem); for (i = 0; i < nMany; i++) { for (j = 0; j < sizeof(rxBuffer); j++) { - rxBuffer[j] = 0; - } + rxBuffer[j] = 0; + } rv = task_pipe_get(pipeId, rxBuffer, manyItems[i].size, - &bytesReceived, manyItems[i].options); + &bytesReceived, manyItems[i].options); if (rv != manyItems[i].rcode) { - TC_ERROR("task_pipe_get(%d bytes) : Expected %d not %d.\n" - " bytesReceived = %d, iteration: %d\n", - manyItems[i].size, manyItems[i].rcode, - rv, bytesReceived, i+1); - return TC_FAIL; - } + TC_ERROR("task_pipe_get(%d bytes) : Expected %d not %d.\n" + " bytesReceived = %d, iteration: %d\n", + manyItems[i].size, manyItems[i].rcode, + rv, bytesReceived, i+1); + return TC_FAIL; + } if (bytesReceived != manyItems[i].sent) { - TC_ERROR("task_pipe_get(%d) : " - "Expected %d bytes to be received, not %d\n", - manyItems[i].size, manyItems[i].sent, bytesReceived); - return TC_FAIL; - } + TC_ERROR("task_pipe_get(%d) : " + "Expected %d bytes to be received, not %d\n", + manyItems[i].size, manyItems[i].sent, bytesReceived); + return TC_FAIL; + } index = receiveBufferCheck(rxBuffer, bytesReceived); if (index != bytesReceived) { - TC_ERROR("pipeGetHelper: rxBuffer[%d] is %d, not %d\n", - index, rxBuffer[index], index); - return TC_FAIL; - } + TC_ERROR("pipeGetHelper: rxBuffer[%d] is %d, not %d\n", + index, rxBuffer[index], index); + return TC_FAIL; + } task_sem_give(counterSem); - } + } task_sem_give(regSem); /* Wake the RegressionTask */ @@ -318,25 +318,25 @@ int pipePutHelper(void) int rv; /* return value from pipePutHelperWork() */ rv = pipePutHelperWork(all_N, ARRAY_SIZE(all_N), - many_all_N, ARRAY_SIZE(many_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 = pipePutHelperWork(one_to_N, ARRAY_SIZE(one_to_N), - many_one_to_N, ARRAY_SIZE(many_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 = pipePutHelperWork(zero_to_N, ARRAY_SIZE(zero_to_N), - many_zero_to_N, ARRAY_SIZE(many_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; } @@ -367,65 +367,65 @@ int pipePutTestWork(SIZE_EXPECT *singleItems, int nSingles, for (i = 0; i < nSingles; i++) { rv = task_pipe_put(pipeId, txBuffer, singleItems[i].size, - &bytesWritten, singleItems[i].options); + &bytesWritten, singleItems[i].options); if (rv != singleItems[i].rcode) { - TC_ERROR("task_pipe_put(%d) : Expected %d not %d.\n" - " bytesWritten = %d, Iteration: %d\n", - singleItems[i].size, singleItems[i].rcode, - rv, bytesWritten, i + 1); - return TC_FAIL; - } + TC_ERROR("task_pipe_put(%d) : Expected %d not %d.\n" + " bytesWritten = %d, Iteration: %d\n", + singleItems[i].size, singleItems[i].rcode, + rv, bytesWritten, i + 1); + return TC_FAIL; + } if (bytesWritten != singleItems[i].sent) { - TC_ERROR("task_pipe_put(%d) : " - "Expected %d bytes to be written, not %d\n", - singleItems[i].size, singleItems[i].sent, bytesWritten); - return TC_FAIL; - } + TC_ERROR("task_pipe_put(%d) : " + "Expected %d bytes to be written, not %d\n", + singleItems[i].size, singleItems[i].sent, bytesWritten); + return TC_FAIL; + } task_sem_give(altSem); (void)task_sem_take_wait(regSem); - nitem = task_sem_count_get(counterSem) - 1; + nitem = task_sem_count_get(counterSem) - 1; if (nitem != i) { - TC_ERROR("Expected item number is %d, not %d\n", - i, nitem); - return TC_FAIL; - } + TC_ERROR("Expected item number is %d, not %d\n", + i, nitem); + return TC_FAIL; } + } - /* This time, more than one item will be in the pipe at a time */ + /* This time, more than one item will be in the pipe at a time */ task_sem_reset(counterSem); for (i = 0; i < nMany; i++) { rv = task_pipe_put(pipeId, txBuffer, manyItems[i].size, - &bytesWritten, manyItems[i].options); + &bytesWritten, manyItems[i].options); if (rv != manyItems[i].rcode) { - TC_ERROR("task_pipe_put(%d) : Expected %d not %d.\n" - " bytesWritten = %d, iteration: %d\n", - manyItems[i].size, manyItems[i].rcode, - rv, bytesWritten, i + 1); - return TC_FAIL; - } + TC_ERROR("task_pipe_put(%d) : Expected %d not %d.\n" + " bytesWritten = %d, iteration: %d\n", + manyItems[i].size, manyItems[i].rcode, + rv, bytesWritten, i + 1); + return TC_FAIL; + } if (bytesWritten != manyItems[i].sent) { - TC_ERROR("task_pipe_put(%d) : " - "Expected %d bytes to be written, not %d\n", - manyItems[i].size, manyItems[i].sent, bytesWritten); - return TC_FAIL; - } + TC_ERROR("task_pipe_put(%d) : " + "Expected %d bytes to be written, not %d\n", + manyItems[i].size, manyItems[i].sent, bytesWritten); + return TC_FAIL; } + } task_sem_give(altSem); /* Wake the alternate task */ - /* wait for other task reading all the items from pipe */ + /* wait for other task reading all the items from pipe */ (void)task_sem_take_wait(regSem); if (task_sem_count_get(counterSem) != nMany) { TC_ERROR("Expected number of items %d, not %d\n", - nMany, task_sem_count_get(counterSem)); + nMany, task_sem_count_get(counterSem)); return TC_FAIL; - } + } return TC_PASS; } @@ -444,25 +444,25 @@ 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)); + 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)); + 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)); + 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; } @@ -482,49 +482,49 @@ int pipePutWaitHelper(void) (void)task_sem_take_wait(altSem); /* Wait until test is ready */ - /* 1. task_pipe_get_wait() will force a context switch to RegressionTask() */ + /* 1. task_pipe_get_wait() will force a context switch to RegressionTask() */ rv = task_pipe_get_wait(pipeId, rxBuffer, PIPE_SIZE, - &bytesRead, _ALL_N); + &bytesRead, _ALL_N); 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); + "Expected %d bytes to be read, not %d\n", + RC_OK, rv, PIPE_SIZE, bytesRead); return TC_FAIL; - } + } - /* 2. task_pipe_get_wait() will force a context switch to RegressionTask(). */ + /* 2. task_pipe_get_wait() will force a context switch to RegressionTask(). */ rv = task_pipe_get_wait(pipeId, rxBuffer, PIPE_SIZE, - &bytesRead, _1_TO_N); + &bytesRead, _1_TO_N); 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); + "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() fails when - * using the _0_TO_N option. - */ + /* + * Before emptying the pipe, check that task_pipe_get_wait() fails when + * using the _0_TO_N option. + */ rv = task_pipe_get_wait(pipeId, rxBuffer, PIPE_SIZE / 2, - &bytesRead, _0_TO_N); + &bytesRead, _0_TO_N); 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 */ + /* 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); + &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; - } + 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); @@ -543,49 +543,49 @@ int pipePutWaitTest(void) int rv; /* return code from task_pipe_put_wait() */ int bytesWritten; /* # of bytes written to pipe */ - /* 1. Fill the pipe */ + /* 1. Fill the pipe */ rv = task_pipe_put_wait(pipeId, txBuffer, PIPE_SIZE, - &bytesWritten, _ALL_N); + &bytesWritten, _ALL_N); if ((rv != RC_OK) || (bytesWritten != PIPE_SIZE)) { TC_ERROR("Return code: expected %d, got %d\n" - "Bytes written: expected %d, got %d\n", - RC_OK, rv, PIPE_SIZE, bytesWritten); + "Bytes written: expected %d, got %d\n", + RC_OK, rv, PIPE_SIZE, bytesWritten); return TC_FAIL; - } + } task_sem_give(altSem); /* Wake the alternate task */ - /* 2. task_pipe_put_wait() will force a context switch to AlternateTask(). */ + /* 2. task_pipe_put_wait() will force a context switch to AlternateTask(). */ rv = task_pipe_put_wait(pipeId, txBuffer, PIPE_SIZE, - &bytesWritten, _ALL_N); + &bytesWritten, _ALL_N); if ((rv != RC_OK) || (bytesWritten != PIPE_SIZE)) { TC_ERROR("Return code: expected %d, got %d\n" - "Bytes written: expected %d, got %d\n", - RC_OK, rv, PIPE_SIZE, bytesWritten); + "Bytes written: expected %d, got %d\n", + RC_OK, rv, PIPE_SIZE, bytesWritten); return TC_FAIL; - } + } - /* 3. task_pipe_put_wait() will force a context switch to AlternateTask(). */ + /* 3. task_pipe_put_wait() will force a context switch to AlternateTask(). */ rv = task_pipe_put_wait(pipeId, txBuffer, PIPE_SIZE, - &bytesWritten, _1_TO_N); + &bytesWritten, _1_TO_N); if ((rv != RC_OK) || (bytesWritten != PIPE_SIZE)) { TC_ERROR("Return code: expected %d, got %d\n" - "Bytes written: expected %d, got %d\n", - RC_OK, rv, PIPE_SIZE, bytesWritten); + "Bytes written: expected %d, got %d\n", + RC_OK, rv, PIPE_SIZE, bytesWritten); return TC_FAIL; - } + } - /* This should return immediately as _0_TO_N with a wait is an error. */ + /* This should return immediately as _0_TO_N with a wait is an error. */ rv = task_pipe_put_wait(pipeId, txBuffer, PIPE_SIZE, - &bytesWritten, _0_TO_N); + &bytesWritten, _0_TO_N); if ((rv != RC_FAIL) || (bytesWritten != 0)) { TC_ERROR("Return code: expected %d, got %d\n" - "Bytes written: expected %d, got %d\n", - RC_FAIL, rv, 0, bytesWritten); + "Bytes written: expected %d, got %d\n", + RC_FAIL, rv, 0, bytesWritten); return TC_FAIL; - } + } - /* Wait for AlternateTask()'s pipePutWaitHelper() to finish */ + /* Wait for AlternateTask()'s pipePutWaitHelper() to finish */ (void)task_sem_take_wait(regSem); return TC_PASS; @@ -606,49 +606,49 @@ int pipePutTimeoutHelper(void) (void)task_sem_take_wait(altSem); /* Wait until test is ready */ - /* 1. task_pipe_get_wait_timeout() will force a context switch to RegressionTask() */ + /* 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); + &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); + "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(). */ + /* 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); + &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); + "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. - */ + /* + * 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); + &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 */ + /* 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); + &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; - } + 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); @@ -667,67 +667,69 @@ int pipePutTimeoutTest(void) int rv; /* return code from task_pipe_put_wait_timeout() */ int bytesWritten; /* # of bytes written to task_pipe_put_wait_timeout() */ - /* 1. Fill the pipe */ + /* 1. Fill the pipe */ rv = task_pipe_put_wait_timeout(pipeId, txBuffer, PIPE_SIZE, - &bytesWritten, _ALL_N, ONE_SECOND); + &bytesWritten, _ALL_N, ONE_SECOND); if ((rv != RC_OK) || (bytesWritten != PIPE_SIZE)) { TC_ERROR("Return code: expected %d, got %d\n" - "Bytes written: expected %d, got %d\n", - RC_OK, rv, PIPE_SIZE, bytesWritten); + "Bytes written: expected %d, got %d\n", + RC_OK, rv, PIPE_SIZE, bytesWritten); return TC_FAIL; - } + } - /* Timeout while waiting to put data into the pipe */ + /* Timeout while waiting to put data into the pipe */ rv = task_pipe_put_wait_timeout(pipeId, txBuffer, PIPE_SIZE, - &bytesWritten, _ALL_N, ONE_SECOND); + &bytesWritten, _ALL_N, ONE_SECOND); if ((rv != RC_TIME) || (bytesWritten != 0)) { TC_ERROR("Return code: expected %d, got %d\n" - "Bytes written: expected %d, got %d\n", - RC_TIME, rv, 0, bytesWritten); + "Bytes written: expected %d, got %d\n", + RC_TIME, rv, 0, bytesWritten); return TC_FAIL; - } + } rv = task_pipe_put_wait_timeout(pipeId, txBuffer, PIPE_SIZE, - &bytesWritten, _1_TO_N, ONE_SECOND); + &bytesWritten, _1_TO_N, ONE_SECOND); if ((rv != RC_TIME) || (bytesWritten != 0)) { TC_ERROR("Return code: expected %d, got %d\n" - "Bytes written: expected %d, got %d\n", - RC_TIME, rv, 0, bytesWritten); + "Bytes written: expected %d, got %d\n", + RC_TIME, rv, 0, bytesWritten); return TC_FAIL; - } + } task_sem_give(altSem); /* Wake the alternate task */ - /* 2. task_pipe_put_wait() will force a context switch to AlternateTask(). */ + /* 2. task_pipe_put_wait() will force a context switch to AlternateTask(). */ rv = task_pipe_put_wait_timeout(pipeId, txBuffer, PIPE_SIZE, - &bytesWritten, _ALL_N, ONE_SECOND); + &bytesWritten, _ALL_N, ONE_SECOND); if ((rv != RC_OK) || (bytesWritten != PIPE_SIZE)) { TC_ERROR("Return code: expected %d, got %d\n" - "Bytes written: expected %d, got %d\n", - RC_OK, rv, PIPE_SIZE, bytesWritten); return TC_FAIL; } + "Bytes written: expected %d, got %d\n", + RC_OK, rv, PIPE_SIZE, bytesWritten); + return TC_FAIL; + } - /* 3. task_pipe_put_wait() will force a context switch to AlternateTask(). */ + /* 3. task_pipe_put_wait() will force a context switch to AlternateTask(). */ rv = task_pipe_put_wait_timeout(pipeId, txBuffer, PIPE_SIZE, - &bytesWritten, _1_TO_N, ONE_SECOND); + &bytesWritten, _1_TO_N, ONE_SECOND); if ((rv != RC_OK) || (bytesWritten != PIPE_SIZE)) { TC_ERROR("Return code: expected %d, got %d\n" - "Bytes written: expected %d, got %d\n", - RC_OK, rv, PIPE_SIZE, bytesWritten); + "Bytes written: expected %d, got %d\n", + RC_OK, rv, PIPE_SIZE, bytesWritten); return TC_FAIL; - } + } - /* This should return immediately as _0_TO_N with a wait is an error. */ + /* This should return immediately as _0_TO_N with a wait is an error. */ rv = task_pipe_put_wait(pipeId, txBuffer, PIPE_SIZE, - &bytesWritten, _0_TO_N); + &bytesWritten, _0_TO_N); if ((rv != RC_FAIL) || (bytesWritten != 0)) { TC_ERROR("Return code: expected %d, got %d\n" - "Bytes written: expected %d, got %d\n", - RC_FAIL, rv, 0, bytesWritten); + "Bytes written: expected %d, got %d\n", + RC_FAIL, rv, 0, bytesWritten); return TC_FAIL; - } + } - /* Wait for AlternateTask()'s pipePutWaitHelper() to finish */ + /* Wait for AlternateTask()'s pipePutWaitHelper() to finish */ (void)task_sem_take_wait(regSem); return TC_PASS; @@ -756,28 +758,28 @@ int pipeGetTest(void) for (j = 0; j < ARRAY_SIZE(options); j++) { for (i = 0; i < ARRAY_SIZE(size); i++) { - rv = task_pipe_get(pipeId, rxBuffer, size[i], - &bytesRead, options[j]); - if (rv != RC_FAIL) { - TC_ERROR("Expected return code %d, not %d\n", RC_FAIL, rv); - return TC_FAIL; - } - } + rv = task_pipe_get(pipeId, rxBuffer, size[i], + &bytesRead, options[j]); + if (rv != RC_FAIL) { + TC_ERROR("Expected return code %d, not %d\n", RC_FAIL, rv); + return TC_FAIL; + } } + } for (i = 0; i < ARRAY_SIZE(size); i++) { rv = task_pipe_get(pipeId, rxBuffer, size[i], - &bytesRead, _0_TO_N); + &bytesRead, _0_TO_N); if (rv != RC_OK) { - TC_ERROR("Expected return code %d, not %d\n", RC_OK, rv); - return TC_FAIL; - } + TC_ERROR("Expected return code %d, not %d\n", RC_OK, rv); + return TC_FAIL; + } if (bytesRead != 0) { - TC_ERROR("Expected <bytesRead> %d, not %d\n", 0, bytesRead); - return TC_FAIL; - } + TC_ERROR("Expected <bytesRead> %d, not %d\n", 0, bytesRead); + return TC_FAIL; } + } return TC_PASS; } @@ -799,22 +801,22 @@ int pipeGetWaitHelperWork(SIZE_EXPECT *items, int nItems) int bytesSent; /* # of bytes sent to task_pipe_put_wait() */ for (i = 0; i < nItems; i++) { - /* - * Pipe should be empty. Most calls to task_pipe_get_wait() should - * block until the call to task_pipe_put() is performed in the routine - * pipeGetWaitHelperWork(). - */ + /* + * Pipe should be empty. Most calls to task_pipe_get_wait() should + * block until the call to task_pipe_put() is performed in the routine + * pipeGetWaitHelperWork(). + */ bytesSent = 0; rv = task_pipe_put_wait(pipeId, rxBuffer, items[i].size, - &bytesSent, items[i].options); + &bytesSent, items[i].options); if ((rv != items[i].rcode) || (bytesSent != items[i].sent)) { - TC_ERROR("Expected return value %d, got %d\n" - "Expected bytesSent = %d, got %d\n", - items[i].rcode, rv, 0, bytesSent); - return TC_FAIL; - } + TC_ERROR("Expected return value %d, got %d\n" + "Expected bytesSent = %d, got %d\n", + items[i].rcode, rv, 0, bytesSent); + return TC_FAIL; } + } return TC_PASS; } @@ -836,13 +838,13 @@ int pipeGetWaitHelper(void) if (rv != TC_PASS) { TC_ERROR("Failed on _ALL_N test\n"); return TC_FAIL; - } + } rv = pipeGetWaitHelperWork(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; - } + } return TC_PASS; } @@ -864,21 +866,21 @@ int pipeGetWaitTestWork(SIZE_EXPECT *items, int nItems) int bytesRead; /* # of bytes read from task_pipe_get_wait() */ for (i = 0; i < nItems; i++) { - /* - * Pipe should be empty. Most calls to task_pipe_get_wait() should - * block until the call to task_pipe_put() is performed in the routine - * pipeGetWaitHelperWork(). - */ + /* + * Pipe should be empty. Most calls to task_pipe_get_wait() should + * block until the call to task_pipe_put() is performed in the routine + * pipeGetWaitHelperWork(). + */ rv = task_pipe_get_wait(pipeId, rxBuffer, items[i].size, - &bytesRead, items[i].options); + &bytesRead, items[i].options); if ((rv != items[i].rcode) || (bytesRead != items[i].sent)) { - TC_ERROR("Expected return value %d, got %d\n" - "Expected bytesRead = %d, got %d\n", - items[i].rcode, rv, 0, bytesRead); - return TC_FAIL; - } + TC_ERROR("Expected return value %d, got %d\n" + "Expected bytesRead = %d, got %d\n", + items[i].rcode, rv, 0, bytesRead); + return TC_FAIL; } + } return TC_PASS; } @@ -901,20 +903,20 @@ int pipeGetWaitTest(void) 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); + &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; } @@ -934,17 +936,17 @@ int pipeGetTimeoutTest(void) for (i = 0; i < ARRAY_SIZE(timeout_cases); i++) { rv = task_pipe_get_wait_timeout(pipeId, rxBuffer, timeout_cases[i].size, - &bytesRead, timeout_cases[i].options, ONE_SECOND); + &bytesRead, timeout_cases[i].options, ONE_SECOND); if ((rv != timeout_cases[i].rcode) || - (bytesRead != timeout_cases[i].sent)) { - TC_ERROR("Expected return code %d, got %d\n" - "Expected <bytesRead> %d, got %d\n" - "Iteration %d\n", - timeout_cases[i].rcode, rv, timeout_cases[i].sent, - bytesRead, i + 1); - return TC_FAIL; - } + (bytesRead != timeout_cases[i].sent)) { + TC_ERROR("Expected return code %d, got %d\n" + "Expected <bytesRead> %d, got %d\n" + "Iteration %d\n", + timeout_cases[i].rcode, rv, timeout_cases[i].sent, + bytesRead, i + 1); + return TC_FAIL; } + } return TC_PASS; } @@ -965,33 +967,33 @@ int AlternateTask(void) rv = pipePutHelper(); if (rv != TC_PASS) { return TC_FAIL; - } + } rv = pipePutWaitHelper(); if (rv != TC_PASS) { return TC_FAIL; - } + } rv = pipePutTimeoutHelper(); if (rv != TC_PASS) { return TC_FAIL; - } + } - /* - * There is no pipeGetHelper() as the task_pipe_get() checks have - * either been done in pipePutHelper(), or pipeGetTest(). - */ + /* + * There is no pipeGetHelper() as the task_pipe_get() checks have + * either been done in pipePutHelper(), or pipeGetTest(). + */ rv = pipeGetWaitHelper(); if (rv != TC_PASS) { return TC_FAIL; - } + } - /* - * There is no pipeGetTimeoutHelper() as the task_pipe_get_wait_timeout() checks - * have either been done in pipePutTimeoutHelper() or - * pipeGetTimeoutTest(). - */ + /* + * There is no pipeGetTimeoutHelper() as the task_pipe_get_wait_timeout() checks + * have either been done in pipePutTimeoutHelper() or + * pipeGetTimeoutTest(). + */ return TC_PASS; } @@ -1014,38 +1016,38 @@ int RegressionTask(void) TC_PRINT("Testing task_pipe_put() ...\n"); tcRC = pipePutTest(); if (tcRC != TC_PASS) { - return TC_FAIL; - } + return TC_FAIL; + } TC_PRINT("Testing task_pipe_put_wait() ...\n"); tcRC = pipePutWaitTest(); if (tcRC != TC_PASS) { - return TC_FAIL; - } + return TC_FAIL; + } TC_PRINT("Testing task_pipe_put_wait_timeout() ...\n"); tcRC = pipePutTimeoutTest(); if (tcRC != TC_PASS) { - return TC_FAIL; - } + return TC_FAIL; + } TC_PRINT("Testing task_pipe_get() ...\n"); tcRC = pipeGetTest(); if (tcRC != TC_PASS) { - return TC_FAIL; - } + return TC_FAIL; + } TC_PRINT("Testing task_pipe_get_wait() ...\n"); tcRC = pipeGetWaitTest(); if (tcRC != TC_PASS) { - return TC_FAIL; - } + return TC_FAIL; + } TC_PRINT("Testing task_pipe_get_wait_timeout() ...\n"); tcRC = pipeGetTimeoutTest(); if (tcRC != TC_PASS) { - return TC_FAIL; - } + return TC_FAIL; + } return TC_PASS; } diff --git a/samples/microkernel/test/test_pool/src/pool.c b/samples/microkernel/test/test_pool/src/pool.c index bf64de768..2a00c704b 100644 --- a/samples/microkernel/test/test_pool/src/pool.c +++ b/samples/microkernel/test/test_pool/src/pool.c @@ -59,7 +59,7 @@ This modules tests the following memory pool routines: typedef struct { struct k_block *block; /* pointer to block data */ - kmemory_pool_t poolId; /* pool ID */ + kmemory_pool_t poolId; /* pool ID */ int size; /* request size in bytes */ int32_t timeout; /* # of ticks to wait */ int rcode; /* expected return code */ diff --git a/samples/microkernel/test/test_secure_string_api/src/secure.c b/samples/microkernel/test/test_secure_string_api/src/secure.c index f1eef4ded..57e552267 100644 --- a/samples/microkernel/test/test_secure_string_api/src/secure.c +++ b/samples/microkernel/test/test_secure_string_api/src/secure.c @@ -58,43 +58,46 @@ This modules tests the following secure routines: */ void MainTask(void) - { +{ int result; - /* wait for the first task to start */ + /* wait for the first task to start */ result = task_sem_take_wait_timeout(SEMA1, WAIT_TOUT); if (result != RC_OK) { - TC_ERROR("Test task 1 did not start properly\n"); - goto fail; + TC_ERROR("Test task 1 did not start properly\n"); + goto fail; } - /* now we check the first task to perform the test and die */ + + /* now we check the first task to perform the test and die */ result = task_sem_take_wait_timeout(SEMA1, WAIT_TOUT); if (result == RC_TIME) { - TC_PRINT("As expected, test task 1 did not continue operating \n"); - TC_PRINT("after calling memcpy_s with incorrect parameters\n"); + TC_PRINT("As expected, test task 1 did not continue operating \n"); + TC_PRINT("after calling memcpy_s with incorrect parameters\n"); } else { - TC_ERROR("Test task 1 unexpectedly continued\n" - "after calling memcpy_s with incorrect parameters\n"); - goto fail; + TC_ERROR("Test task 1 unexpectedly continued\n" + "after calling memcpy_s with incorrect parameters\n"); + goto fail; } - /* wait for the second task to start */ + /* wait for the second task to start */ result = task_sem_take_wait_timeout(SEMA2, WAIT_TOUT); if (result != RC_OK) { - TC_ERROR("Test task 2 did not start properly\n"); - goto fail; + TC_ERROR("Test task 2 did not start properly\n"); + goto fail; } - /* now we check the second task to perform the test and die */ + + /* now we check the second task to perform the test and die */ result = task_sem_take_wait_timeout(SEMA2, WAIT_TOUT); if (result == RC_TIME) { - TC_PRINT("As expected, test task 2 did not continue operating \n"); - TC_PRINT("after calling strcpy_s with incorrect parameters\n"); + TC_PRINT("As expected, test task 2 did not continue operating \n"); + TC_PRINT("after calling strcpy_s with incorrect parameters\n"); } else { - TC_ERROR("Test task 2 unexpectedly continued\n" - "after calling memcpy_s with incorrect parameters\n"); - goto fail; + TC_ERROR("Test task 2 unexpectedly continued\n" + "after calling memcpy_s with incorrect parameters\n"); + goto fail; } + TC_END_RESULT(TC_PASS); TC_END_REPORT(TC_PASS); return; @@ -102,7 +105,7 @@ void MainTask(void) fail: TC_END_RESULT(TC_FAIL); TC_END_REPORT(TC_FAIL); - } +} /******************************************************************************* * @@ -113,18 +116,19 @@ fail: * RETURNS: N/A */ void MemcpyTask(void) - { +{ uint8_t buf1[BUFSIZE]; uint8_t buf2[BUFSIZE + 1]; - /* do correct memory copy */ + /* do correct memory copy */ k_memcpy_s(buf2, sizeof(buf2), buf1, sizeof(buf1)); task_sem_give(SEMA1); task_yield(); - /* do incorrect memory copy */ + + /* do incorrect memory copy */ k_memcpy_s(buf1, sizeof(buf1), buf2, sizeof(buf2)); task_sem_give(SEMA1); - } +} /******************************************************************************* * @@ -135,22 +139,22 @@ void MemcpyTask(void) * RETURNS: N/A */ void StrcpyTask(void) - { +{ char buf1[BUFSIZE]; - char buf2[BUFSIZE] = { '1', '2', '3', '4', '5', - '6', '7', '8', '9', 0 }; + char buf2[BUFSIZE] = { '1', '2', '3', '4', '5', '6', '7', '8', '9', 0 }; - /* do correct string copy */ + /* do correct string copy */ strcpy_s(buf1, sizeof(buf1), buf2); task_sem_give(SEMA2); task_yield(); - /* - * Make the string not \0 terminated as a result - * strcpy_s has to make an error - */ + /* + * Make the string not \0 terminated as a result + * strcpy_s has to make an error + */ buf2[BUFSIZE - 1] = '0'; - /* do incorrect string copy */ + + /* do incorrect string copy */ strcpy_s(buf1, sizeof(buf1), buf2); task_sem_give(SEMA2); - } +} diff --git a/samples/microkernel/test/test_sema/src/main.c b/samples/microkernel/test/test_sema/src/main.c index 7b893af9d..49b96aa6f 100644 --- a/samples/microkernel/test/test_sema/src/main.c +++ b/samples/microkernel/test/test_sema/src/main.c @@ -249,22 +249,22 @@ void MonitorTaskEntry(void) PRINT_DATA("Starting semaphore tests\n"); PRINT_LINE; - /* - * the various test tasks start executing automatically; - * wait for all tasks to complete or a failure to occur, - * then issue the appropriate test case summary message - */ + /* + * the various test tasks start executing automatically; + * wait for all tasks to complete or a failure to occur, + * then issue the appropriate test case summary message + */ for (tasksDone = 0; tasksDone < NUM_TEST_TASKS; tasksDone++) { - result = task_sem_group_take_wait_timeout(resultSems, SECONDS(60)); - if (result != resultSems[TC_PASS]) { - if (result != resultSems[TC_FAIL]) { - TC_ERROR("Monitor task timed out\n"); + result = task_sem_group_take_wait_timeout(resultSems, SECONDS(60)); + if (result != resultSems[TC_PASS]) { + if (result != resultSems[TC_FAIL]) { + TC_ERROR("Monitor task timed out\n"); + } + TC_END_RESULT(TC_FAIL); + TC_END_REPORT(TC_FAIL); + return; } - TC_END_RESULT(TC_FAIL); - TC_END_REPORT(TC_FAIL); - return; - } } TC_END_RESULT(TC_PASS); diff --git a/samples/microkernel/test/test_sema/src/sema.c b/samples/microkernel/test/test_sema/src/sema.c index a582ae6e0..bc5255048 100644 --- a/samples/microkernel/test/test_sema/src/sema.c +++ b/samples/microkernel/test/test_sema/src/sema.c @@ -81,15 +81,15 @@ extern ksem_t semList[]; */ int simpleSemaTest(void) - { +{ int signalCount; int i; int status; - /* - * Signal the semaphore several times from an ISR. After each signal, - * check the signal count. - */ + /* + * Signal the semaphore several times from an ISR. After each signal, + * check the signal count. + */ for (i = 0; i < 5; i++) { trigger_isrSemaSignal(simpleSem); @@ -97,74 +97,74 @@ int simpleSemaTest(void) task_sleep(10); /* Time for low priority task to run. */ signalCount = task_sem_count_get(simpleSem); if (signalCount != (i + 1)) { - TC_ERROR("<signalCount> error. Expected %d, got %d\n", - i + 1, signalCount); - return TC_FAIL; - } + TC_ERROR("<signalCount> error. Expected %d, got %d\n", + i + 1, signalCount); + return TC_FAIL; } + } - /* - * Signal the semaphore several times from a task. After each signal, - * check the signal count. - */ + /* + * Signal the semaphore several times from a task. After each signal, + * check the signal count. + */ for (i = 5; i < 10; i++) { task_sem_give(simpleSem); signalCount = task_sem_count_get(simpleSem); if (signalCount != (i + 1)) { - TC_ERROR("<signalCount> error. Expected %d, got %d\n", - i + 1, signalCount); - return TC_FAIL; - } + TC_ERROR("<signalCount> error. Expected %d, got %d\n", + i + 1, signalCount); + return TC_FAIL; } + } - /* - * Test the semaphore without wait. Check the signal count after each - * attempt (it should be decrementing by 1 each time). - */ + /* + * Test the semaphore without wait. Check the signal count after each + * attempt (it should be decrementing by 1 each time). + */ for (i = 9; i >= 4; i--) { status = task_sem_take(simpleSem); if (status != RC_OK) { - TC_ERROR("task_sem_take(SIMPLE_SEM) error. Expected %d, not %d.\n", - RC_OK, status); - return TC_FAIL; - } + TC_ERROR("task_sem_take(SIMPLE_SEM) error. Expected %d, not %d.\n", + RC_OK, status); + return TC_FAIL; + } signalCount = task_sem_count_get(simpleSem); if (signalCount != i) { - TC_ERROR("<signalCount> error. Expected %d, not %d\n", - i, signalCount); - return TC_FAIL; - } + TC_ERROR("<signalCount> error. Expected %d, not %d\n", + i, signalCount); + return TC_FAIL; } + } task_sem_reset(simpleSem); - /* - * The semaphore's signal count should now be zero (0). Test the - * semaphore without wait. It should fail. - */ + /* + * The semaphore's signal count should now be zero (0). Test the + * semaphore without wait. It should fail. + */ for (i = 0; i < 10; i++) { status = task_sem_take(simpleSem); if (status != RC_FAIL) { - TC_ERROR("task_sem_take(SIMPLE_SEM) error. Expected %d, got %d.\n", - RC_FAIL, status); - return TC_FAIL; - } + TC_ERROR("task_sem_take(SIMPLE_SEM) error. Expected %d, got %d.\n", + RC_FAIL, status); + return TC_FAIL; + } signalCount = task_sem_count_get(simpleSem); if (signalCount != 0) { - TC_ERROR("<signalCount> error. Expected %d, not %d\n", - 0, signalCount); - return TC_FAIL; - } + TC_ERROR("<signalCount> error. Expected %d, not %d\n", + 0, signalCount); + return TC_FAIL; } + } return TC_PASS; - } +} /******************************************************************************* * @@ -174,55 +174,55 @@ int simpleSemaTest(void) */ int simpleSemaWaitTest(void) - { +{ int status; int i; for (i = 0; i < 5; i++) { - /* Wait one second for SIMPLE_SEM. Timeout is expected. */ + /* Wait one second for SIMPLE_SEM. Timeout is expected. */ status = task_sem_take_wait_timeout(simpleSem, OBJ_TIMEOUT); if (status != RC_TIME) { - TC_ERROR("task_sem_take_wait_timeout() error. Expected %d, got %d\n", - RC_TIME, status); - return TC_FAIL; - } + TC_ERROR("task_sem_take_wait_timeout() error. Expected %d, got %d\n", + RC_TIME, status); + return TC_FAIL; } + } - /* - * Signal the semaphore upon which the alternate task is waiting. The - * alternate task (which is at a lower priority) will cause SIMPLE_SEM - * to be signalled, thus waking this task. - */ + /* + * Signal the semaphore upon which the alternate task is waiting. The + * alternate task (which is at a lower priority) will cause SIMPLE_SEM + * to be signalled, thus waking this task. + */ task_sem_give(altSem); status = task_sem_take_wait_timeout(simpleSem, OBJ_TIMEOUT); if (status != RC_OK) { TC_ERROR("task_sem_take_wait_timeout() error. Expected %d, got %d\n", - RC_OK, status); + RC_OK, status); return TC_FAIL; - } + } - /* - * Note that task_sem_take_wait() has been tested when waking up the alternate - * task. Since previous tests had this task waiting, the alternate task - * must have had the time to enter the state where it is waiting for the - * ALTTASK_SEM semaphore to be given. Thus, we do not need to test for - * it here. - * - * Now wait on SIMPLE_SEM again. This time it will be woken up by an - * ISR signalling the semaphore. - */ + /* + * Note that task_sem_take_wait() has been tested when waking up the alternate + * task. Since previous tests had this task waiting, the alternate task + * must have had the time to enter the state where it is waiting for the + * ALTTASK_SEM semaphore to be given. Thus, we do not need to test for + * it here. + * + * Now wait on SIMPLE_SEM again. This time it will be woken up by an + * ISR signalling the semaphore. + */ status = task_sem_take_wait_timeout(simpleSem, OBJ_TIMEOUT); if (status != RC_OK) { TC_ERROR("task_sem_take_wait_timeout() error. Expected %d, got %d\n", - RC_OK, status); + RC_OK, status); return TC_FAIL; - } + } return TC_PASS; - } +} /******************************************************************************* * @@ -232,77 +232,77 @@ int simpleSemaWaitTest(void) */ int simpleGroupTest(void) - { +{ int i; int j; int status; ksem_t value; - /* Ensure that the semaphores in the group are reset */ + /* Ensure that the semaphores in the group are reset */ task_sem_group_reset(semList); for (i = 0; semList[i] != ENDLIST; i++) { status = task_sem_count_get(semList[i]); if (status != 0) { - TC_ERROR("task_sem_count_get() returned %d not %d\n", status, 0); - return TC_FAIL; - } + TC_ERROR("task_sem_count_get() returned %d not %d\n", status, 0); + return TC_FAIL; } + } - /* Timeout while waiting for a semaphore from the group */ + /* Timeout while waiting for a semaphore from the group */ value = task_sem_group_take_wait_timeout(semList, OBJ_TIMEOUT); if (value != ENDLIST) { TC_ERROR("task_sem_group_take_wait_timeout() returned %d not %d\n", - value, ENDGROUP); + value, ENDGROUP); return TC_FAIL; - } + } - /* Signal the semaphores in the group */ + /* Signal the semaphores in the group */ for (i = 0; i < 10; i++) { task_sem_group_give(semList); for (j = 0; semList[j] != ENDLIST; j++) { - status = task_sem_count_get(semList[j]); - if (status != i + 1) { - TC_ERROR("task_sem_count_get() returned %d not %d\n", - status, i + 1); - return TC_FAIL; - } - } + status = task_sem_count_get(semList[j]); + if (status != i + 1) { + TC_ERROR("task_sem_count_get() returned %d not %d\n", + status, i + 1); + return TC_FAIL; + } } + } - /* Get the semaphores */ + /* Get the semaphores */ for (i = 9; i >= 5; i--) { value = task_sem_group_take_wait_timeout(semList, 0); for (j = 0; semList[j] != ENDLIST; j++) { - status = task_sem_count_get(semList[j]); - if (status != (value == semList[j] ? i : 10)) { - TC_ERROR("task_sem_count_get(0x%x) returned %d not %d\n", - semList[j], status, (value == semList[j]) ? i : 10); - return TC_FAIL; - } - } + status = task_sem_count_get(semList[j]); + if (status != (value == semList[j] ? i : 10)) { + TC_ERROR("task_sem_count_get(0x%x) returned %d not %d\n", + semList[j], status, (value == semList[j]) ? i : 10); + return TC_FAIL; + } } + } - /* Reset the semaphores in the group */ + /* Reset the semaphores in the group */ task_sem_group_reset(semList); for (i = 0; semList[i] != ENDLIST; i++) { status = task_sem_count_get(semList[i]); if (status != 0) { - TC_ERROR("task_sem_count_get() returned %d not %d\n", status, 0); - return TC_FAIL; - } + TC_ERROR("task_sem_count_get() returned %d not %d\n", status, 0); + return TC_FAIL; } + } return TC_PASS; - } +} /******************************************************************************* * @@ -315,57 +315,57 @@ int simpleGroupTest(void) */ int simpleGroupWaitTest(void) - { +{ int i; ksem_t sema; task_sem_give(altSem); /* Wake the alternate task */ - /* - * Wait for a semaphore to be signalled by the alternate task. - * Each semaphore in the group will be tested. - */ + /* + * Wait for a semaphore to be signalled by the alternate task. + * Each semaphore in the group will be tested. + */ for (i = 0; semList[i] != ENDLIST; i++) { sema = task_sem_group_take_wait(semList); if (sema != semList[i]) { - TC_ERROR("task_sem_group_take_wait() error. Expected %d, not %d\n", - (int) semList[i], (int) sema); - return TC_FAIL; - } + TC_ERROR("task_sem_group_take_wait() error. Expected %d, not %d\n", + (int) semList[i], (int) sema); + return TC_FAIL; } + } - /* - * The Alternate Task will signal the semaphore group once. Note that - * when the semaphore group is signalled, the last semaphore in the - * group is the value that is returned, not the first. - */ + /* + * The Alternate Task will signal the semaphore group once. Note that + * when the semaphore group is signalled, the last semaphore in the + * group is the value that is returned, not the first. + */ for (i = 3; i >= 0; i--) { sema = task_sem_group_take_wait(semList); if (sema != semList[i]) { - TC_ERROR("task_sem_group_take_wait() error. Expected %d, not %d\n", - (int) semList[3], (int) sema); - return TC_FAIL; - } + TC_ERROR("task_sem_group_take_wait() error. Expected %d, not %d\n", + (int) semList[3], (int) sema); + return TC_FAIL; } + } - /* - * Again wait for a semaphore to be signalled. This time, the alternate - * task will trigger an interrupt that signals the semaphore. - */ + /* + * Again wait for a semaphore to be signalled. This time, the alternate + * task will trigger an interrupt that signals the semaphore. + */ for (i = 0; semList[i] != ENDLIST; i++) { sema = task_sem_group_take_wait(semList); if (sema != semList[i]) { - TC_ERROR("task_sem_group_take_wait() error. Expected %d, not %d\n", - (int) semList[i], (int) sema); - return TC_FAIL; - } + TC_ERROR("task_sem_group_take_wait() error. Expected %d, not %d\n", + (int) semList[i], (int) sema); + return TC_FAIL; } + } return TC_PASS; - } +} /******************************************************************************* * @@ -382,7 +382,7 @@ int simpleGroupWaitTest(void) * RETURNS: TC_PASS on success or TC_FAIL on failure */ static int simpleFiberSemTest(void) - { +{ int signalCount; int status; int i; @@ -391,36 +391,36 @@ static int simpleFiberSemTest(void) task_sem_reset(simpleSem); task_sem_group_reset(semList); - /* let the fiber signal the semaphore and wait on it */ + /* let the fiber signal the semaphore and wait on it */ releaseTestFiber(); status = task_sem_take_wait_timeout(simpleSem, OBJ_TIMEOUT); if (status != RC_OK) { - TC_ERROR("task_sem_take_wait_timeout() error. Expected %d, got %d\n", - RC_OK, status); - return TC_FAIL; + TC_ERROR("task_sem_take_wait_timeout() error. Expected %d, got %d\n", + RC_OK, status); + return TC_FAIL; } - /* release the fiber and let it signal the semaphore N_TESTS times */ + /* release the fiber and let it signal the semaphore N_TESTS times */ releaseTestFiber(); signalCount = task_sem_count_get(simpleSem); if (signalCount != N_TESTS) { - TC_ERROR("<signalCount> error. Expected %d, got %d\n", - N_TESTS, signalCount); - return TC_FAIL; + TC_ERROR("<signalCount> error. Expected %d, got %d\n", + N_TESTS, signalCount); + return TC_FAIL; } - /* wait on the semaphore group while the fiber signals each semaphore in it */ + /* wait on the semaphore group while the fiber signals each semaphore in it */ for (i = 0; semList[i] != ENDLIST; i++) { - releaseTestFiber(); + releaseTestFiber(); sema = task_sem_group_take_wait_timeout(semList, OBJ_TIMEOUT); if (sema != semList[i]) { - TC_ERROR("task_sem_group_take_wait() error. Expected %d, not %d\n", - (int) semList[i], (int) sema); - return TC_FAIL; - } + TC_ERROR("task_sem_group_take_wait() error. Expected %d, not %d\n", + (int) semList[i], (int) sema); + return TC_FAIL; } - return TC_PASS; } + return TC_PASS; +} /******************************************************************************* * @@ -430,31 +430,31 @@ static int simpleFiberSemTest(void) */ int HighPriTask(void) - { +{ int status; - /* Wait until task is activated */ + /* Wait until task is activated */ status = task_sem_take_wait(hpSem); if (status != RC_OK) { TC_ERROR("%s priority task failed to wait on %s: %d\n", - "High", "HIGH_PRI_SEM", status); + "High", "HIGH_PRI_SEM", status); return TC_FAIL; - } + } - /* Wait on a semaphore along with other tasks */ + /* Wait on a semaphore along with other tasks */ status = task_sem_take_wait(manyBlockSem); if (status != RC_OK) { TC_ERROR("%s priority task failed to wait on %s: %d\n", - "High", "MANY_BLOCKED_SEM", status); + "High", "MANY_BLOCKED_SEM", status); return TC_FAIL; - } + } - /* Inform Regression test HP task is no longer blocked on MANY_BLOCKED_SEM*/ + /* Inform Regression test HP task is no longer blocked on MANY_BLOCKED_SEM*/ task_sem_give(blockHpSem); return TC_PASS; - } +} /******************************************************************************* * @@ -464,22 +464,22 @@ int HighPriTask(void) */ int LowPriTask(void) - { +{ int status; - /* Wait on a semaphore along with other tasks */ + /* Wait on a semaphore along with other tasks */ status = task_sem_take_wait(manyBlockSem); if (status != RC_OK) { TC_ERROR("%s priority task failed to wait on %s: %d\n", - "Low", "MANY_BLOCKED_SEM", status); + "Low", "MANY_BLOCKED_SEM", status); return TC_FAIL; - } + } - /* Inform Regression test LP task is no longer blocked on MANY_BLOCKED_SEM*/ + /* Inform Regression test LP task is no longer blocked on MANY_BLOCKED_SEM*/ task_sem_give(blockLpSem); return TC_PASS; - } +} /******************************************************************************* * @@ -491,74 +491,74 @@ int LowPriTask(void) */ int AlternateTask(void) - { +{ int status; int i; - /* Wait until it is time to continue */ + /* Wait until it is time to continue */ status = task_sem_take_wait(altSem); if (status != RC_OK) { TC_ERROR("task_sem_take_wait() error. Expected %d, got %d\n", - RC_OK, status); + RC_OK, status); return TC_FAIL; - } + } - /* - * After signalling the semaphore upon which the main (RegressionTask) task - * is waiting, control will pass back to the main (RegressionTask) task. - */ + /* + * After signalling the semaphore upon which the main (RegressionTask) task + * is waiting, control will pass back to the main (RegressionTask) task. + */ task_sem_give(simpleSem); - /* - * Control has returned to the alternate task. Trigger an ISR that will - * signal the semaphore upon which RegressionTask is waiting. - */ + /* + * Control has returned to the alternate task. Trigger an ISR that will + * signal the semaphore upon which RegressionTask is waiting. + */ trigger_isrSemaSignal(simpleSem); - /* Wait for RegressionTask to wake this task up */ + /* Wait for RegressionTask to wake this task up */ status = task_sem_take_wait(altSem); if (status != RC_OK) { TC_ERROR("task_sem_take_wait() error. Expected %d, got %d", - RC_OK, status); + RC_OK, status); return TC_FAIL; - } + } - /* Wait on a semaphore that will have many waiters */ + /* Wait on a semaphore that will have many waiters */ status = task_sem_take_wait(manyBlockSem); if (status != RC_OK) { TC_ERROR("task_sem_take_wait() error. Expected %d, got %d", - RC_OK, status); + RC_OK, status); return TC_FAIL; - } + } - /* Inform Regression test MP task is no longer blocked on MANY_BLOCKED_SEM*/ + /* Inform Regression test MP task is no longer blocked on MANY_BLOCKED_SEM*/ task_sem_give(blockMpSem); - /* Wait until the alternate task is needed again */ + /* Wait until the alternate task is needed again */ status = task_sem_take_wait(altSem); if (status != RC_OK) { TC_ERROR("task_sem_take_wait() error. Expected %d, got %d", - RC_OK, status); + RC_OK, status); return TC_FAIL; - } + } for (i = 0; semList[i] != ENDLIST; i++) { task_sem_give(semList[i]); - /* Context switch back to Regression Task */ - } + /* Context switch back to Regression Task */ + } task_sem_group_give(semList); - /* Context switch back to Regression Task */ + /* Context switch back to Regression Task */ for (i = 0; semList[i] != ENDLIST; i++) { trigger_isrSemaSignal(semList[i]); - /* Context switch back to Regression Task */ - } + /* Context switch back to Regression Task */ + } return TC_PASS; - } +} /******************************************************************************* * @@ -570,7 +570,7 @@ int AlternateTask(void) */ int RegressionTask(void) - { +{ int tcRC; int value; ksem_t semBlockList[4]; @@ -580,31 +580,31 @@ int RegressionTask(void) semBlockList[2] = blockLpSem; semBlockList[3] = ENDLIST; - /* Signal a semaphore that has no waiting tasks. */ + /* Signal a semaphore that has no waiting tasks. */ TC_PRINT("Signal and test a semaphore without blocking\n"); tcRC = simpleSemaTest(); if (tcRC != TC_PASS) { return TC_FAIL; - } + } - /* Wait on a semaphore. */ + /* Wait on a semaphore. */ TC_PRINT("Signal and test a semaphore with blocking\n"); tcRC = simpleSemaWaitTest(); if (tcRC != TC_PASS) { - return TC_FAIL; - } + return TC_FAIL; + } - /* - * Have many tasks wait on a semaphore (MANY_BLOCKED_SEM). They will - * block in the following order: - * LowPriorityTask (low priority) - * HighPriorityTask (high priority) - * AlternateTask (medium priority) - * - * When the semaphore (MANY_BLOCKED_SEM) is signalled, HighPriorityTask - * will be woken first. - * - */ + /* + * Have many tasks wait on a semaphore (MANY_BLOCKED_SEM). They will + * block in the following order: + * LowPriorityTask (low priority) + * HighPriorityTask (high priority) + * AlternateTask (medium priority) + * + * When the semaphore (MANY_BLOCKED_SEM) is signalled, HighPriorityTask + * will be woken first. + * + */ TC_PRINT("Testing many tasks blocked on the same semaphore\n"); @@ -619,18 +619,18 @@ int RegressionTask(void) value = task_sem_group_take_wait_timeout(semBlockList, OBJ_TIMEOUT); if (value != blockHpSem) { TC_ERROR("%s priority task did not get semaphore: 0x%x\n", - "High", value); + "High", value); return TC_FAIL; - } + } task_sem_give(manyBlockSem); task_sleep(OBJ_TIMEOUT); /* Ensure medium priority task can run */ value = task_sem_group_take_wait_timeout(semBlockList, OBJ_TIMEOUT); if (value != blockMpSem) { TC_ERROR("%s priority task did not get semaphore: 0x%x\n", - "Medium", value); + "Medium", value); return TC_FAIL; - } + } task_sem_give(manyBlockSem); @@ -639,35 +639,35 @@ int RegressionTask(void) value = task_sem_group_take_wait_timeout(semBlockList, OBJ_TIMEOUT); if (value != blockLpSem) { TC_ERROR("%s priority task did not get semaphore: 0x%x\n", - "Low", value); + "Low", value); return TC_FAIL; - } + } value = task_sem_group_take_wait_timeout(semBlockList, OBJ_TIMEOUT); if (value != ENDLIST) { TC_ERROR("Group test Expecting ENDLIST, but got 0x%x\n", - value); + value); return TC_FAIL; - } + } TC_PRINT("Testing semaphore groups without blocking\n"); tcRC = simpleGroupTest(); if (tcRC != TC_PASS) { - return TC_FAIL; - } + return TC_FAIL; + } TC_PRINT("Testing semaphore groups with blocking\n"); tcRC = simpleGroupWaitTest(); if (tcRC != TC_PASS) { - return TC_FAIL; - } + return TC_FAIL; + } TC_PRINT("Testing semaphore release by fiber\n"); tcRC = simpleFiberSemTest(); if (tcRC != TC_PASS) { - return TC_FAIL; - } + return TC_FAIL; + } return TC_PASS; - } +} diff --git a/samples/microkernel/test/test_sema/src/test_fiber.c b/samples/microkernel/test/test_sema/src/test_fiber.c index be7fd1add..24d44f7da 100644 --- a/samples/microkernel/test/test_sema/src/test_fiber.c +++ b/samples/microkernel/test/test_sema/src/test_fiber.c @@ -72,24 +72,24 @@ static CMD_PKT_SET_INSTANCE(cmdPktSet, N_TESTS + 1) * RETURNS: N/A */ static void testFiberEntry(void) - { +{ int i; - /* release semaphore test task is waiting for */ + /* release semaphore test task is waiting for */ nano_fiber_sem_take_wait(&fiberSem); fiber_sem_give(simpleSem, &CMD_PKT_SET(cmdPktSet)); - /* release the semaphore for N_TESTS times */ + /* release the semaphore for N_TESTS times */ nano_fiber_sem_take_wait(&fiberSem); for (i = 0; i < N_TESTS; i++) { - fiber_sem_give(simpleSem, &CMD_PKT_SET(cmdPktSet)); + fiber_sem_give(simpleSem, &CMD_PKT_SET(cmdPktSet)); } - /* signal each semaphore in the group */ + /* signal each semaphore in the group */ for (i = 0; semList[i] != ENDLIST; i++) { - nano_fiber_sem_take_wait(&fiberSem); - fiber_sem_give(semList[i], &CMD_PKT_SET(cmdPktSet)); - } + nano_fiber_sem_take_wait(&fiberSem); + fiber_sem_give(semList[i], &CMD_PKT_SET(cmdPktSet)); } +} /******************************************************************************* * @@ -99,8 +99,8 @@ static void testFiberEntry(void) */ void testFiberInit(void) - { +{ nano_sem_init(&fiberSem); task_fiber_start(fiberStack, FIBER_STACK_SIZE, (nano_fiber_entry_t)testFiberEntry, 0, 0, FIBER_PRIORITY, 0); - } +} diff --git a/samples/microkernel/test/test_sprintf/src/test_sprintf.c b/samples/microkernel/test/test_sprintf/src/test_sprintf.c index 367e3f9a1..02805f303 100644 --- a/samples/microkernel/test/test_sprintf/src/test_sprintf.c +++ b/samples/microkernel/test/test_sprintf/src/test_sprintf.c @@ -75,8 +75,8 @@ typedef union { struct { uint32_t u1; /* This part contains the exponent */ uint32_t u2; /* This part contains the fraction */ - }; - } raw_double_u; + }; +} raw_double_u; #ifdef CONFIG_FLOAT /******************************************************************************* @@ -98,7 +98,7 @@ int sprintfDoubleTest(void) if (strcmp(buffer, "+INF") != 0) { TC_ERROR("sprintf(+INF) - incorrect output '%s'\n", buffer); status = TC_FAIL; - } + } var.u1 = 0x00000000; var.u2 = 0xfff00000; /* Bit pattern for -INF (double) */ @@ -106,7 +106,7 @@ int sprintfDoubleTest(void) if (strcmp(buffer, "-INF") != 0) { TC_ERROR("sprintf(-INF) - incorrect output '%s'\n", buffer); status = TC_FAIL; - } + } var.u1 = 0x00000000; var.u2 = 0x7ff80000; /* Bit pattern for NaN (double) */ @@ -114,123 +114,122 @@ int sprintfDoubleTest(void) if (strcmp(buffer, "NaN") != 0) { TC_ERROR("sprintf(NaN) - incorrect output '%s'\n", buffer); status = TC_FAIL; - } + } var.d = 1.0; sprintf(buffer, "%f", var.d); if (strcmp(buffer, "1.000000") != 0) { TC_ERROR("sprintf(1.0) - incorrect output '%s'\n", buffer); status = TC_FAIL; - } + } sprintf(buffer, "%+f", var.d); if (strcmp(buffer, "+1.000000") != 0) { TC_ERROR("sprintf(+1.0) - incorrect output '%s'\n", buffer); status = TC_FAIL; - } + } sprintf(buffer, "%.2f", var.d); if (strcmp(buffer, "1.00") != 0) { TC_ERROR("sprintf(1.00) - incorrect output '%s'\n", buffer); status = TC_FAIL; - } + } sprintf(buffer, "%.*f", 11, var.d); if (strcmp(buffer, "1.00000000000") != 0) { TC_ERROR("sprintf(1.00000000000) - incorrect output '%s'\n", buffer); status = TC_FAIL; - } + } sprintf(buffer, "%12f", var.d); if (strcmp(buffer, " 1.000000") != 0) { TC_ERROR("sprintf( 1.000000) - incorrect output '%s'\n", buffer); status = TC_FAIL; - } + } sprintf(buffer, "%-12f", var.d); if (strcmp(buffer, "1.000000 ") != 0) { TC_ERROR("sprintf(1.000000 ) - incorrect output '%s'\n", buffer); status = TC_FAIL; - } + } sprintf(buffer, "%012f", var.d); if (strcmp(buffer, "00001.000000") != 0) { TC_ERROR("sprintf(00001.000000) - incorrect output '%s'\n", buffer); status = TC_FAIL; - } + } var.d = -1.0; sprintf(buffer, "%f", var.d); if (strcmp(buffer, "-1.000000") != 0) { TC_ERROR("sprintf(-1.0) - incorrect output '%s'\n", buffer); status = TC_FAIL; - } + } var.d = 1234.56789; sprintf(buffer, "%f", var.d); if (strcmp(buffer, "1234.567890") != 0) { TC_ERROR("sprintf(-1.0) - incorrect output '%s'\n", buffer); status = TC_FAIL; - } + } - /*******************/ + /*******************/ var.d = 1234.0; sprintf(buffer, "%e", var.d); if (strcmp(buffer, "1.234000e+003") != 0) { TC_ERROR("sprintf(1.234000e+003) - incorrect output '%s'\n", buffer); status = TC_FAIL; - } + } sprintf(buffer, "%E", var.d); if (strcmp(buffer, "1.234000E+003") != 0) { TC_ERROR("sprintf(1.234000E+003) - incorrect output '%s'\n", buffer); status = TC_FAIL; - } + } - /*******************/ + /*******************/ var.d = 0.1234; sprintf(buffer, "%e", var.d); if (strcmp(buffer, "1.234000e-001") != 0) { TC_ERROR("sprintf(1.234000e-001) - incorrect output '%s'\n", buffer); status = TC_FAIL; - } + } sprintf(buffer, "%E", var.d); if (strcmp(buffer, "1.234000E-001") != 0) { TC_ERROR("sprintf(1.234000E-001) - incorrect output '%s'\n", buffer); status = TC_FAIL; - } + } - /*******************/ + /*******************/ var.d = 1234000000.0; sprintf(buffer, "%g", var.d); if (strcmp(buffer, "1.234e+009") != 0) { TC_ERROR("sprintf(1.234e+009) - incorrect output '%s'\n", buffer); status = TC_FAIL; - } + } sprintf(buffer, "%G", var.d); if (strcmp(buffer, "1.234E+009") != 0) { TC_ERROR("sprintf(1.234E+009) - incorrect output '%s'\n", buffer); status = TC_FAIL; - } + } - /*******************/ + /*******************/ - /* - * VxMicro does not support size modifiers such as L. As such, attempts to - * print a long double will NOT result in intuitively expected output. - * Until such time as they are supported (if ever) the output will remain - * counter-intuitive. If they ever are supported then this test will have - * to be updated. - */ + /* + * VxMicro does not support size modifiers such as L. As such, attempts to + * print a long double will NOT result in intuitively expected output. + * Until such time as they are supported (if ever) the output will remain + * counter-intuitive. If they ever are supported then this test will have + * to be updated. + */ sprintf(buffer, "%Lf", (long double) 1234567.0); if (strcmp("-0.000000", buffer) != 0) { - TC_ERROR("sprintf(%%Lf). Expected '-0.000000', got '%s'\n", - buffer); + TC_ERROR("sprintf(%%Lf). Expected '-0.000000', got '%s'\n", buffer); status = TC_FAIL; - } + } return status; } @@ -271,55 +270,55 @@ int vsnprintfTest(void) int status = TC_PASS; char buffer[100]; - /* - * VxMicro may be handling the string size in a non-standard manner. - * If a negative value is supplied for the string size, VxMicro converts - * it to 0x7fffffff--maximum integer size. Since there is insufficient - * memory to test a string of that length, we just check that the string - * was fully written so that we can exercise the code path. - */ + /* + * VxMicro may be handling the string size in a non-standard manner. + * If a negative value is supplied for the string size, VxMicro converts + * it to 0x7fffffff--maximum integer size. Since there is insufficient + * memory to test a string of that length, we just check that the string + * was fully written so that we can exercise the code path. + */ buffer[0] = '\0'; len = tvsnprintf(buffer, (size_t)(-4), "%x", DEADBEEF); if (len != strlen(DEADBEEF_LHEX_STR)) { TC_ERROR("vsnprintf(%%x). Expected return value %d, not %d\n", - strlen(DEADBEEF_LHEX_STR), len); + strlen(DEADBEEF_LHEX_STR), len); status = TC_FAIL; - } + } if (strcmp(buffer, DEADBEEF_LHEX_STR) != 0) { TC_ERROR("vsnprintf(%%x). Expected '%s', got '%s'\n", - DEADBEEF_LHEX_STR, buffer); + DEADBEEF_LHEX_STR, buffer); status = TC_FAIL; - } + } - /*******************/ + /*******************/ buffer[0] = '\0'; len = tvsnprintf(buffer, 0, "%x", DEADBEEF); if (len != strlen(DEADBEEF_LHEX_STR)) { TC_ERROR("vsnprintf(%%x). Expected return value %d, not %d\n", - strlen(DEADBEEF_LHEX_STR), len); + strlen(DEADBEEF_LHEX_STR), len); status = TC_FAIL; - } + } if (strcmp(buffer, "") != 0) { TC_ERROR("vsnprintf(%%x). Expected '%s', got '%s'\n", - "", buffer); + "", buffer); status = TC_FAIL; - } + } - /*******************/ + /*******************/ len = tvsnprintf(buffer, 4, "%x", DEADBEEF); if (len != strlen(DEADBEEF_LHEX_STR)) { TC_ERROR("vsnprintf(%%x). Expected return value %d, not %d\n", - strlen(DEADBEEF_LHEX_STR), len); + strlen(DEADBEEF_LHEX_STR), len); status = TC_FAIL; - } + } if (strcmp(buffer, "dea") != 0) { TC_ERROR("vsnprintf(%%x). Expected '%s', got '%s'\n", - "dea", buffer); + "dea", buffer); status = TC_FAIL; - } + } return status; } @@ -358,19 +357,19 @@ int vsprintfTest(void) int status = TC_PASS; char buffer[100]; - /*******************/ + /*******************/ len = tvsprintf(buffer, "%x", DEADBEEF); if (len != strlen(DEADBEEF_LHEX_STR)) { TC_ERROR("sprintf(%%x). Expected %d bytes written, not %d\n", - strlen(DEADBEEF_LHEX_STR), len); + strlen(DEADBEEF_LHEX_STR), len); status = TC_FAIL; - } + } if (strcmp(buffer, DEADBEEF_LHEX_STR) != 0) { TC_ERROR("sprintf(%%x). Expected '%s', got '%s'\n", - DEADBEEF_LHEX_STR, buffer); + DEADBEEF_LHEX_STR, buffer); status = TC_FAIL; - } + } return status; } @@ -392,55 +391,55 @@ int snprintfTest(void) int status = TC_PASS; char buffer[100]; - /* - * VxMicro may be handling the string size in a non-standard manner. - * If a negative value is supplied for the string size, VxMicro converts - * it to 0x7fffffff--maximum integer size. Since there is insufficient - * memory to test a string of that length, we just check that the string - * was fully written so that we can exercise the code path. - */ + /* + * VxMicro may be handling the string size in a non-standard manner. + * If a negative value is supplied for the string size, VxMicro converts + * it to 0x7fffffff--maximum integer size. Since there is insufficient + * memory to test a string of that length, we just check that the string + * was fully written so that we can exercise the code path. + */ buffer[0] = '\0'; len = snprintf(buffer, (size_t)(-4), "%x", DEADBEEF); if (len != strlen(DEADBEEF_LHEX_STR)) { TC_ERROR("snprintf(%%x). Expected return value %d, not %d\n", - strlen(DEADBEEF_LHEX_STR), len); + strlen(DEADBEEF_LHEX_STR), len); status = TC_FAIL; - } + } if (strcmp(buffer, DEADBEEF_LHEX_STR) != 0) { TC_ERROR("snprintf(%%x). Expected '%s', got '%s'\n", - DEADBEEF_LHEX_STR, buffer); + DEADBEEF_LHEX_STR, buffer); status = TC_FAIL; - } + } - /*******************/ + /*******************/ buffer[0] = '\0'; len = snprintf(buffer, 0, "%x", DEADBEEF); if (len != strlen(DEADBEEF_LHEX_STR)) { TC_ERROR("snprintf(%%x). Expected return value %d, not %d\n", - strlen(DEADBEEF_LHEX_STR), len); + strlen(DEADBEEF_LHEX_STR), len); status = TC_FAIL; - } + } if (strcmp(buffer, "") != 0) { TC_ERROR("snprintf(%%x). Expected '%s', got '%s'\n", - "", buffer); + "", buffer); status = TC_FAIL; - } + } - /*******************/ + /*******************/ len = snprintf(buffer, 4, "%x", DEADBEEF); if (len != strlen(DEADBEEF_LHEX_STR)) { TC_ERROR("snprintf(%%x). Expected return value %d, not %d\n", - strlen(DEADBEEF_LHEX_STR), len); + strlen(DEADBEEF_LHEX_STR), len); status = TC_FAIL; - } + } if (strcmp(buffer, "dea") != 0) { TC_ERROR("snprintf(%%x). Expected '%s', got '%s'\n", - "dea", buffer); + "dea", buffer); status = TC_FAIL; - } + } return status; } @@ -458,65 +457,65 @@ int sprintfMiscTest(void) int count; char buffer[100]; - /*******************/ + /*******************/ sprintf(buffer, "%p", (void *) DEADBEEF); if (strcmp(buffer, DEADBEEF_PTR_STR) != 0) { TC_ERROR("sprintf(%%p). Expected '%s', got '%s'\n", - DEADBEEF_PTR_STR, buffer); + DEADBEEF_PTR_STR, buffer); status = TC_FAIL; - } + } - /*******************/ + /*******************/ sprintf(buffer, "test data %n test data", &count); if (count != 10) { TC_ERROR("sprintf(%%n). Expected count to be %d, not %d\n", - 10, count); + 10, count); status = TC_FAIL; - } + } if (strcmp(buffer, "test data test data") != 0) { TC_ERROR("sprintf(%%p). Expected '%s', got '%s'\n", - "test data test data", buffer); + "test data test data", buffer); status = TC_FAIL; - } + } - /*******************/ + /*******************/ sprintf(buffer, "%*d", 10, 1234); if (strcmp(buffer, " 1234") != 0) { TC_ERROR("sprintf(%%p). Expected '%s', got '%s'\n", - " 1234", buffer); + " 1234", buffer); status = TC_FAIL; - } + } - /*******************/ + /*******************/ sprintf(buffer, "%*d", -10, 1234); if (strcmp(buffer, "1234 ") != 0) { TC_ERROR("sprintf(%%p). Expected '%s', got '%s'\n", - "1234 ", buffer); + "1234 ", buffer); status = TC_FAIL; - } + } - /*******************/ + /*******************/ sprintf(buffer, "% d", 1234); if (strcmp(buffer, " 1234") != 0) { TC_ERROR("sprintf(%% d). Expected '%s', got '%s'\n", - " 1234", buffer); + " 1234", buffer); status = TC_FAIL; - } + } - /*******************/ + /*******************/ sprintf(buffer, "%hx", 1234); if (strcmp("4d2", buffer) != 0) { TC_ERROR("sprintf(%%hx). Expected '4d2', got '%s'\n", buffer); status = TC_FAIL; - } + } - /*******************/ + /*******************/ sprintf(buffer, "%lx", 1234ul); if (strcmp("4d2", buffer) != 0) { TC_ERROR("sprintf(%%lx). Expected '4d2', got '%s'\n", buffer); status = TC_FAIL; - } + } return status; } @@ -534,142 +533,142 @@ int sprintfIntegerTest(void) int len; char buffer[100]; - /*******************/ + /*******************/ - /* Note: VxMicro prints hex numbers in 8 characters */ + /* Note: VxMicro prints hex numbers in 8 characters */ len = sprintf(buffer, "%x", 0x11); if (len != 2) { TC_ERROR("sprintf(%%x). Expected 2 bytes written, not %d\n", len); status = TC_FAIL; - } + } if (strcmp(buffer, "11") != 0) { TC_ERROR("sprintf(%%x). Expected '%s', got '%s'\n", "11", buffer); status = TC_FAIL; - } + } - /*******************/ + /*******************/ len = sprintf(buffer, "%x", DEADBEEF); if (len != strlen(DEADBEEF_LHEX_STR)) { TC_ERROR("sprintf(%%x). Expected %d bytes written, not %d\n", - strlen(DEADBEEF_LHEX_STR), len); + strlen(DEADBEEF_LHEX_STR), len); status = TC_FAIL; - } + } if (strcmp(buffer, DEADBEEF_LHEX_STR) != 0) { TC_ERROR("sprintf(%%x). Expected '%s', got '%s'\n", - DEADBEEF_LHEX_STR, buffer); + DEADBEEF_LHEX_STR, buffer); status = TC_FAIL; - } + } - /*******************/ + /*******************/ len = sprintf(buffer, "%X", DEADBEEF); if (len != strlen(DEADBEEF_UHEX_STR)) { TC_ERROR("sprintf(%%X). Expected %d bytes written, not %d\n", - strlen(DEADBEEF_UHEX_STR), len); + strlen(DEADBEEF_UHEX_STR), len); status = TC_FAIL; - } + } if (strcmp(buffer, DEADBEEF_UHEX_STR) != 0) { TC_ERROR("sprintf(%%X). Expected '%s', got '%s'\n", - DEADBEEF_UHEX_STR, buffer); + DEADBEEF_UHEX_STR, buffer); status = TC_FAIL; - } + } - /*******************/ + /*******************/ len = sprintf(buffer, "%u", DEADBEEF); if (len != strlen(DEADBEEF_UNSIGNED_STR)) { TC_ERROR("sprintf(%%u). Expected %d bytes written, not %d\n", - strlen(DEADBEEF_UNSIGNED_STR), len); + strlen(DEADBEEF_UNSIGNED_STR), len); status = TC_FAIL; - } + } if (strcmp(buffer, DEADBEEF_UNSIGNED_STR) != 0) { TC_ERROR("sprintf(%%u). Expected '%s', got '%s'\n", - DEADBEEF_UNSIGNED_STR, buffer); + DEADBEEF_UNSIGNED_STR, buffer); status = TC_FAIL; - } + } - /*******************/ + /*******************/ len = sprintf(buffer, "%d", (int) DEADBEEF); if (len != strlen(DEADBEEF_SIGNED_STR)) { TC_ERROR("sprintf(%%d). Expected %d bytes written, not %d\n", - strlen(DEADBEEF_SIGNED_STR), len); + strlen(DEADBEEF_SIGNED_STR), len); status = TC_FAIL; - } + } if (strcmp(buffer, DEADBEEF_SIGNED_STR) != 0) { TC_ERROR("sprintf(%%d). Expected '%s', got '%s'\n", - DEADBEEF_SIGNED_STR, buffer); + DEADBEEF_SIGNED_STR, buffer); status = TC_FAIL; - } + } - /*******************/ + /*******************/ len = sprintf(buffer, "%o", DEADBEEF); if (len != strlen(DEADBEEF_OCTAL_STR)) { TC_ERROR("sprintf(%%o). Expected %d bytes written, not %d\n", - strlen(DEADBEEF_OCTAL_STR), len); + strlen(DEADBEEF_OCTAL_STR), len); status = TC_FAIL; - } + } if (strcmp(buffer, DEADBEEF_OCTAL_STR) != 0) { TC_ERROR("sprintf(%%o). Expected '%s', got '%s'\n", - DEADBEEF_OCTAL_STR, buffer); + DEADBEEF_OCTAL_STR, buffer); status = TC_FAIL; - } + } - /*******************/ + /*******************/ len = sprintf(buffer, "%#o", DEADBEEF); if (len != strlen(DEADBEEF_OCTAL_ALT_STR)) { TC_ERROR("sprintf(%%#o). Expected %d bytes written, not %d\n", - strlen(DEADBEEF_OCTAL_ALT_STR), len); + strlen(DEADBEEF_OCTAL_ALT_STR), len); status = TC_FAIL; - } + } if (strcmp(buffer, DEADBEEF_OCTAL_ALT_STR) != 0) { TC_ERROR("sprintf(%%#o). Expected '%s', got '%s'\n", - DEADBEEF_OCTAL_ALT_STR, buffer); + DEADBEEF_OCTAL_ALT_STR, buffer); status = TC_FAIL; - } + } - /*******************/ + /*******************/ len = sprintf(buffer, "%#x", DEADBEEF); if (len != strlen(DEADBEEF_LHEX_ALT_STR)) { TC_ERROR("sprintf(%%#x). Expected %d bytes written, not %d\n", - strlen(DEADBEEF_LHEX_ALT_STR), len); + strlen(DEADBEEF_LHEX_ALT_STR), len); status = TC_FAIL; - } + } if (strcmp(buffer, DEADBEEF_LHEX_ALT_STR) != 0) { TC_ERROR("sprintf(%%#x). Expected '%s', got '%s'\n", - DEADBEEF_LHEX_ALT_STR, buffer); + DEADBEEF_LHEX_ALT_STR, buffer); status = TC_FAIL; - } + } - /*******************/ + /*******************/ len = sprintf(buffer, "%#X", DEADBEEF); if (len != strlen(DEADBEEF_UHEX_ALT_STR)) { TC_ERROR("sprintf(%%#X). Expected %d bytes written, not %d\n", - strlen(DEADBEEF_UHEX_ALT_STR), len); + strlen(DEADBEEF_UHEX_ALT_STR), len); status = TC_FAIL; - } + } if (strcmp(buffer, DEADBEEF_UHEX_ALT_STR) != 0) { TC_ERROR("sprintf(%%#X). Expected '%s', got '%s'\n", - DEADBEEF_UHEX_ALT_STR, buffer); + DEADBEEF_UHEX_ALT_STR, buffer); status = TC_FAIL; - } + } - /*******************/ + /*******************/ len = sprintf(buffer, "%+d", 1); if (len != 2) { TC_ERROR("sprintf(%%+d). Expected %d bytes written, not %d\n", - 2, len); + 2, len); status = TC_FAIL; - } + } if (strcmp(buffer, "+1") != 0) { TC_ERROR("sprintf(%%+d). Expected '+1', got '%s'\n", buffer); status = TC_FAIL; - } + } return status; } @@ -691,31 +690,31 @@ int sprintfStringTest(void) if (strcmp(buffer, "%") != 0) { TC_ERROR("sprintf(%%). Expected '%%', got '%s'\n", buffer); status = TC_FAIL; - } + } sprintf(buffer, "%c", 't'); if (strcmp(buffer, "t") != 0) { TC_ERROR("sprintf(%%c). Expected 't', got '%s'\n", buffer); status = TC_FAIL; - } + } sprintf(buffer, "%s", "short string"); if (strcmp(buffer, "short string") != 0) { TC_ERROR("sprintf(%%s). Expected 'short string', got '%s'\n", buffer); status = TC_FAIL; - } + } len = sprintf(buffer, "%s", REALLY_LONG_STRING); if (len != PRINTF_MAX_STRING_LENGTH) { TC_ERROR("Internals changed. Max string length no longer %d\n", - PRINTF_MAX_STRING_LENGTH); + PRINTF_MAX_STRING_LENGTH); status = TC_FAIL; - } + } if (strncmp(buffer, REALLY_LONG_STRING, PRINTF_MAX_STRING_LENGTH) != 0) { TC_ERROR("First %d characters of REALLY_LONG_STRING not printed!\n", - PRINTF_MAX_STRING_LENGTH); + PRINTF_MAX_STRING_LENGTH); status = TC_FAIL; - } + } return status; } @@ -738,38 +737,38 @@ void RegressionTask(void) TC_PRINT("Testing sprintf() with integers ....\n"); if (sprintfIntegerTest() != TC_PASS) { status = TC_FAIL; - } + } TC_PRINT("Testing snprintf() ....\n"); if (snprintfTest() != TC_PASS) { status = TC_FAIL; - } + } TC_PRINT("Testing vsprintf() ....\n"); if (vsprintfTest() != TC_PASS) { status = TC_FAIL; - } + } TC_PRINT("Testing vsnprintf() ....\n"); if (vsnprintfTest() != TC_PASS) { status = TC_FAIL; - } + } TC_PRINT("Testing sprintf() with strings ....\n"); if (sprintfStringTest() != TC_PASS) { status = TC_FAIL; - } + } TC_PRINT("Testing sprintf() with misc options ....\n"); if (sprintfMiscTest() != TC_PASS) { status = TC_FAIL; - } + } #ifdef CONFIG_FLOAT TC_PRINT("Testing sprintf() with doubles ....\n"); if (sprintfDoubleTest() != TC_PASS) { status = TC_FAIL; - } + } #endif /* CONFIG_FLOAT */ TC_END_RESULT(status); diff --git a/samples/microkernel/test/test_stackprot/src/stackprot.c b/samples/microkernel/test/test_stackprot/src/stackprot.c index 379ba76aa..7dee7568f 100644 --- a/samples/microkernel/test/test_stackprot/src/stackprot.c +++ b/samples/microkernel/test/test_stackprot/src/stackprot.c @@ -85,10 +85,10 @@ void check_input(const char *name, const char *input); void printLoop(const char *name) { while (count < 6) { - /* A short input string to check_input. It will pass. */ + /* A short input string to check_input. It will pass. */ check_input(name, "Stack ok"); count++; - } + } } /******************************************************************************* @@ -109,7 +109,7 @@ void printLoop(const char *name) void check_input(const char *name, const char *input) { - /* Stack will overflow when input is more than 16 characters */ + /* Stack will overflow when input is more than 16 characters */ char buf[16]; strcpy(buf, input); @@ -135,12 +135,11 @@ void fiber1(void) #endif /* ! CONFIG_MICROKERNEL */ { TC_PRINT("Starts %s\n", __func__); - check_input(__func__, - "Input string is too long and stack overflowed!\n"); - /* - * Expect this task to terminate due to stack check fail and will not - * execute pass here. - */ + check_input(__func__, "Input string is too long and stack overflowed!\n"); + /* + * Expect this task to terminate due to stack check fail and will not + * execute pass here. + */ printLoop(__func__); tcRC = TC_FAIL; @@ -168,17 +167,17 @@ void main(void) TC_PRINT("Starts %s\n", __func__); #ifdef CONFIG_MICROKERNEL - /* Start task */ + /* Start task */ task_start(ALTERNATETASK); /* refer to prj.vpf file */ #else - /* Start fiber */ + /* Start fiber */ task_fiber_start(&fiberStack[0], STACKSIZE, - (nano_fiber_entry_t) fiber1, 0, 0, 7, 0); + (nano_fiber_entry_t) fiber1, 0, 0, 7, 0); #endif /* ! CONFIG_MICROKERNEL */ if (tcRC == TC_FAIL) { goto errorExit; - } + } printLoop(__func__); diff --git a/samples/microkernel/test/test_static_idt/src/static_idt.c b/samples/microkernel/test/test_static_idt/src/static_idt.c index c93591b0d..c5ed03763 100644 --- a/samples/microkernel/test/test_static_idt/src/static_idt.c +++ b/samples/microkernel/test/test_static_idt/src/static_idt.c @@ -137,44 +137,44 @@ int nanoIdtStubTest(void) IDT_ENTRY *pIdtEntry; uint16_t offset; - /* Check for the interrupt stub */ + /* Check for the interrupt stub */ pIdtEntry = (IDT_ENTRY *) (_idt_base_address + (TEST_SOFT_INT << 3)); offset = (uint16_t)((uint32_t)(&nanoIntStub) & 0xFFFF); if (pIdtEntry->lowOffset != offset) { - TC_ERROR("Failed to find low offset of nanoIntStub \ - (0x%x) at vector %d\n", (uint32_t)offset, TEST_SOFT_INT); - return TC_FAIL; + TC_ERROR("Failed to find low offset of nanoIntStub " + "(0x%x) at vector %d\n", (uint32_t)offset, TEST_SOFT_INT); + return TC_FAIL; } offset = (uint16_t)((uint32_t)(&nanoIntStub) >> 16); if (pIdtEntry->hiOffset != offset) { - TC_ERROR("Failed to find high offset of nanoIntStub \ - (0x%x) at vector %d\n", (uint32_t)offset, TEST_SOFT_INT); - return TC_FAIL; + TC_ERROR("Failed to find high offset of nanoIntStub " + "(0x%x) at vector %d\n", (uint32_t)offset, TEST_SOFT_INT); + return TC_FAIL; } - /* Check for the exception stub */ + /* Check for the exception stub */ pIdtEntry = (IDT_ENTRY *) (_idt_base_address + (IV_DIVIDE_ERROR << 3)); offset = (uint16_t)((uint32_t)(&exc_divide_error_handlerStub) & 0xFFFF); if (pIdtEntry->lowOffset != offset) { - TC_ERROR("Failed to find low offset of exc stub \ - (0x%x) at vector %d\n", (uint32_t)offset, IV_DIVIDE_ERROR); - return TC_FAIL; + TC_ERROR("Failed to find low offset of exc stub " + "(0x%x) at vector %d\n", (uint32_t)offset, IV_DIVIDE_ERROR); + return TC_FAIL; } offset = (uint16_t)((uint32_t)(&exc_divide_error_handlerStub) >> 16); if (pIdtEntry->hiOffset != offset) { - TC_ERROR("Failed to find high offset of exc stub \ - (0x%x) at vector %d\n", (uint32_t)offset, IV_DIVIDE_ERROR); - return TC_FAIL; + TC_ERROR("Failed to find high offset of exc stub " + "(0x%x) at vector %d\n", (uint32_t)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. - */ + /* + * 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; } @@ -200,7 +200,7 @@ static void idtSpurFiber(int a1, int a2) _trigger_spurHandler(); - /* Shouldn't get here */ + /* Shouldn't get here */ spurHandlerAbortedContext = 0; } @@ -230,59 +230,59 @@ void main(void) rv = nanoIdtStubTest(); if (rv != TC_PASS) { goto doneTests; - } + } TC_PRINT("Testing to see interrupt handler executes properly\n"); _trigger_isrHandler(); if (intHandlerExecuted == 0) { - TC_ERROR("Interrupt handler did not execute\n"); - rv = TC_FAIL; - goto doneTests; + TC_ERROR("Interrupt handler did not execute\n"); + rv = TC_FAIL; + goto doneTests; } else if (intHandlerExecuted != 1) { - TC_ERROR("Interrupt handler executed more than once! (%d)\n", - intHandlerExecuted); - rv = TC_FAIL; - goto doneTests; + TC_ERROR("Interrupt handler executed more than once! (%d)\n", + intHandlerExecuted); + rv = TC_FAIL; + goto doneTests; } TC_PRINT("Testing to see exception handler executes properly\n"); - /* - * Use excHandlerExecuted instead of 0 to prevent the compiler issuing a - * 'divide by zero' warning. - */ + /* + * Use excHandlerExecuted instead of 0 to prevent the compiler issuing a + * 'divide by zero' warning. + */ error = error / excHandlerExecuted; if (excHandlerExecuted == 0) { - TC_ERROR("Exception handler did not execute\n"); - rv = TC_FAIL; - goto doneTests; + TC_ERROR("Exception handler did not execute\n"); + rv = TC_FAIL; + goto doneTests; } else if (excHandlerExecuted != 1) { - TC_ERROR("Exception handler executed more than once! (%d)\n", - excHandlerExecuted); - rv = TC_FAIL; - goto doneTests; + TC_ERROR("Exception handler executed more than once! (%d)\n", + excHandlerExecuted); + rv = TC_FAIL; + goto doneTests; } - /* - * Start fiber/task to trigger the spurious interrupt handler - */ + /* + * Start fiber/task to trigger the spurious interrupt handler + */ TC_PRINT("Testing to see spurious handler executes properly\n"); #ifdef CONFIG_MICROKERNEL task_start(tSpurTask); #else task_fiber_start(fiberStack, sizeof(fiberStack), idtSpurFiber, 0, 0, 5, 0); #endif - /* - * The fiber/task should not run past where the spurious interrupt is - * generated. Therefore spurHandlerAbortedContext should remain at 1. - */ + /* + * The fiber/task should not run past where the spurious interrupt is + * generated. Therefore spurHandlerAbortedContext should remain at 1. + */ if (spurHandlerAbortedContext == 0) { - TC_ERROR("Spurious handler did not execute as expected\n"); - rv = TC_FAIL; - goto doneTests; + TC_ERROR("Spurious handler did not execute as expected\n"); + rv = TC_FAIL; + goto doneTests; } doneTests: diff --git a/samples/microkernel/test/test_task/src/task.c b/samples/microkernel/test/test_task/src/task.c index b8bf2eabd..e79291697 100644 --- a/samples/microkernel/test/test_task/src/task.c +++ b/samples/microkernel/test/test_task/src/task.c @@ -65,7 +65,7 @@ This module tests the following task APIs: typedef struct { int cmd; int data; - } ISR_INFO; +} ISR_INFO; /* locals */ @@ -91,14 +91,14 @@ void isr_task_command_handler(void *data) int value = -1; switch (pInfo->cmd) { - case CMD_TASKID: - value = isr_task_id_get(); - break; + case CMD_TASKID: + value = isr_task_id_get(); + break; - case CMD_PRIORITY: - value = isr_task_priority_get(); - break; - } + case CMD_PRIORITY: + value = isr_task_priority_get(); + break; + } pInfo->data = value; } @@ -116,17 +116,17 @@ int isrAPIsTest(int taskId, int taskPrio) _trigger_isrTaskCommand(); if (isrInfo.data != taskId) { TC_ERROR("isr_task_id_get() returned %d, not %d\n", - isrInfo.data, taskId); + isrInfo.data, taskId); return TC_FAIL; - } + } isrInfo.cmd = CMD_PRIORITY; _trigger_isrTaskCommand(); if (isrInfo.data != taskPrio) { TC_ERROR("isr_task_priority_get() returned %d, not %d\n", - isrInfo.data, taskPrio); + isrInfo.data, taskPrio); return TC_FAIL; - } + } return TC_PASS; } @@ -145,16 +145,16 @@ int taskMacrosTest(int taskId, int taskPrio) value = task_id_get(); if (value != taskId) { TC_ERROR("task_id_get() returned 0x%x, not 0x%x\n", - value, taskId); + value, taskId); return TC_FAIL; - } + } value = task_priority_get(); if (value != taskPrio) { TC_ERROR("task_priority_get() returned %d, not %d\n", - value, taskPrio); + value, taskPrio); return TC_FAIL; - } + } return TC_PASS; } @@ -211,65 +211,65 @@ int taskSetPrioTest(void) { int rv; - /* Lower the priority of the current task (RegressionTask) */ + /* Lower the priority of the current task (RegressionTask) */ task_priority_set(RT_TASKID, RT_PRIO + 5); rv = task_priority_get(); if (rv != RT_PRIO + 5) { TC_ERROR("Expected priority to be changed to %d, not %d\n", - RT_PRIO + 5, rv); + RT_PRIO + 5, rv); return TC_FAIL; - } + } - /* Raise the priority of the current task (RegressionTask) */ + /* Raise the priority of the current task (RegressionTask) */ task_priority_set(RT_TASKID, RT_PRIO - 5); rv = task_priority_get(); if (rv != RT_PRIO - 5) { TC_ERROR("Expected priority to be changed to %d, not %d\n", - RT_PRIO - 5, rv); + RT_PRIO - 5, rv); return TC_FAIL; - } + } - /* Restore the priority of the current task (RegressionTask) */ + /* Restore the priority of the current task (RegressionTask) */ task_priority_set(RT_TASKID, RT_PRIO); rv = task_priority_get(); if (rv != RT_PRIO) { TC_ERROR("Expected priority to be changed to %d, not %d\n", - RT_PRIO, rv); + RT_PRIO, rv); return TC_FAIL; - } + } - /* Lower the priority of the helper task (HelperTask) */ + /* Lower the priority of the helper task (HelperTask) */ task_priority_set(HT_TASKID, HT_PRIO + 5); task_sem_give(HT_SEM); task_sem_take_wait(RT_SEM); if (helperData != HT_PRIO + 5) { TC_ERROR("Expected priority to be changed to %d, not %d\n", - HT_PRIO + 5, helperData); + HT_PRIO + 5, helperData); return TC_FAIL; - } + } - /* Raise the priority of the helper task (HelperTask) */ + /* Raise the priority of the helper task (HelperTask) */ task_priority_set(HT_TASKID, HT_PRIO - 5); task_sem_give(HT_SEM); task_sem_take_wait(RT_SEM); if (helperData != HT_PRIO - 5) { TC_ERROR("Expected priority to be changed to %d, not %d\n", - HT_PRIO - 5, helperData); + HT_PRIO - 5, helperData); return TC_FAIL; - } + } - /* Restore the priority of the helper task (HelperTask) */ + /* Restore the priority of the helper task (HelperTask) */ task_priority_set(HT_TASKID, HT_PRIO); task_sem_give(HT_SEM); task_sem_take_wait(RT_SEM); if (helperData != HT_PRIO) { TC_ERROR("Expected priority to be changed to %d, not %d\n", - HT_PRIO, helperData); + HT_PRIO, helperData); return TC_FAIL; - } + } return TC_PASS; } @@ -289,7 +289,7 @@ void helperTaskSleepTest(void) firstTick = task_tick_get_32(); while (mainTaskNotReady) { - } + } helperData = task_tick_get_32() - firstTick; task_sem_give(RT_SEM); @@ -308,7 +308,7 @@ int taskSleepTest(void) tick = task_tick_get_32(); /* Busy wait to align */ while (tick == task_tick_get_32()) { /* to tick boundary */ - } + } task_sem_give(HT_SEM); @@ -319,9 +319,9 @@ int taskSleepTest(void) if (helperData != SLEEP_TIME) { TC_ERROR("task_sleep() slept for %d ticks, not %d\n", - helperData, SLEEP_TIME); + helperData, SLEEP_TIME); return TC_FAIL; - } + } return TC_PASS; } @@ -341,7 +341,7 @@ void helperTaskYieldTest(void) for (i = 0; i < 5; i++) { helperData++; task_yield(); - } + } task_sem_give(RT_SEM); } @@ -360,7 +360,7 @@ int taskYieldTest(void) helperData = 0; - /* 1st raise the priority of the helper task */ + /* 1st raise the priority of the helper task */ task_priority_set(HT_TASKID, RT_PRIO); task_sem_give(HT_SEM); @@ -369,16 +369,16 @@ int taskYieldTest(void) task_yield(); if (helperData == prevHelperData) { - TC_ERROR("Iter %d. helperData did not change (%d) \n", - i + 1, helperData); - return TC_FAIL; - } + TC_ERROR("Iter %d. helperData did not change (%d) \n", + i + 1, helperData); + return TC_FAIL; } + } - /* Restore helper task priority */ + /* Restore helper task priority */ task_priority_set(HT_TASKID, HT_PRIO); - /* Ensure that the helper task finishes */ + /* Ensure that the helper task finishes */ task_sem_take_wait(RT_SEM); return TC_PASS; @@ -424,7 +424,7 @@ int taskSuspendTest(void) if (prevHelperData != helperData) { TC_ERROR("Helper task did not suspend!\n"); return TC_FAIL; - } + } task_resume(HT_TASKID); task_sleep(SLEEP_TIME); @@ -432,7 +432,7 @@ int taskSuspendTest(void) if (prevHelperData == helperData) { TC_ERROR("Helper task did not resume!\n"); return TC_FAIL; - } + } task_sem_give(HT_SEM); return TC_PASS; @@ -454,7 +454,7 @@ void HelperTask(void) if (rv != TC_PASS) { tcRC = TC_FAIL; return; - } + } task_sem_give(RT_SEM); task_sem_take_wait(HT_SEM); @@ -462,7 +462,7 @@ void HelperTask(void) if (rv != TC_PASS) { tcRC = TC_FAIL; return; - } + } task_sem_give(RT_SEM); helperTaskSetPrioTest(); @@ -496,7 +496,7 @@ void RegressionTask(void) if (rv != TC_PASS) { tcRC = TC_FAIL; goto errorReturn; - } + } task_sem_give(HT_SEM); task_sem_take_wait(RT_SEM); @@ -506,7 +506,7 @@ void RegressionTask(void) if (rv != TC_PASS) { tcRC = TC_FAIL; goto errorReturn; - } + } task_sem_give(HT_SEM); task_sem_take_wait(RT_SEM); @@ -515,25 +515,25 @@ void RegressionTask(void) if (taskSetPrioTest() != TC_PASS) { tcRC = TC_FAIL; goto errorReturn; - } + } TC_PRINT("Testing task_sleep()\n"); if (taskSleepTest() != TC_PASS) { tcRC = TC_FAIL; goto errorReturn; - } + } TC_PRINT("Testing task_yield()\n"); if (taskYieldTest() != TC_PASS) { tcRC = TC_FAIL; goto errorReturn; - } + } TC_PRINT("Testing task_suspend() and task_resume()\n"); if (taskSuspendTest() != TC_PASS) { tcRC = TC_FAIL; goto errorReturn; - } + } errorReturn: TC_END_RESULT(tcRC); diff --git a/samples/microkernel/test/test_task_irq/src/main.c b/samples/microkernel/test/test_task_irq/src/main.c index 9325754ed..88a5e5d5c 100644 --- a/samples/microkernel/test/test_task_irq/src/main.c +++ b/samples/microkernel/test/test_task_irq/src/main.c @@ -64,10 +64,10 @@ static ksem_t rdySem = SEM_RDY; */ void taskAMain(void) - { +{ extern int taskA(ksem_t semRdy); task_sem_give(resultSems[taskA(rdySem)]); - } +} /******************************************************************************* * @@ -80,10 +80,10 @@ void taskAMain(void) */ void taskBMain(void) - { +{ extern int taskB(ksem_t semRdy); task_sem_give(resultSems[taskB(rdySem)]); - } +} /******************************************************************************* * @@ -96,29 +96,30 @@ void taskBMain(void) * RETURNS: N/A */ void registerWait(void) - { +{ extern void raiseInt(uint8_t id); int tasksDone; int irq_obj; - /* Wait for the 2 tasks to finish registering their IRQ objects*/ + /* Wait for the 2 tasks to finish registering their IRQ objects*/ for (tasksDone = 0; tasksDone < NUM_TEST_TASKS - 1; tasksDone++) { if (task_sem_take_wait_timeout(SEM_RDY, TIMEOUT) != RC_OK) { - TC_ERROR("Monitor task timed out\n"); - task_sem_give(resultSems[TC_FAIL]); - return; - } + TC_ERROR("Monitor task timed out\n"); + task_sem_give(resultSems[TC_FAIL]); + return; } + } TC_PRINT("Generating interrupts for all allocated IRQ objects...\n"); for (irq_obj = 0; irq_obj < NUM_TASK_IRQS; irq_obj++) { - if (task_irq_object[irq_obj].irq != INVALID_VECTOR) - raiseInt((uint8_t)task_irq_object[irq_obj].vector); + if (task_irq_object[irq_obj].irq != INVALID_VECTOR) { + raiseInt((uint8_t)task_irq_object[irq_obj].vector); } + } task_sem_give(resultSems[TC_PASS]); - } +} /******************************************************************************* * @@ -131,7 +132,7 @@ void registerWait(void) */ void MonitorTaskEntry(void) - { +{ extern struct task_irq_info task_irq_object[NUM_TASK_IRQS]; ksem_t result; int tasksDone; @@ -139,24 +140,24 @@ void MonitorTaskEntry(void) PRINT_DATA("Starting task level interrupt handling tests\n"); PRINT_LINE; - /* - * the various test tasks start executing automatically; - * wait for all tasks to complete or a failure to occur, - * then issue the appropriate test case summary message - */ + /* + * the various test tasks start executing automatically; + * wait for all tasks to complete or a failure to occur, + * then issue the appropriate test case summary message + */ for (tasksDone = 0; tasksDone < NUM_TEST_TASKS; tasksDone++) { result = task_sem_group_take_wait_timeout(resultSems, TIMEOUT); if (result != resultSems[TC_PASS]) { - if (result != resultSems[TC_FAIL]) { - TC_ERROR("Monitor task timed out\n"); - } - TC_END_RESULT(TC_FAIL); - TC_END_REPORT(TC_FAIL); - return; - } + if (result != resultSems[TC_FAIL]) { + TC_ERROR("Monitor task timed out\n"); + } + TC_END_RESULT(TC_FAIL); + TC_END_REPORT(TC_FAIL); + return; } + } TC_END_RESULT(TC_PASS); TC_END_REPORT(TC_PASS); - } +} diff --git a/samples/microkernel/test/test_task_irq/src/raise_int.c b/samples/microkernel/test/test_task_irq/src/raise_int.c index eab832631..89afb9c3f 100644 --- a/samples/microkernel/test/test_task_irq/src/raise_int.c +++ b/samples/microkernel/test/test_task_irq/src/raise_int.c @@ -43,1350 +43,1350 @@ #if defined(VXMICRO_ARCH_x86) static void genInt0(void) - { +{ __asm__ volatile("int $0"); - } +} static void genInt1(void) - { +{ __asm__ volatile("int $1"); - } +} static void genInt2(void) - { +{ __asm__ volatile("int $2"); - } +} static void genInt3(void) - { +{ __asm__ volatile("int $3"); - } +} static void genInt4(void) - { +{ __asm__ volatile("int $4"); - } +} static void genInt5(void) - { +{ __asm__ volatile("int $5"); - } +} static void genInt6(void) - { +{ __asm__ volatile("int $6"); - } +} static void genInt7(void) - { +{ __asm__ volatile("int $7"); - } +} static void genInt8(void) - { +{ __asm__ volatile("int $8"); - } +} static void genInt9(void) - { +{ __asm__ volatile("int $9"); - } +} static void genInt10(void) - { +{ __asm__ volatile("int $10"); - } +} static void genInt11(void) - { +{ __asm__ volatile("int $11"); - } +} static void genInt12(void) - { +{ __asm__ volatile("int $12"); - } +} static void genInt13(void) - { +{ __asm__ volatile("int $13"); - } +} static void genInt14(void) - { +{ __asm__ volatile("int $14"); - } +} static void genInt15(void) - { +{ __asm__ volatile("int $15"); - } +} static void genInt16(void) - { +{ __asm__ volatile("int $16"); - } +} static void genInt17(void) - { +{ __asm__ volatile("int $17"); - } +} static void genInt18(void) - { +{ __asm__ volatile("int $18"); - } +} static void genInt19(void) - { +{ __asm__ volatile("int $19"); - } +} static void genInt20(void) - { +{ __asm__ volatile("int $20"); - } +} static void genInt21(void) - { +{ __asm__ volatile("int $21"); - } +} static void genInt22(void) - { +{ __asm__ volatile("int $22"); - } +} static void genInt23(void) - { +{ __asm__ volatile("int $23"); - } +} static void genInt24(void) - { +{ __asm__ volatile("int $24"); - } +} static void genInt25(void) - { +{ __asm__ volatile("int $25"); - } +} static void genInt26(void) - { +{ __asm__ volatile("int $26"); - } +} static void genInt27(void) - { +{ __asm__ volatile("int $27"); - } +} static void genInt28(void) - { +{ __asm__ volatile("int $28"); - } +} static void genInt29(void) - { +{ __asm__ volatile("int $29"); - } +} static void genInt30(void) - { +{ __asm__ volatile("int $30"); - } +} static void genInt31(void) - { +{ __asm__ volatile("int $31"); - } +} static void genInt32(void) - { +{ __asm__ volatile("int $32"); - } +} static void genInt33(void) - { +{ __asm__ volatile("int $33"); - } +} static void genInt34(void) - { +{ __asm__ volatile("int $34"); - } +} static void genInt35(void) - { +{ __asm__ volatile("int $35"); - } +} static void genInt36(void) - { +{ __asm__ volatile("int $36"); - } +} static void genInt37(void) - { +{ __asm__ volatile("int $37"); - } +} static void genInt38(void) - { +{ __asm__ volatile("int $38"); - } +} static void genInt39(void) - { +{ __asm__ volatile("int $39"); - } +} static void genInt40(void) - { +{ __asm__ volatile("int $40"); - } +} static void genInt41(void) - { +{ __asm__ volatile("int $41"); - } +} static void genInt42(void) - { +{ __asm__ volatile("int $42"); - } +} static void genInt43(void) - { +{ __asm__ volatile("int $43"); - } +} static void genInt44(void) - { +{ __asm__ volatile("int $44"); - } +} static void genInt45(void) - { +{ __asm__ volatile("int $45"); - } +} static void genInt46(void) - { +{ __asm__ volatile("int $46"); - } +} static void genInt47(void) - { +{ __asm__ volatile("int $47"); - } +} static void genInt48(void) - { +{ __asm__ volatile("int $48"); - } +} static void genInt49(void) - { +{ __asm__ volatile("int $49"); - } +} static void genInt50(void) - { +{ __asm__ volatile("int $50"); - } +} static void genInt51(void) - { +{ __asm__ volatile("int $51"); - } +} static void genInt52(void) - { +{ __asm__ volatile("int $52"); - } +} static void genInt53(void) - { +{ __asm__ volatile("int $53"); - } +} static void genInt54(void) - { +{ __asm__ volatile("int $54"); - } +} static void genInt55(void) - { +{ __asm__ volatile("int $55"); - } +} static void genInt56(void) - { +{ __asm__ volatile("int $56"); - } +} static void genInt57(void) - { +{ __asm__ volatile("int $57"); - } +} static void genInt58(void) - { +{ __asm__ volatile("int $58"); - } +} static void genInt59(void) - { +{ __asm__ volatile("int $59"); - } +} static void genInt60(void) - { +{ __asm__ volatile("int $60"); - } +} static void genInt61(void) - { +{ __asm__ volatile("int $61"); - } +} static void genInt62(void) - { +{ __asm__ volatile("int $62"); - } +} static void genInt63(void) - { +{ __asm__ volatile("int $63"); - } +} static void genInt64(void) - { +{ __asm__ volatile("int $64"); - } +} static void genInt65(void) - { +{ __asm__ volatile("int $65"); - } +} static void genInt66(void) - { +{ __asm__ volatile("int $66"); - } +} static void genInt67(void) - { +{ __asm__ volatile("int $67"); - } +} static void genInt68(void) - { +{ __asm__ volatile("int $68"); - } +} static void genInt69(void) - { +{ __asm__ volatile("int $69"); - } +} static void genInt70(void) - { +{ __asm__ volatile("int $70"); - } +} static void genInt71(void) - { +{ __asm__ volatile("int $71"); - } +} static void genInt72(void) - { +{ __asm__ volatile("int $72"); - } +} static void genInt73(void) - { +{ __asm__ volatile("int $73"); - } +} static void genInt74(void) - { +{ __asm__ volatile("int $74"); - } +} static void genInt75(void) - { +{ __asm__ volatile("int $75"); - } +} static void genInt76(void) - { +{ __asm__ volatile("int $76"); - } +} static void genInt77(void) - { +{ __asm__ volatile("int $77"); - } +} static void genInt78(void) - { +{ __asm__ volatile("int $78"); - } +} static void genInt79(void) - { +{ __asm__ volatile("int $79"); - } +} static void genInt80(void) - { +{ __asm__ volatile("int $80"); - } +} static void genInt81(void) - { +{ __asm__ volatile("int $81"); - } +} static void genInt82(void) - { +{ __asm__ volatile("int $82"); - } +} static void genInt83(void) - { +{ __asm__ volatile("int $83"); - } +} static void genInt84(void) - { +{ __asm__ volatile("int $84"); - } +} static void genInt85(void) - { +{ __asm__ volatile("int $85"); - } +} static void genInt86(void) - { +{ __asm__ volatile("int $86"); - } +} static void genInt87(void) - { +{ __asm__ volatile("int $87"); - } +} static void genInt88(void) - { +{ __asm__ volatile("int $88"); - } +} static void genInt89(void) - { +{ __asm__ volatile("int $89"); - } +} static void genInt90(void) - { +{ __asm__ volatile("int $90"); - } +} static void genInt91(void) - { +{ __asm__ volatile("int $91"); - } +} static void genInt92(void) - { +{ __asm__ volatile("int $92"); - } +} static void genInt93(void) - { +{ __asm__ volatile("int $93"); - } +} static void genInt94(void) - { +{ __asm__ volatile("int $94"); - } +} static void genInt95(void) - { +{ __asm__ volatile("int $95"); - } +} static void genInt96(void) - { +{ __asm__ volatile("int $96"); - } +} static void genInt97(void) - { +{ __asm__ volatile("int $97"); - } +} static void genInt98(void) - { +{ __asm__ volatile("int $98"); - } +} static void genInt99(void) - { +{ __asm__ volatile("int $99"); - } +} static void genInt100(void) - { +{ __asm__ volatile("int $100"); - } +} static void genInt101(void) - { +{ __asm__ volatile("int $101"); - } +} static void genInt102(void) - { +{ __asm__ volatile("int $102"); - } +} static void genInt103(void) - { +{ __asm__ volatile("int $103"); - } +} static void genInt104(void) - { +{ __asm__ volatile("int $104"); - } +} static void genInt105(void) - { +{ __asm__ volatile("int $105"); - } +} static void genInt106(void) - { +{ __asm__ volatile("int $106"); - } +} static void genInt107(void) - { +{ __asm__ volatile("int $107"); - } +} static void genInt108(void) - { +{ __asm__ volatile("int $108"); - } +} static void genInt109(void) - { +{ __asm__ volatile("int $109"); - } +} static void genInt110(void) - { +{ __asm__ volatile("int $110"); - } +} static void genInt111(void) - { +{ __asm__ volatile("int $111"); - } +} static void genInt112(void) - { +{ __asm__ volatile("int $112"); - } +} static void genInt113(void) - { +{ __asm__ volatile("int $113"); - } +} static void genInt114(void) - { +{ __asm__ volatile("int $114"); - } +} static void genInt115(void) - { +{ __asm__ volatile("int $115"); - } +} static void genInt116(void) - { +{ __asm__ volatile("int $116"); - } +} static void genInt117(void) - { +{ __asm__ volatile("int $117"); - } +} static void genInt118(void) - { +{ __asm__ volatile("int $118"); - } +} static void genInt119(void) - { +{ __asm__ volatile("int $119"); - } +} static void genInt120(void) - { +{ __asm__ volatile("int $120"); - } +} static void genInt121(void) - { +{ __asm__ volatile("int $121"); - } +} static void genInt122(void) - { +{ __asm__ volatile("int $122"); - } +} static void genInt123(void) - { +{ __asm__ volatile("int $123"); - } +} static void genInt124(void) - { +{ __asm__ volatile("int $124"); - } +} static void genInt125(void) - { +{ __asm__ volatile("int $125"); - } +} static void genInt126(void) - { +{ __asm__ volatile("int $126"); - } +} static void genInt127(void) - { +{ __asm__ volatile("int $127"); - } +} static void genInt128(void) - { +{ __asm__ volatile("int $128"); - } +} static void genInt129(void) - { +{ __asm__ volatile("int $129"); - } +} static void genInt130(void) - { +{ __asm__ volatile("int $130"); - } +} static void genInt131(void) - { +{ __asm__ volatile("int $131"); - } +} static void genInt132(void) - { +{ __asm__ volatile("int $132"); - } +} static void genInt133(void) - { +{ __asm__ volatile("int $133"); - } +} static void genInt134(void) - { +{ __asm__ volatile("int $134"); - } +} static void genInt135(void) - { +{ __asm__ volatile("int $135"); - } +} static void genInt136(void) - { +{ __asm__ volatile("int $136"); - } +} static void genInt137(void) - { +{ __asm__ volatile("int $137"); - } +} static void genInt138(void) - { +{ __asm__ volatile("int $138"); - } +} static void genInt139(void) - { +{ __asm__ volatile("int $139"); - } +} static void genInt140(void) - { +{ __asm__ volatile("int $140"); - } +} static void genInt141(void) - { +{ __asm__ volatile("int $141"); - } +} static void genInt142(void) - { +{ __asm__ volatile("int $142"); - } +} static void genInt143(void) - { +{ __asm__ volatile("int $143"); - } +} static void genInt144(void) - { +{ __asm__ volatile("int $144"); - } +} static void genInt145(void) - { +{ __asm__ volatile("int $145"); - } +} static void genInt146(void) - { +{ __asm__ volatile("int $146"); - } +} static void genInt147(void) - { +{ __asm__ volatile("int $147"); - } +} static void genInt148(void) - { +{ __asm__ volatile("int $148"); - } +} static void genInt149(void) - { +{ __asm__ volatile("int $149"); - } +} static void genInt150(void) - { +{ __asm__ volatile("int $150"); - } +} static void genInt151(void) - { +{ __asm__ volatile("int $151"); - } +} static void genInt152(void) - { +{ __asm__ volatile("int $152"); - } +} static void genInt153(void) - { +{ __asm__ volatile("int $153"); - } +} static void genInt154(void) - { +{ __asm__ volatile("int $154"); - } +} static void genInt155(void) - { +{ __asm__ volatile("int $155"); - } +} static void genInt156(void) - { +{ __asm__ volatile("int $156"); - } +} static void genInt157(void) - { +{ __asm__ volatile("int $157"); - } +} static void genInt158(void) - { +{ __asm__ volatile("int $158"); - } +} static void genInt159(void) - { +{ __asm__ volatile("int $159"); - } +} static void genInt160(void) - { +{ __asm__ volatile("int $160"); - } +} static void genInt161(void) - { +{ __asm__ volatile("int $161"); - } +} static void genInt162(void) - { +{ __asm__ volatile("int $162"); - } +} static void genInt163(void) - { +{ __asm__ volatile("int $163"); - } +} static void genInt164(void) - { +{ __asm__ volatile("int $164"); - } +} static void genInt165(void) - { +{ __asm__ volatile("int $165"); - } +} static void genInt166(void) - { +{ __asm__ volatile("int $166"); - } +} static void genInt167(void) - { +{ __asm__ volatile("int $167"); - } +} static void genInt168(void) - { +{ __asm__ volatile("int $168"); - } +} static void genInt169(void) - { +{ __asm__ volatile("int $169"); - } +} static void genInt170(void) - { +{ __asm__ volatile("int $170"); - } +} static void genInt171(void) - { +{ __asm__ volatile("int $171"); - } +} static void genInt172(void) - { +{ __asm__ volatile("int $172"); - } +} static void genInt173(void) - { +{ __asm__ volatile("int $173"); - } +} static void genInt174(void) - { +{ __asm__ volatile("int $174"); - } +} static void genInt175(void) - { +{ __asm__ volatile("int $175"); - } +} static void genInt176(void) - { +{ __asm__ volatile("int $176"); - } +} static void genInt177(void) - { +{ __asm__ volatile("int $177"); - } +} static void genInt178(void) - { +{ __asm__ volatile("int $178"); - } +} static void genInt179(void) - { +{ __asm__ volatile("int $179"); - } +} static void genInt180(void) - { +{ __asm__ volatile("int $180"); - } +} static void genInt181(void) - { +{ __asm__ volatile("int $181"); - } +} static void genInt182(void) - { +{ __asm__ volatile("int $182"); - } +} static void genInt183(void) - { +{ __asm__ volatile("int $183"); - } +} static void genInt184(void) - { +{ __asm__ volatile("int $184"); - } +} static void genInt185(void) - { +{ __asm__ volatile("int $185"); - } +} static void genInt186(void) - { +{ __asm__ volatile("int $186"); - } +} static void genInt187(void) - { +{ __asm__ volatile("int $187"); - } +} static void genInt188(void) - { +{ __asm__ volatile("int $188"); - } +} static void genInt189(void) - { +{ __asm__ volatile("int $189"); - } +} static void genInt190(void) - { +{ __asm__ volatile("int $190"); - } +} static void genInt191(void) - { +{ __asm__ volatile("int $191"); - } +} static void genInt192(void) - { +{ __asm__ volatile("int $192"); - } +} static void genInt193(void) - { +{ __asm__ volatile("int $193"); - } +} static void genInt194(void) - { +{ __asm__ volatile("int $194"); - } +} static void genInt195(void) - { +{ __asm__ volatile("int $195"); - } +} static void genInt196(void) - { +{ __asm__ volatile("int $196"); - } +} static void genInt197(void) - { +{ __asm__ volatile("int $197"); - } +} static void genInt198(void) - { +{ __asm__ volatile("int $198"); - } +} static void genInt199(void) - { +{ __asm__ volatile("int $199"); - } +} static void genInt200(void) - { +{ __asm__ volatile("int $200"); - } +} static void genInt201(void) - { +{ __asm__ volatile("int $201"); - } +} static void genInt202(void) - { +{ __asm__ volatile("int $202"); - } +} static void genInt203(void) - { +{ __asm__ volatile("int $203"); - } +} static void genInt204(void) - { +{ __asm__ volatile("int $204"); - } +} static void genInt205(void) - { +{ __asm__ volatile("int $205"); - } +} static void genInt206(void) - { +{ __asm__ volatile("int $206"); - } +} static void genInt207(void) - { +{ __asm__ volatile("int $207"); - } +} static void genInt208(void) - { +{ __asm__ volatile("int $208"); - } +} static void genInt209(void) - { +{ __asm__ volatile("int $209"); - } +} static void genInt210(void) - { +{ __asm__ volatile("int $210"); - } +} static void genInt211(void) - { +{ __asm__ volatile("int $211"); - } +} static void genInt212(void) - { +{ __asm__ volatile("int $212"); - } +} static void genInt213(void) - { +{ __asm__ volatile("int $213"); - } +} static void genInt214(void) - { +{ __asm__ volatile("int $214"); - } +} static void genInt215(void) - { +{ __asm__ volatile("int $215"); - } +} static void genInt216(void) - { +{ __asm__ volatile("int $216"); - } +} static void genInt217(void) - { +{ __asm__ volatile("int $217"); - } +} static void genInt218(void) - { +{ __asm__ volatile("int $218"); - } +} static void genInt219(void) - { +{ __asm__ volatile("int $219"); - } +} static void genInt220(void) - { +{ __asm__ volatile("int $220"); - } +} static void genInt221(void) - { +{ __asm__ volatile("int $221"); - } +} static void genInt222(void) - { +{ __asm__ volatile("int $222"); - } +} static void genInt223(void) - { +{ __asm__ volatile("int $223"); - } +} static void genInt224(void) - { +{ __asm__ volatile("int $224"); - } +} static void genInt225(void) - { +{ __asm__ volatile("int $225"); - } +} static void genInt226(void) - { +{ __asm__ volatile("int $226"); - } +} static void genInt227(void) - { +{ __asm__ volatile("int $227"); - } +} static void genInt228(void) - { +{ __asm__ volatile("int $228"); - } +} static void genInt229(void) - { +{ __asm__ volatile("int $229"); - } +} static void genInt230(void) - { +{ __asm__ volatile("int $230"); - } +} static void genInt231(void) - { +{ __asm__ volatile("int $231"); - } +} static void genInt232(void) - { +{ __asm__ volatile("int $232"); - } +} static void genInt233(void) - { +{ __asm__ volatile("int $233"); - } +} static void genInt234(void) - { +{ __asm__ volatile("int $234"); - } +} static void genInt235(void) - { +{ __asm__ volatile("int $235"); - } +} static void genInt236(void) - { +{ __asm__ volatile("int $236"); - } +} static void genInt237(void) - { +{ __asm__ volatile("int $237"); - } +} static void genInt238(void) - { +{ __asm__ volatile("int $238"); - } +} static void genInt239(void) - { +{ __asm__ volatile("int $239"); - } +} static void genInt240(void) - { +{ __asm__ volatile("int $240"); - } +} static void genInt241(void) - { +{ __asm__ volatile("int $241"); - } +} static void genInt242(void) - { +{ __asm__ volatile("int $242"); - } +} static void genInt243(void) - { +{ __asm__ volatile("int $243"); - } +} static void genInt244(void) - { +{ __asm__ volatile("int $244"); - } +} static void genInt245(void) - { +{ __asm__ volatile("int $245"); - } +} static void genInt246(void) - { +{ __asm__ volatile("int $246"); - } +} static void genInt247(void) - { +{ __asm__ volatile("int $247"); - } +} static void genInt248(void) - { +{ __asm__ volatile("int $248"); - } +} static void genInt249(void) - { +{ __asm__ volatile("int $249"); - } +} static void genInt250(void) - { +{ __asm__ volatile("int $250"); - } +} static void genInt251(void) - { +{ __asm__ volatile("int $251"); - } +} static void genInt252(void) - { +{ __asm__ volatile("int $252"); - } +} static void genInt253(void) - { +{ __asm__ volatile("int $253"); - } +} static void genInt254(void) - { +{ __asm__ volatile("int $254"); - } +} static void genInt255(void) - { +{ __asm__ volatile("int $255"); - } +} static void (*intFPtr[256])(void) = { - genInt0, genInt1, genInt2,genInt3, - genInt4, genInt5, genInt6,genInt7, - genInt8, genInt9, genInt10,genInt11, - genInt12, genInt13, genInt14,genInt15, - genInt16, genInt17, genInt18,genInt19, - genInt20, genInt21, genInt22,genInt23, - genInt24, genInt25, genInt26,genInt27, - genInt28, genInt29, genInt30,genInt31, - genInt32, genInt33, genInt34,genInt35, - genInt36, genInt37, genInt38,genInt39, - genInt40, genInt41, genInt42,genInt43, - genInt44, genInt45, genInt46,genInt47, - genInt48, genInt49, genInt50,genInt51, - genInt52, genInt53, genInt54,genInt55, - genInt56, genInt57, genInt58,genInt59, - genInt60, genInt61, genInt62,genInt63, - genInt64, genInt65, genInt66,genInt67, - genInt68, genInt69, genInt70,genInt71, - genInt72, genInt73, genInt74,genInt75, - genInt76, genInt77, genInt78,genInt79, - genInt80, genInt81, genInt82,genInt83, - genInt84, genInt85, genInt86,genInt87, - genInt88, genInt89, genInt90,genInt91, - genInt92, genInt93, genInt94,genInt95, - genInt96, genInt97, genInt98,genInt99, - genInt100, genInt101, genInt102,genInt103, - genInt104, genInt105, genInt106,genInt107, - genInt108, genInt109, genInt110,genInt111, - genInt112, genInt113, genInt114,genInt115, - genInt116, genInt117, genInt118,genInt119, - genInt120, genInt121, genInt122,genInt123, - genInt124, genInt125, genInt126,genInt127, - genInt128, genInt129, genInt130,genInt131, - genInt132, genInt133, genInt134,genInt135, - genInt136, genInt137, genInt138,genInt139, - genInt140, genInt141, genInt142,genInt143, - genInt144, genInt145, genInt146,genInt147, - genInt148, genInt149, genInt150,genInt151, - genInt152, genInt153, genInt154,genInt155, - genInt156, genInt157, genInt158,genInt159, - genInt160, genInt161, genInt162,genInt163, - genInt164, genInt165, genInt166,genInt167, - genInt168, genInt169, genInt170,genInt171, - genInt172, genInt173, genInt174,genInt175, - genInt176, genInt177, genInt178,genInt179, - genInt180, genInt181, genInt182,genInt183, - genInt184, genInt185, genInt186,genInt187, - genInt188, genInt189, genInt190,genInt191, - genInt192, genInt193, genInt194,genInt195, - genInt196, genInt197, genInt198,genInt199, - genInt200, genInt201, genInt202,genInt203, - genInt204, genInt205, genInt206,genInt207, - genInt208, genInt209, genInt210,genInt211, - genInt212, genInt213, genInt214,genInt215, - genInt216, genInt217, genInt218,genInt219, - genInt220, genInt221, genInt222,genInt223, - genInt224, genInt225, genInt226,genInt227, - genInt228, genInt229, genInt230,genInt231, - genInt232, genInt233, genInt234,genInt235, - genInt236, genInt237, genInt238,genInt239, - genInt240, genInt241, genInt242,genInt243, - genInt244, genInt245, genInt246,genInt247, - genInt248, genInt249, genInt250,genInt251, - genInt252, genInt253, genInt254,genInt255}; + genInt0, genInt1, genInt2,genInt3, + genInt4, genInt5, genInt6,genInt7, + genInt8, genInt9, genInt10,genInt11, + genInt12, genInt13, genInt14,genInt15, + genInt16, genInt17, genInt18,genInt19, + genInt20, genInt21, genInt22,genInt23, + genInt24, genInt25, genInt26,genInt27, + genInt28, genInt29, genInt30,genInt31, + genInt32, genInt33, genInt34,genInt35, + genInt36, genInt37, genInt38,genInt39, + genInt40, genInt41, genInt42,genInt43, + genInt44, genInt45, genInt46,genInt47, + genInt48, genInt49, genInt50,genInt51, + genInt52, genInt53, genInt54,genInt55, + genInt56, genInt57, genInt58,genInt59, + genInt60, genInt61, genInt62,genInt63, + genInt64, genInt65, genInt66,genInt67, + genInt68, genInt69, genInt70,genInt71, + genInt72, genInt73, genInt74,genInt75, + genInt76, genInt77, genInt78,genInt79, + genInt80, genInt81, genInt82,genInt83, + genInt84, genInt85, genInt86,genInt87, + genInt88, genInt89, genInt90,genInt91, + genInt92, genInt93, genInt94,genInt95, + genInt96, genInt97, genInt98,genInt99, + genInt100, genInt101, genInt102,genInt103, + genInt104, genInt105, genInt106,genInt107, + genInt108, genInt109, genInt110,genInt111, + genInt112, genInt113, genInt114,genInt115, + genInt116, genInt117, genInt118,genInt119, + genInt120, genInt121, genInt122,genInt123, + genInt124, genInt125, genInt126,genInt127, + genInt128, genInt129, genInt130,genInt131, + genInt132, genInt133, genInt134,genInt135, + genInt136, genInt137, genInt138,genInt139, + genInt140, genInt141, genInt142,genInt143, + genInt144, genInt145, genInt146,genInt147, + genInt148, genInt149, genInt150,genInt151, + genInt152, genInt153, genInt154,genInt155, + genInt156, genInt157, genInt158,genInt159, + genInt160, genInt161, genInt162,genInt163, + genInt164, genInt165, genInt166,genInt167, + genInt168, genInt169, genInt170,genInt171, + genInt172, genInt173, genInt174,genInt175, + genInt176, genInt177, genInt178,genInt179, + genInt180, genInt181, genInt182,genInt183, + genInt184, genInt185, genInt186,genInt187, + genInt188, genInt189, genInt190,genInt191, + genInt192, genInt193, genInt194,genInt195, + genInt196, genInt197, genInt198,genInt199, + genInt200, genInt201, genInt202,genInt203, + genInt204, genInt205, genInt206,genInt207, + genInt208, genInt209, genInt210,genInt211, + genInt212, genInt213, genInt214,genInt215, + genInt216, genInt217, genInt218,genInt219, + genInt220, genInt221, genInt222,genInt223, + genInt224, genInt225, genInt226,genInt227, + genInt228, genInt229, genInt230,genInt231, + genInt232, genInt233, genInt234,genInt235, + genInt236, genInt237, genInt238,genInt239, + genInt240, genInt241, genInt242,genInt243, + genInt244, genInt245, genInt246,genInt247, + genInt248, genInt249, genInt250,genInt251, + genInt252, genInt253, genInt254,genInt255}; /******************************************************************************* * @@ -1400,9 +1400,9 @@ static void (*intFPtr[256])(void) = { * \NOMANUAL */ void raiseInt(uint8_t id) - { +{ (*intFPtr[id])(); - } +} #endif /* Intel */ #if defined(CONFIG_CPU_CORTEXM3) @@ -1419,7 +1419,7 @@ void raiseInt(uint8_t id) */ void raiseInt(uint8_t id) - { +{ _NvicSwInterruptTrigger((unsigned int)id); - } +} #endif diff --git a/samples/microkernel/test/test_task_irq/src/test_device.c b/samples/microkernel/test/test_task_irq/src/test_device.c index 88fae4042..c6a562312 100644 --- a/samples/microkernel/test/test_task_irq/src/test_device.c +++ b/samples/microkernel/test/test_task_irq/src/test_device.c @@ -77,63 +77,63 @@ exercises the task_irq_free() API. */ int taskA(ksem_t semRdy) - { +{ if (task_irq_alloc(DEV1_ID, DEV1_IRQ, 1) == INVALID_VECTOR) { - TC_ERROR("Not able to allocate IRQ object\n"); - return TC_FAIL; - } + TC_ERROR("Not able to allocate IRQ object\n"); + return TC_FAIL; + } TC_PRINT("IRQ object %d using IRQ%d allocated\n", DEV1_ID, DEV1_IRQ); if (task_irq_alloc(DEV2_ID, DEV2_IRQ, 2) == INVALID_VECTOR) { - TC_ERROR("Not able to allocate IRQ object\n"); - return TC_FAIL; - } + TC_ERROR("Not able to allocate IRQ object\n"); + return TC_FAIL; + } TC_PRINT("IRQ object %d using IRQ%d allocated\n\n", DEV2_ID, DEV2_IRQ); - /* Send semaphore to let loader know IRQ objects have been allocated */ + /* Send semaphore to let loader know IRQ objects have been allocated */ task_sem_give(semRdy); if (task_irq_test_wait(DEV1_ID) != RC_OK) { - TC_ERROR("Not able to test IRQ object event\n"); - return TC_FAIL; - } + TC_ERROR("Not able to test IRQ object event\n"); + return TC_FAIL; + } TC_PRINT("Received event for IRQ object %d\n", DEV1_ID); task_irq_ack(DEV1_ID); if (task_irq_test_wait(DEV2_ID) != RC_OK) { - TC_ERROR("Not able to test IRQ object event\n"); - return TC_FAIL; - } + TC_ERROR("Not able to test IRQ object event\n"); + return TC_FAIL; + } TC_PRINT("Received event for IRQ object %d\n", DEV2_ID); task_irq_ack(DEV2_ID); - /* Wait for other task to receive its events */ + /* Wait for other task to receive its events */ (void)task_sem_take_wait(semRdy); TC_PRINT("\nAttempt to allocate an IRQ object that\n"); TC_PRINT("is already allocated by another task...\n"); if (task_irq_alloc(DEV4_ID, DEV4_IRQ, 1) != INVALID_VECTOR) { - TC_ERROR("Error: Was able to allocate\n\n"); + TC_ERROR("Error: Was able to allocate\n\n"); return TC_FAIL; - } + } TC_PRINT("Re-allocation of IRQ object %d prevented\n", DEV4_ID); TC_PRINT("\nAttempt to allocate an IRQ that\n" "is already allocated by another task...\n"); if (task_irq_alloc(DEV5_ID, DEV4_IRQ, 1) != INVALID_VECTOR) { - TC_ERROR("Error: Was able to allocate\n\n"); + TC_ERROR("Error: Was able to allocate\n\n"); return TC_FAIL; - } + } TC_PRINT("Re-allocation of IRQ%d prevented\n\n", DEV4_IRQ); - /* Signal other task that we are done processing */ + /* Signal other task that we are done processing */ task_sem_give(semRdy); return TC_PASS; - } +} /******************************************************************************* * @@ -147,46 +147,46 @@ int taskA(ksem_t semRdy) */ int taskB(ksem_t semRdy) - { +{ if (task_irq_alloc(DEV3_ID, DEV3_IRQ, 1) == INVALID_VECTOR) { - TC_ERROR("Not able to allocate IRQ object\n"); - return TC_FAIL; - } + TC_ERROR("Not able to allocate IRQ object\n"); + return TC_FAIL; + } TC_PRINT("IRQ object %d using IRQ%d allocated\n", DEV3_ID, DEV3_IRQ); if (task_irq_alloc(DEV4_ID, DEV4_IRQ, 1) == INVALID_VECTOR) { - TC_ERROR("Not able to allocate IRQ object\n"); - return TC_FAIL; - } + TC_ERROR("Not able to allocate IRQ object\n"); + return TC_FAIL; + } TC_PRINT("IRQ object %d using IRQ%d allocated\n\n", DEV4_ID, DEV4_IRQ); - /* Send semaphore to let loader/main know objects have been allocated */ + /* Send semaphore to let loader/main know objects have been allocated */ task_sem_give(semRdy); if (task_irq_test_wait(DEV3_ID) != RC_OK) { TC_ERROR("Not able to test IRQ object event\n"); return TC_FAIL; - } + } TC_PRINT("Received event for IRQ object %d\n", DEV3_ID); task_irq_ack(DEV3_ID); if (task_irq_test_wait(DEV4_ID) != RC_OK) { - TC_ERROR("Not able to test IRQ object event\n"); - return TC_FAIL; - } + TC_ERROR("Not able to test IRQ object event\n"); + return TC_FAIL; + } TC_PRINT("Received event for IRQ object %d\n", DEV4_ID); task_irq_ack(DEV4_ID); - /* Signal other task that we are done receiving events */ + /* Signal other task that we are done receiving events */ task_sem_give(semRdy); - /* - * Wait for other task to finish processing. The signal just previously - * sent will not be seen here as the other task is a higher priority and - * will thus consume the signal first. - */ + /* + * Wait for other task to finish processing. The signal just previously + * sent will not be seen here as the other task is a higher priority and + * will thus consume the signal first. + */ (void)task_sem_take_wait(semRdy); @@ -195,4 +195,4 @@ int taskB(ksem_t semRdy) TC_PRINT("IRQ object %d freed\n", DEV3_ID); return TC_PASS; - } +} diff --git a/samples/microkernel/test/test_tickless/src/test_tickless.c b/samples/microkernel/test/test_tickless/src/test_tickless.c index bf83c31cc..69a2460ef 100644 --- a/samples/microkernel/test/test_tickless/src/test_tickless.c +++ b/samples/microkernel/test/test_tickless/src/test_tickless.c @@ -88,7 +88,7 @@ extern void _TimestampClose(void); #endif void ticklessTestTask(void) - { +{ int32_t start_ticks; int32_t end_ticks; int32_t diff_ticks; @@ -111,25 +111,25 @@ void ticklessTestTask(void) printk("Calibrating TSC...\n"); #ifdef CONFIG_TICKLESS_IDLE oldThreshold = _sys_idle_threshold_ticks; - /* make sure we do not enter tickless idle mode */ + /* make sure we do not enter tickless idle mode */ _sys_idle_threshold_ticks = 0x7FFFFFFF; #endif - /* initialize the timer, if necessary */ + /* initialize the timer, if necessary */ _TIMESTAMP_OPEN(); for (i = 0; i < CAL_REPS; i++) { - /* - * Do a single tick sleep to get us as close to a tick boundary - * as we can. - */ - task_sleep(1); - start_ticks = task_tick_get_32(); - start_tsc = _TIMESTAMP_READ(); - task_sleep(SLEEP_TICKS); - end_tsc = _TIMESTAMP_READ(); - end_ticks = task_tick_get_32(); - cal_tsc += end_tsc - start_tsc; + /* + * Do a single tick sleep to get us as close to a tick boundary + * as we can. + */ + task_sleep(1); + start_ticks = task_tick_get_32(); + start_tsc = _TIMESTAMP_READ(); + task_sleep(SLEEP_TICKS); + end_tsc = _TIMESTAMP_READ(); + end_ticks = task_tick_get_32(); + cal_tsc += end_tsc - start_tsc; } cal_tsc /= CAL_REPS; @@ -149,17 +149,17 @@ void ticklessTestTask(void) printk("Going idle for %d ticks...\n", SLEEP_TICKS); for (i = 0; i < CAL_REPS; i++) { - /* - * Do a single tick sleep to get us as close to a tick boundary - * as we can. - */ - task_sleep(1); - start_ticks = task_tick_get_32(); - start_tsc = _TIMESTAMP_READ(); - task_sleep(SLEEP_TICKS); - end_tsc = _TIMESTAMP_READ(); - end_ticks = task_tick_get_32(); - diff_tsc += end_tsc - start_tsc; + /* + * Do a single tick sleep to get us as close to a tick boundary + * as we can. + */ + task_sleep(1); + start_ticks = task_tick_get_32(); + start_tsc = _TIMESTAMP_READ(); + task_sleep(SLEEP_TICKS); + end_tsc = _TIMESTAMP_READ(); + end_ticks = task_tick_get_32(); + diff_tsc += end_tsc - start_tsc; } diff_tsc /= CAL_REPS; @@ -180,25 +180,27 @@ void ticklessTestTask(void) printk("Cal time stamp: 0x%x\n", cal_tsc); #endif - /* Calculate percentage difference between calibrated TSC diff and measured result */ - if (diff_tsc > cal_tsc) - diff_per = (100 * (diff_tsc - cal_tsc)) / cal_tsc; - else - diff_per = (100 * (cal_tsc - diff_tsc)) / cal_tsc; + /* Calculate percentage difference between calibrated TSC diff and measured result */ + if (diff_tsc > cal_tsc) { + diff_per = (100 * (diff_tsc - cal_tsc)) / cal_tsc; + } + else { + diff_per = (100 * (cal_tsc - diff_tsc)) / cal_tsc; + } printk("variance in time stamp diff: %d percent\n", (int32_t)diff_per); if (diff_ticks != SLEEP_TICKS) { - printk("* TEST FAILED. TICK COUNT INCORRECT *\n"); - TC_END_REPORT(TC_FAIL); + printk("* TEST FAILED. TICK COUNT INCORRECT *\n"); + TC_END_REPORT(TC_FAIL); } else { - TC_END_REPORT(TC_PASS); - } + TC_END_REPORT(TC_PASS); + } - /* release the timer, if necessary */ + /* release the timer, if necessary */ _TIMESTAMP_CLOSE(); while(1); - } +} diff --git a/samples/microkernel/test/test_tickless/src/timestamps.c b/samples/microkernel/test/test_tickless/src/timestamps.c index 6dd1ddb4d..f8d62a42b 100644 --- a/samples/microkernel/test/test_tickless/src/timestamps.c +++ b/samples/microkernel/test/test_tickless/src/timestamps.c @@ -82,14 +82,14 @@ BSP-specific timestamp support for the tickless idle test. */ void _TimestampOpen(void) - { - /* QEMU does not currently support the 32-bit timer modes of the GPTM */ +{ + /* QEMU does not currently support the 32-bit timer modes of the GPTM */ printk("WARNING! Timestamp is not supported for this target!\n"); - /* enable timer access */ + /* enable timer access */ _CLKGATECTRL |= _CLKGATECTRL_TIMESTAMP_EN; - /* minimum 3 clk delay is required before timer register access */ + /* minimum 3 clk delay is required before timer register access */ task_sleep(3); _TIMESTAMP_CTRL = 0x0; /* disable/reset timer */ @@ -100,7 +100,7 @@ void _TimestampOpen(void) _TIMESTAMP_ICLEAR = 0x70F; /* clear all interrupt status */ _TIMESTAMP_CTRL = 0x1; /* enable timer */ - } +} /******************************************************************************* * @@ -114,30 +114,30 @@ void _TimestampOpen(void) */ uint32_t _TimestampRead(void) - { +{ static uint32_t lastTimerVal = 0; static uint32_t cnt = 0; uint32_t timerVal = _TIMESTAMP_VAL; - /* handle rollover for every other read (end of sleep) */ + /* handle rollover for every other read (end of sleep) */ if ((cnt % 2) && (timerVal > lastTimerVal)) { - lastTimerVal = timerVal; + lastTimerVal = timerVal; - /* convert to extended up-counter value */ - timerVal = _TIMESTAMP_EXT + (_TIMESTAMP_MAX - timerVal); + /* convert to extended up-counter value */ + timerVal = _TIMESTAMP_EXT + (_TIMESTAMP_MAX - timerVal); } else { - lastTimerVal = timerVal; + lastTimerVal = timerVal; - /* convert to up-counter value */ - timerVal = _TIMESTAMP_MAX - timerVal; + /* convert to up-counter value */ + timerVal = _TIMESTAMP_MAX - timerVal; } cnt++; return timerVal; - } +} /******************************************************************************* * @@ -151,15 +151,15 @@ uint32_t _TimestampRead(void) */ void _TimestampClose(void) - { +{ - /* disable/reset timer */ + /* disable/reset timer */ _TIMESTAMP_CTRL = 0x0; _TIMESTAMP_CFG = 0x0; - /* disable timer access */ + /* disable timer access */ _CLKGATECTRL &= ~_CLKGATECTRL_TIMESTAMP_EN; - } +} #elif defined(CONFIG_BSP_FSL_FRDM_K64F) /* Freescale FRDM-K64F target - use RTC (prescale value) */ @@ -198,11 +198,11 @@ void _TimestampClose(void) */ void _TimestampOpen(void) - { - /* enable timer access */ +{ + /* enable timer access */ _CLKGATECTRL |= _CLKGATECTRL_TIMESTAMP_EN; - /* set 32 KHz RTC clk */ + /* set 32 KHz RTC clk */ _SYSOPTCTRL2 |= _SYSOPTCTRL2_32KHZRTCCLK; _TIMESTAMP_STATUS = 0x0; /* disable counter */ @@ -215,13 +215,13 @@ void _TimestampOpen(void) _TIMESTAMP_WACCESS = 0xFF; /* allow register write access */ _TIMESTAMP_IMASK = 0x0; /* mask all timer interrupts */ - /* minimum 0.3 sec delay required for oscillator stabilization */ + /* minimum 0.3 sec delay required for oscillator stabilization */ task_sleep(300000/sys_clock_us_per_tick); _TIMESTAMP_VAL = 0x0; /* clear invalid time flag in status register */ _TIMESTAMP_STATUS = 0x10; /* enable counter */ - } +} /******************************************************************************* * @@ -235,30 +235,30 @@ void _TimestampOpen(void) */ uint32_t _TimestampRead(void) - { +{ static uint32_t lastPrescale = 0; static uint32_t cnt = 0; uint32_t prescale1 = _TIMESTAMP_PRESCALE; uint32_t prescale2 = _TIMESTAMP_PRESCALE; - /* ensure a valid reading */ + /* ensure a valid reading */ while (prescale1 != prescale2) { prescale1 = _TIMESTAMP_PRESCALE; prescale2 = _TIMESTAMP_PRESCALE; - } + } - /* handle prescale rollover @ 0x8000 for every other read (end of sleep) */ + /* handle prescale rollover @ 0x8000 for every other read (end of sleep) */ if ((cnt % 2) && (prescale1 < lastPrescale)) { prescale1 += 0x8000; - } + } lastPrescale = prescale2; cnt++; return prescale1; - } +} /******************************************************************************* * @@ -272,10 +272,10 @@ uint32_t _TimestampRead(void) */ void _TimestampClose(void) - { +{ _TIMESTAMP_STATUS = 0x0; /* disable counter */ _TIMESTAMP_CTRL = 0x0; /* disable oscillator */ - } +} #else #error "Unknown BSP" diff --git a/samples/microkernel/test/test_timer/src/timer.c b/samples/microkernel/test/test_timer/src/timer.c index a50525d63..826cbd759 100644 --- a/samples/microkernel/test/test_timer/src/timer.c +++ b/samples/microkernel/test/test_timer/src/timer.c @@ -128,7 +128,7 @@ int testLowTimerPeriodicity(void) } (void) task_tick_delta_32(&refTime); - /* Use task_timer_restart() to change the periodicity */ + /* Use task_timer_restart() to change the periodicity */ task_timer_restart(pTimer[0], 0, 60); for (i = 0; i < 6; i++) { status = task_sem_take_wait_timeout(TIMER_SEM, 100); diff --git a/samples/microkernel/test/test_xip/src/test_xip.c b/samples/microkernel/test/test_xip/src/test_xip.c index ae98e71ea..f90dd380d 100644 --- a/samples/microkernel/test/test_xip/src/test_xip.c +++ b/samples/microkernel/test/test_xip/src/test_xip.c @@ -66,27 +66,27 @@ void main(void) void RegressionTaskEntry(void) #endif - { +{ int tcRC = TC_PASS; int i; PRINT_DATA("Starting XIP tests\n"); PRINT_LINE; - /* Test globals are correct */ + /* Test globals are correct */ TC_PRINT("Test globals\n"); - /* Array should be filled with monotomically incrementing values */ + /* Array should be filled with monotomically incrementing values */ for (i = 0; i < XIP_TEST_ARRAY_SZ; i++) { - if (xip_array[i] != (i+1)) { - TC_PRINT("xip_array[%d] != %d\n", i, i+1); - tcRC = TC_FAIL; - goto exitRtn; - } + if (xip_array[i] != (i+1)) { + TC_PRINT("xip_array[%d] != %d\n", i, i+1); + tcRC = TC_FAIL; + goto exitRtn; + } } exitRtn: TC_END_RESULT(tcRC); TC_END_REPORT(tcRC); - } +} |