static void Init(rtems_task_argument arg) { rtems_status_code sc; rtems_name to_name = rtems_build_name('I', 'D', 'L', 'E');; uint32_t i; TEST_BEGIN(); sc = rtems_capture_open (5000, NULL); rtems_test_assert(sc == RTEMS_SUCCESSFUL); sc = rtems_capture_watch_ceiling (0); rtems_test_assert(sc == RTEMS_SUCCESSFUL); sc = rtems_capture_watch_floor (20); rtems_test_assert(sc == RTEMS_SUCCESSFUL); sc = rtems_capture_watch_global (true); rtems_test_assert(sc == RTEMS_SUCCESSFUL); sc = rtems_capture_set_trigger ( 0, 0, to_name, 0, rtems_capture_from_any, rtems_capture_switch ); rtems_test_assert(sc == RTEMS_SUCCESSFUL); for (i = 1; i < TASK_COUNT; i++) { to_name = rtems_build_name('T', 'A', '0', '0'+i); sc = rtems_capture_set_trigger ( 0, 0, to_name, 0, rtems_capture_from_any, rtems_capture_switch ); } sc = rtems_capture_set_control (true); rtems_test_assert(sc == RTEMS_SUCCESSFUL); test(); sc = rtems_capture_set_control (false); rtems_test_assert(sc == RTEMS_SUCCESSFUL); rtems_capture_print_trace_records ( 22, false ); rtems_capture_print_trace_records ( 22, false ); rtems_capture_print_trace_records ( 22, false ); TEST_END(); rtems_test_exit(0); }
static void Init(rtems_task_argument arg) { rtems_status_code sc; uint32_t i; uint32_t cpu; uint32_t cpu_count; uint32_t read; uint32_t enter_count; uint32_t exit_count; uint32_t clock_tick_count; uint32_t res_should_be; rtems_name name; rtems_capture_record_t *recs; rtems_capture_record_t *prev_rec; empty_record_t *record; enter_add_number_record_t *enter_add_number_rec; exit_add_number_record_t *exit_add_number_rec; rtems_vector_number vec; clock_interrupt_handler cih = {.found = 0}; TEST_BEGIN(); /* Get the number of processors that we are using. */ cpu_count = rtems_get_processor_count(); sc = rtems_capture_open(50000, NULL); rtems_test_assert(sc == RTEMS_SUCCESSFUL); sc = rtems_capture_watch_global(true); rtems_test_assert(sc == RTEMS_SUCCESSFUL); sc = rtems_capture_control(true); rtems_test_assert(sc == RTEMS_SUCCESSFUL); /* Run main test */ test(cpu_count); /* Try to find the clock interrupt handler */ for ( vec=BSP_INTERRUPT_VECTOR_MIN; vec<BSP_INTERRUPT_VECTOR_MAX; vec++ ) { rtems_interrupt_handler_iterate(vec, locate_clock_interrupt_handler, &cih); if ( cih.found ) break; } /* If we find the clock interrupt handler we replace it with * a wrapper and wait for a fixed number of ticks. */ if ( cih.found ) { #ifdef VERBOSE printf("Found a clock handler\n"); #endif org_clock_handler = cih.handler; rtems_interrupt_handler_install(vec, cih.info, cih.options | RTEMS_INTERRUPT_REPLACE, clock_tick_wrapper, cih.arg); rtems_task_wake_after(CLOCK_TICKS); } /* Disable capturing */ sc = rtems_capture_control(false); rtems_test_assert(sc == RTEMS_SUCCESSFUL); clock_tick_count = 0; /* Read out the trace from all processors */ for ( cpu = 0; cpu < cpu_count; cpu++ ) { sc = rtems_capture_read(cpu, &read, &recs); rtems_test_assert(sc == RTEMS_SUCCESSFUL); prev_rec = recs; enter_count = 0; exit_count = 0; res_should_be = 0; for ( i = 0; i < read; i++ ) { /* Verify that time goes forward */ rtems_test_assert(recs->time>=prev_rec->time); if ( recs->events & RTEMS_CAPTURE_TIMESTAMP ) { record = (empty_record_t*)((char*) recs + sizeof(rtems_capture_record_t)); switch ( record->id ) { case enter_add_number: rtems_test_assert(enter_count==exit_count); enter_count++; enter_add_number_rec = (enter_add_number_record_t*)record; res_should_be = add_number(enter_add_number_rec->a, enter_add_number_rec->b); rtems_object_get_classic_name(recs->task_id, &name); #ifdef VERBOSE /* Print record */ printf("Time: %"PRIu64"us Task: %4s => Add %"PRIu32" and" " %"PRIu32"\n", recs->time/1000, (char*)&name, enter_add_number_rec->a, enter_add_number_rec->b); #endif break; case exit_add_number: rtems_test_assert(enter_count==exit_count+1); exit_count++; exit_add_number_rec = (exit_add_number_record_t*)record; /* Verify that the result matches the expected result */ rtems_test_assert(res_should_be == exit_add_number_rec->res); #ifdef VERBOSE /* Print record */ rtems_object_get_classic_name(recs->task_id, &name); printf("Time: %"PRIu64"us Task: %4s => Result is %"PRIu32"\n", recs->time/1000, (char*)&name, exit_add_number_rec->res); #endif break; case clock_tick: clock_tick_count++; #ifdef VERBOSE rtems_object_get_classic_name(recs->task_id, &name); printf("Time: %"PRIu64"us Task: %4s => Clock tick\n", recs->time/1000, (char*)&name); #endif break; default: rtems_test_assert(0); } } prev_rec = recs; recs = (rtems_capture_record_t*) ((char*) recs + recs->size); } rtems_test_assert(enter_count == exit_count); rtems_test_assert(enter_count == TASKS_PER_CPU * ITERATIONS); rtems_capture_release(cpu, read); } if( cih.found ) rtems_test_assert(clock_tick_count == cpu_count * CLOCK_TICKS); TEST_END(); rtems_test_exit(0); }