void *POSIX_Init( void *argument ) { struct mq_attr attr; mqd_t mq; TEST_BEGIN(); /* set the time of day, and print our buffer in multiple ways */ set_time( TM_FRIDAY, TM_MAY, 24, 96, 11, 5, 0 ); /* get id of this thread */ Init_id = pthread_self(); printf( "Init's ID is 0x%08" PRIxpthread_t "\n", Init_id ); rtems_workspace_greedy_allocate( NULL, 0 ); attr.mq_maxmsg = MAXMSG; attr.mq_msgsize = MSGSIZE; puts("Init: mq_open - Workspace not available - ENOMEM"); mq = mq_open( Get_Longest_Name(), O_CREAT, 0x777, &attr ); fatal_posix_service_status_errno(mq, ENOMEM, "no workspace available"); TEST_END(); rtems_test_exit( 0 ); return NULL; /* just so the compiler thinks we returned something */ }
rtems_task Init( rtems_task_argument ignored ) { rtems_status_code status; rtems_id extension; rtems_id task_id; TEST_BEGIN(); puts( "Init - rtems_extension_create - OK" ); status = rtems_extension_create( rtems_build_name( 'E', 'X', 'T', ' ' ), &Extensions, &extension ); directive_failed( status, "rtems_extension_create" ); puts( "Init - rtems_task_create - create extension fails - UNSATISFIED" ); status = rtems_task_create( rtems_build_name( 'T', 'A', '1', ' ' ), 1, RTEMS_MINIMUM_STACK_SIZE, RTEMS_TIMESLICE, RTEMS_FLOATING_POINT, &task_id ); fatal_directive_status( status, RTEMS_UNSATISFIED, "rtems_task_create" ); puts( "Init - rtems_extension_delete - OK" ); status = rtems_extension_delete( extension ); directive_failed( status, "rtems_extension_delete" ); TEST_END(); rtems_test_exit(0); }
/* TASK A/B */ rtems_task TaskAB_entry(rtems_task_argument me) { static rtems_mode previous_mode_set; rtems_status_code status; uint32_t iterations = 0; status = rtems_task_mode( RTEMS_PREEMPT | RTEMS_TIMESLICE, RTEMS_PREEMPT_MASK | RTEMS_TIMESLICE_MASK, &previous_mode_set ); directive_failed(status, "Unable to change task mode."); while(1) { if (turn == me) { printf( "Task #%" PRIdrtems_task_argument "'s turn. Now setting turn to %" PRIdrtems_task_argument "\n", me, 1 - me ); if ( ++iterations == 10 ) { TEST_END(); exit( 0 ); } turn = 1 - me; } } }
/* Task01 starts with priority 36 */ rtems_task Task01(rtems_task_argument ignored) { rtems_status_code status; printf("TA01: started with priority %d\n", getprio()); status = rtems_semaphore_obtain( sem_id[0], RTEMS_WAIT, 0 ); directive_failed( status, "rtems_semaphore_obtain of S0\n"); printf("TA01: priority %d, holding S0\n", getprio()); status = rtems_semaphore_obtain( sem_id[1], RTEMS_WAIT, 0 ); directive_failed( status, "rtems_semaphore_obtain of S1"); printf("TA01: priority %d, holding S0, S1\n", getprio()); /* Start Task 2 (TA02) with priority 34. It will run immediately. */ status = rtems_task_start( Task_id[1], Task02, 0); directive_failed( status, "rtems_task_start of TA02\n"); /* Start Task 3 (TA03) with priority 32. It will run immediately. */ status = rtems_task_start( Task_id[2], Task03, 0); directive_failed( status, "rtems_task_start of TA03\n"); printf("TA01: priority %d, holding S0, S1\n", getprio()); status = rtems_semaphore_release(sem_id[1]); directive_failed( status, "rtems_semaphore_release of S1\n"); printf("TA01: priority %d, holding S0\n", getprio()); status = rtems_semaphore_release(sem_id[0]); directive_failed( status, "rtems_semaphore_release of S0\n"); printf("TA01: priority %d\n", getprio()); printf("TA01: exiting\n"); TEST_END(); rtems_test_exit(0); }
rtems_task High_task( rtems_task_argument argument ) { size_t size; (void) rtems_message_queue_receive( Queue_id, (long (*)[4]) Buffer, &size, RTEMS_DEFAULT_OPTIONS, RTEMS_NO_TIMEOUT ); end_time = benchmark_timer_read(); put_time( "rtems_message_queue_send: task readied preempts caller", end_time, operation_count, 0, 0 ); TEST_END(); rtems_test_exit( 0 ); }
static rtems_task Init(rtems_task_argument ignored) { Freechain_Control fc; test_node *node; TEST_BEGIN(); _Freechain_Initialize(&fc, NULL, 0, sizeof(test_node)); rtems_test_assert(_Chain_Is_empty(&fc.Free)); _Freechain_Initialize(&fc, malloc, 1, SIZE_MAX); rtems_test_assert(_Chain_Is_empty(&fc.Free)); rtems_test_assert(_Freechain_Get(&fc, NULL, 0, sizeof(test_node)) == NULL); rtems_test_assert(_Freechain_Get(&fc, malloc, 1, SIZE_MAX) == NULL); /* check whether freechain put and get works correctly*/ _Freechain_Put(&fc, NULL); puts( "INIT - Get node from freechain - OK" ); node = _Freechain_Get(&fc, malloc, 1, sizeof(test_node)); node->x = 1; puts( "INIT - Put node back to freechain - OK" ); _Freechain_Put(&fc, node); puts( "INIT - Verify freechain node put and get - OK" ); node = _Freechain_Get(&fc, NULL, 0, sizeof(test_node)); rtems_test_assert(node->x == 1); TEST_END(); rtems_test_exit(0); }
rtems_task Init( rtems_task_argument argument ) { FILE *fd; int sc; TEST_BEGIN(); puts( "Open /testfile" ); fd = fopen( "/testfile", "w+" ); rtems_test_assert( fd ); puts( "flockfile /testfile" ); flockfile( fd ); puts( "ftrylockfile /testfile" ); sc = ftrylockfile( fd ); rtems_test_assert( sc == -1 ); rtems_test_assert( errno == ENOTSUP ); puts( "flockfile /testfile" ); flockfile( fd ); puts( "funlockfile /testfile" ); funlockfile( fd ); TEST_END(); rtems_test_exit(0); }
void *Low( void *argument ) { int status; benchmark_timer_t end_time; /* write locking */ status = pthread_rwlock_wrlock(&rwlock); end_time = benchmark_timer_read(); rtems_test_assert( status == 0 ); put_time( "pthread_rwlock_unlock: thread waiting preempt", end_time, OPERATION_COUNT, 0, 0 ); TEST_END(); rtems_test_exit( 0 ); return NULL; }
rtems_task Init( rtems_task_argument ignored ) { rtems_status_code status; TEST_BEGIN(); puts( "Init - Trying to generate semaphore release from ISR while blocking" ); puts( "Init - Variation is: " TEST_STRING ); status = rtems_semaphore_create( rtems_build_name( 'S', 'M', '1', ' ' ), 0, SEMAPHORE_ATTRIBUTES, RTEMS_NO_PRIORITY, &Semaphore ); directive_failed( status, "rtems_semaphore_create of SM1" ); interrupt_critical_section_test( test_body, NULL, test_release_from_isr ); if ( case_hit ) { puts( "Init - Case hit" ); TEST_END(); } else puts( "Init - Case not hit - ran too long" ); rtems_test_exit(0); }
static rtems_task Init( rtems_task_argument ignored ) { rtems_status_code sc; TEST_BEGIN(); thread = _Thread_Get_executing(); puts( "Init - Test may not be able to detect case is hit reliably" ); puts( "Init - Trying to generate timeout from ISR while blocking" ); sc = rtems_semaphore_create( rtems_build_name( 'S', 'M', '1', ' ' ), 0, RTEMS_DEFAULT_ATTRIBUTES, RTEMS_NO_PRIORITY, &Semaphore ); directive_failed( sc, "rtems_semaphore_create of SM1" ); interrupt_critical_section_test( test_body, NULL, test_release_from_isr ); if ( case_hit ) { puts( "Init - It appears the case has been hit" ); TEST_END(); } else puts( "Init - Case not hit - ran too long" ); rtems_test_exit(0); }
rtems_task Task_1_through_3( rtems_task_argument argument ) { rtems_id tid; rtems_time_of_day time; rtems_status_code status; status = rtems_task_ident( RTEMS_SELF, RTEMS_SEARCH_ALL_NODES, &tid ); directive_failed( status, "rtems_task_ident of self" ); while ( FOREVER ) { status = rtems_timer_server_fire_after( Timer_id[ argument ], (task_number( tid ) - 1) * 5 * rtems_clock_get_ticks_per_second(), Resume_task, (void *) &tid ); directive_failed( status, "rtems_timer_server_fire_after failed" ); status = rtems_clock_get_tod( &time ); directive_failed( status, "rtems_clock_get_tod failed" ); if ( time.second >= 35 ) { TEST_END(); rtems_test_exit( 0 ); } put_name( Task_name[ task_number( tid ) - 1 ], FALSE ); print_time( " - rtems_clock_get_tod - ", &time, "\n" ); status = rtems_task_suspend( RTEMS_SELF ); directive_failed( status, "rtems_task_suspend" ); } }
static void Init(rtems_task_argument arg) { test_context *ctx = &test_instance; TEST_BEGIN(); ctx->low = rtems_task_self(); create_task(&ctx->mid, 3); create_task(&ctx->high, 1); create_task(&ctx->inversion, 2); create_sema(&ctx->sem_a); create_sema(&ctx->sem_b); obtain_sema(ctx->sem_a); start_task(ctx->mid, mid_task); start_task(ctx->high, high_task); /* * Here we see that the priority of the high priority task blocked on * semaphore B propagated to the low priority task owning semaphore A * on which the owner of semaphore B depends. */ assert_prio(ctx->low, 1); assert_prio(ctx->mid, 1); assert_prio(ctx->high, 1); assert_prio(ctx->inversion, 2); TEST_END(); rtems_test_exit(0); }
int main(int argc, char *argv[]) { TEST_START(); TEST(test_cat()); TEST_END(); return 0; }
void *Blocker( void *argument ) { uint32_t end_time; struct sched_param param; int policy; int status; status = pthread_mutex_lock(&MutexID); rtems_test_assert( status == 0 ); status = pthread_getschedparam(pthread_self(), &policy, ¶m); rtems_test_assert( status == 0 ); param.sched_priority = sched_get_priority_max(policy) - 1; status = pthread_setschedparam(pthread_self(), policy, ¶m); /* Thread blocks, unlocks mutex, waits for CondID to be signaled */ pthread_cond_wait(&CondID,&MutexID); /* Once signaled, this thread preempts POSIX_Init thread */ end_time = benchmark_timer_read(); put_time( "pthread_cond_signal: thread waiting preempt", end_time, 1, 0, 0 ); TEST_END(); rtems_test_exit( 0 ); return NULL; }
rtems_task High_task( rtems_task_argument argument ) { int index; benchmark_timer_initialize(); for ( index=1 ; index < operation_count ; index++ ) (void) benchmark_timer_empty_function(); overhead = benchmark_timer_read(); benchmark_timer_initialize(); for ( index=1 ; index <= operation_count ; index++ ) (void) rtems_message_queue_urgent( Queue_id, Buffer, MESSAGE_SIZE ); end_time = benchmark_timer_read(); put_time( "rtems_message_queue_urgent: task readied returns to caller", end_time, operation_count, overhead, 0 ); TEST_END(); rtems_test_exit( 0 ); }
rtems_task Task_1_through_3( rtems_task_argument index ) { rtems_time_of_day time; rtems_status_code status; rtems_interval ticks; rtems_name name; status = rtems_object_get_classic_name( rtems_task_self(), &name ); directive_failed( status, "rtems_object_get_classic_name" ); ticks = RTEMS_MILLISECONDS_TO_TICKS( index * 5 * 1000 ); while( FOREVER ) { status = rtems_clock_get_tod( &time ); directive_failed( status, "rtems_clock_get_tod" ); if ( time.second >= 35 ) { TEST_END(); rtems_test_exit( 0 ); } put_name( name, FALSE ); print_time( " - rtems_clock_get_tod - ", &time, "\n" ); status = rtems_task_wake_after( ticks ); directive_failed( status, "rtems_task_wake_after" ); } }
void *Low( void *argument ) { benchmark_timer_t end_time; /* * Now we have finished the thread startup overhead, * so let other threads run. When we return, we can * finish the benchmark. */ sched_yield(); /* let other threads run */ end_time = benchmark_timer_read(); put_time( "pthread_rwlock_timedwrlock: not available blocks", end_time, OPERATION_COUNT, 0, 0 ); TEST_END(); rtems_test_exit( 0 ); return NULL; }
int main(int argc, char *argv[]) { TEST_START(); TEST(test_quad_textured(0, 0)); TEST(test_quad_textured(0, 1)); TEST(test_quad_textured(0, 2)); TEST(test_quad_textured(0, 3)); TEST(test_quad_textured(0, 4)); TEST(test_quad_textured(0, 5)); TEST(test_quad_textured(0, 6)); TEST(test_quad_textured(0, 7)); TEST(test_quad_textured(0, 8)); TEST(test_quad_textured(0, 9)); TEST(test_quad_textured(1, GL_NEVER)); TEST(test_quad_textured(1, GL_LESS)); TEST(test_quad_textured(1, GL_EQUAL)); TEST(test_quad_textured(1, GL_LEQUAL)); TEST(test_quad_textured(1, GL_GREATER)); TEST(test_quad_textured(1, GL_NOTEQUAL)); TEST(test_quad_textured(1, GL_GEQUAL)); TEST(test_quad_textured(1, GL_ALWAYS)); TEST_END(); return 0; }
static void Init(rtems_task_argument arg) { test_context *self = &test_instance; int i; int j; int k; TEST_BEGIN(); test_context_is_executing(); for (i = 0; i < 2; ++i) { for (j = 0; j < 2; ++j) { for (k = 0; k < 2; ++k) { printf("Test configuration %s %s %s... ", desc(i), desc(j), desc(k)); test(self, is_fp(i), is_fp(j), is_fp(k)); printf("done\n"); } } } TEST_END(); rtems_test_exit(0); }
static void Init(rtems_task_argument arg) { TEST_BEGIN(); test(); TEST_END(); rtems_test_exit(0); }
void *POSIX_Init(void *argument) { TEST_BEGIN(); /* creating unnamed semaphore */ benchmark_sem_init(); /* destroying unnamed semaphore */ benchmark_sem_destroy(); /* opening named semaphore first time o_flag = O_CREAT */ benchmark_sem_open(true); /* opening named semaphore second time o_flag = O_EXCL */ benchmark_sem_open_second(); /* close named semaphore first time -- does not delete */ benchmark_sem_close(true); /* unlink named semaphore -- does not delete */ benchmark_sem_unlink("sem_unlink: does not delete"); /* close semaphore the second time, this actually deletes it */ benchmark_sem_close_second(); /* recrate named semaphore first time o_flag = O_CREAT */ benchmark_sem_open(false); benchmark_sem_close(false); benchmark_sem_unlink("sem_unlink: deletes semaphore"); TEST_END(); rtems_test_exit(0); }
static void Init(rtems_task_argument ignored) { test_context *ctx = &ctx_instance; rtems_status_code sc; TEST_BEGIN(); ctx->main_task_control = _Thread_Get_executing(); sc = rtems_semaphore_create( rtems_build_name('S', 'E', 'M', 'A'), 1, RTEMS_SIMPLE_BINARY_SEMAPHORE, 0, &ctx->semaphore_id ); rtems_test_assert(sc == RTEMS_SUCCESSFUL); ctx->semaphore_control = get_semaphore_control(ctx->semaphore_id); interrupt_critical_section_test(test_body, ctx, release_semaphore); rtems_test_assert(ctx->done); TEST_END(); rtems_test_exit(0); }
static void test(const char *rda, const char *mnt, const char *file) { static const msdos_format_request_param_t rqdata = { .quick_format = true, .sync_device = true }; rtems_status_code sc; int disk_fd; int rv; sc = rtems_disk_io_initialize(); rtems_test_assert(sc == RTEMS_SUCCESSFUL); disk_fd = open(rda, O_RDWR); rtems_test_assert(disk_fd >= 0); rv = msdos_format(rda, &rqdata); rtems_test_assert(rv == 0); rv = mount_and_make_target_path( rda, mnt, RTEMS_FILESYSTEM_TYPE_DOSFS, RTEMS_FILESYSTEM_READ_WRITE, NULL ); rtems_test_assert(rv == 0); create_file(file); rv = rtems_disk_fd_purge(disk_fd); rtems_test_assert(rv == 0); write_to_file(file, false); rv = rtems_disk_fd_purge(disk_fd); rtems_test_assert(rv == 0); check_file_size(file, 0); write_to_file(file, true); rv = rtems_disk_fd_purge(disk_fd); rtems_test_assert(rv == 0); check_file_size(file, 1); rv = unmount(mnt); rtems_test_assert(rv == 0); rv = close(disk_fd); rtems_test_assert(rv == 0); } static void Init(rtems_task_argument arg) { TEST_BEGIN(); test("/dev/rda", "/mnt", "/mnt/file"); TEST_END(); rtems_test_exit(0); }
rtems_task Task_2( rtems_task_argument argument ) { rtems_cpu_usage_top(); TEST_END(); rtems_test_exit( 0 ); }
int main(int argc, char **argv) { TEST_START(); TEST(test_multi()); TEST_END(); return 0; }
void *POSIX_Init( void *ignored ) { TEST_BEGIN(); puts( " Affinity NOT Supported"); TEST_END(); rtems_test_exit(0); }
static void Init(rtems_task_argument arg) { TEST_BEGIN(); test_smp_cache_manager(); TEST_END(); rtems_test_exit(0); }
int main(int argc, char *argv[]) { TEST_START(); TEST(test_triangle_smoothed(GL_CCW)); TEST(test_triangle_smoothed(GL_CW)); TEST_END(); return 0; }
int main(int argc, char *argv[]) { TEST_START(); TEST(test_strip_smoothed(0)); TEST(test_strip_smoothed(1)); TEST_END(); return 0; }
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); }