tests: context: make some failures less ambiguous

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
This commit is contained in:
Andrew Boie 2017-06-05 12:47:45 -07:00 committed by Anas Nashif
commit 7a5150cd9f

View file

@ -189,7 +189,7 @@ static int kernel_init_objects(void)
*/
static int test_kernel_cpu_idle(int atomic)
{
int tms; /* current time in millisecond */
int tms, tms2;; /* current time in millisecond */
int i; /* loop variable */
/* Align to a "ms boundary". */
@ -208,7 +208,10 @@ static int test_kernel_cpu_idle(int atomic)
}
/* calculating milliseconds per tick*/
tms += sys_clock_us_per_tick / USEC_PER_MSEC;
if (k_uptime_get_32() < tms) {
tms2 = k_uptime_get_32();
if (tms2 < tms) {
TC_ERROR("Bad ms per tick value computed, got %d which is less than %d\n",
tms2, tms);
return TC_FAIL;
}
}
@ -317,6 +320,7 @@ static int test_kernel_interrupts(disable_int_func disable_int,
enable_int(imask);
if (tick2 != tick) {
TC_ERROR("tick advanced with interrupts locked\n");
return TC_FAIL;
}
@ -325,7 +329,13 @@ static int test_kernel_interrupts(disable_int_func disable_int,
_tick_get_32();
}
return (tick == _tick_get_32()) ? TC_FAIL : TC_PASS;
tick2 = _tick_get_32();
if (tick == tick2) {
TC_ERROR("tick didn't advance as expected\n");
return TC_FAIL;
}
return TC_PASS;
}
/**
@ -351,11 +361,14 @@ static int test_kernel_ctx_task(void)
isr_info.error = 0;
/* isr_info is modified by the isr_handler routine */
isr_handler_trigger();
if (isr_info.error || isr_info.data != (void *)self_thread_id) {
/*
* Either the ISR detected an error, or the ISR context ID
* does not match the interrupted task's thread ID.
*/
if (isr_info.error) {
TC_ERROR("ISR detected an error\n");
return TC_FAIL;
}
if (isr_info.data != (void *)self_thread_id) {
TC_ERROR("ISR context ID mismatch\n");
return TC_FAIL;
}
@ -363,12 +376,24 @@ static int test_kernel_ctx_task(void)
isr_info.command = EXEC_CTX_TYPE_CMD;
isr_info.error = 0;
isr_handler_trigger();
if (isr_info.error || isr_info.value != K_ISR) {
if (isr_info.error) {
TC_ERROR("ISR detected an error\n");
return TC_FAIL;
}
TC_PRINT("Testing k_is_in_isr() from a preemtible thread\n");
if (k_is_in_isr() || _current->base.prio < 0) {
if (isr_info.value != K_ISR) {
TC_ERROR("isr_info.value was not K_ISR\n");
return TC_FAIL;
}
TC_PRINT("Testing k_is_in_isr() from a preemptible thread\n");
if (k_is_in_isr()) {
TC_ERROR("Should not be in ISR context\n");
return TC_FAIL;
}
if (_current->base.prio < 0) {
TC_ERROR("Current thread should have preemptible priority\n");
return TC_FAIL;
}
@ -670,6 +695,7 @@ static void test_thread_sleep(void *delta, void *arg2, void *arg3)
TC_PRINT(" thread back from sleep\n");
if (timestamp < timeout || timestamp > timeout + 10) {
TC_ERROR("timestamp out of range, got %d\n", (int)timestamp);
return;
}