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


C++ rtems_test_assert函数代码示例

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


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

示例1: Init

rtems_task Init(
  rtems_task_argument ignored
)
{
  int fd[2] = {0,0};
  int dummy_fd[2] = {0,0};
  int status = 0;
  void *opaque = NULL;

  TEST_BEGIN();

  puts( "Init - attempt to create pipe -- expect EFAULT" );
  status = pipe( NULL );
  rtems_test_assert( status == -1 );
  rtems_test_assert( errno == EFAULT );

  puts( "Init - create pipe -- OK" );
  status = pipe( fd );
  rtems_test_assert( status == 0 );

  status = close( fd[0] );
  status |= close( fd[1] );
  rtems_test_assert( status == 0 );

  puts( "Init - create pipe -- OK" );
  status = pipe( fd );
  rtems_test_assert( status == 0 );

  status = close( fd[0] );
  status |= close( fd[1] );
  rtems_test_assert( status == 0 );

  opaque = rtems_heap_greedy_allocate( NULL, 0 );

  /* case where mkfifo fails */
  puts( "Init - attempt to create pipe -- expect ENOMEM" );
  status = pipe( fd );
  rtems_test_assert( status == -1 );
  rtems_test_assert( errno == ENOMEM );

  rtems_heap_greedy_free( opaque );
  
  dummy_fd[0] = open( "/file01", O_RDONLY | O_CREAT, S_IRWXU );
  rtems_test_assert( dummy_fd[0] != -1 );
  dummy_fd[1] = open( "/file02", O_RDONLY | O_CREAT, S_IRWXU );
  rtems_test_assert( dummy_fd[1] != -1 );

  /* case where fifo_open for read => open fails */
  puts( "Init - create pipe -- expect ENFILE" );
  status = pipe( fd );
  rtems_test_assert( status == -1 );
  rtems_test_assert( errno == ENFILE );

  status = close( dummy_fd[1] );
  status |= unlink( "/file02" );
  rtems_test_assert( status == 0 );

  /* case where fifo_open for write => open fails */
  puts( "Init - create pipe -- expect ENFILE" );
  status = pipe( fd );
  rtems_test_assert( status == -1 );
  rtems_test_assert( errno == ENFILE );

  status = close( dummy_fd[0] );
  status |= unlink( "/file01" );
  rtems_test_assert( status == 0 );

  TEST_END();
  rtems_test_exit( 0 );
}
开发者ID:Avanznow,项目名称:rtems,代码行数:70,代码来源:init.c

示例2: main

int main(
  int    argc,
  char **argv
)
#endif
{
  pthread_rwlock_t     rwlock;
  pthread_rwlockattr_t attr;
  int                  status;
  int                  p;
  int                  i;
  struct timespec      abstime;

  TEST_BEGIN();

  /*************** NULL POINTER CHECKS *****************/
  puts( "pthread_rwlockattr_init( NULL ) -- EINVAL" );
  status = pthread_rwlockattr_init( NULL );
  rtems_test_assert( status == EINVAL );

  puts( "pthread_rwlockattr_setpshared( NULL, private ) -- EINVAL" );
  status = pthread_rwlockattr_setpshared( NULL, PTHREAD_PROCESS_PRIVATE );
  rtems_test_assert( status == EINVAL );

  puts( "pthread_rwlockattr_setpshared( NULL, shared ) -- EINVAL" );
  status = pthread_rwlockattr_setpshared( NULL, PTHREAD_PROCESS_SHARED );
  rtems_test_assert( status == EINVAL );

  puts( "pthread_rwlockattr_getpshared( NULL, &p ) -- EINVAL" );
  status = pthread_rwlockattr_getpshared( NULL, &p );
  rtems_test_assert( status == EINVAL );

  puts( "pthread_rwlockattr_destroy( NULL ) -- EINVAL" );
  status = pthread_rwlockattr_destroy( NULL );
  rtems_test_assert( status == EINVAL );

  /*************** NOT INITIALIZED CHECKS *****************/
  /* cheat visibility */
  attr.is_initialized = 0;
  puts( "pthread_rwlockattr_setpshared( &attr, shared ) -- EINVAL" );
  status = pthread_rwlockattr_setpshared( &attr, PTHREAD_PROCESS_SHARED );
  rtems_test_assert( status == EINVAL );

  puts( "pthread_rwlockattr_getpshared( &attr, NULL ) -- EINVAL" );
  status = pthread_rwlockattr_getpshared( &attr, NULL );
  rtems_test_assert( status == EINVAL );

  puts( "pthread_rwlockattr_destroy( &attr ) -- EINVAL" );
  status = pthread_rwlockattr_destroy( &attr );
  rtems_test_assert( status == EINVAL );

  /*************** BAD PSHARED CHECK *****************/
  puts( "pthread_rwlockattr_setpshared( &attr, private ) -- EINVAL" );
  status = pthread_rwlockattr_setpshared( &attr, ~PTHREAD_PROCESS_PRIVATE );
  rtems_test_assert( status == EINVAL );

  /*************** ACTUALLY WORK THIS TIME *****************/
  puts( "pthread_rwlockattr_init( &attr ) -- OK" );
  status = pthread_rwlockattr_init( &attr );
  rtems_test_assert( status == 0 );

  puts( "pthread_rwlockattr_setpshared( &attr, private ) -- OK" );
  status = pthread_rwlockattr_setpshared( &attr, PTHREAD_PROCESS_PRIVATE );
  rtems_test_assert( status == 0 );

  puts( "pthread_rwlockattr_getpshared( &attr, &p ) -- OK" );
  status = pthread_rwlockattr_getpshared( &attr, &p );
  rtems_test_assert( status == 0 );
  rtems_test_assert( p == PTHREAD_PROCESS_PRIVATE );

  puts( "pthread_rwlockattr_setpshared( &attr, shared ) -- OK" );
  status = pthread_rwlockattr_setpshared( &attr, PTHREAD_PROCESS_SHARED );
  rtems_test_assert( status == 0 );

  puts( "pthread_rwlockattr_getpshared( &attr, &p ) -- OK" );
  status = pthread_rwlockattr_getpshared( &attr, &p );
  rtems_test_assert( status == 0 );
  rtems_test_assert( p == PTHREAD_PROCESS_SHARED );

  /*************** DESTROY/REUSE CHECK *****************/
  puts( "pthread_rwlockattr_destroy( &attr ) -- OK" );
  status = pthread_rwlockattr_destroy( &attr );
  rtems_test_assert( status == 0 );

  puts( "pthread_rwlockattr_getpshared( &attr, &p ) destroyed -- EINVAL" );
  status = pthread_rwlockattr_getpshared( &attr, &p );
  rtems_test_assert( status == EINVAL );

  /*************** NULL ARGUMENT CHECKS *****************/
  abstime.tv_sec = 0;
  abstime.tv_nsec = 0;

  puts( "pthread_rwlock_init(NULL, &attr) -- EINVAL" );
  status = pthread_rwlock_init(NULL, &attr);
  rtems_test_assert( status == EINVAL );

  puts( "pthread_rwlock_destroy(NULL) -- EINVAL" );
  status = pthread_rwlock_destroy(NULL);
  rtems_test_assert( status == EINVAL );

//.........这里部分代码省略.........
开发者ID:Fyleo,项目名称:rtems,代码行数:101,代码来源:test.c

示例3: test_blkdev_imfs_errors

static void test_blkdev_imfs_errors(void)
{
  rtems_status_code sc;
  int rv;
  ramdisk *rd;
  void *opaque;

  rd = ramdisk_allocate(NULL, BLOCK_SIZE, BLOCK_COUNT, false);
  rtems_test_assert(rd != NULL);

  ramdisk_enable_free_at_delete_request(rd);

  sc = rtems_blkdev_create(
    rda,
    0,
    BLOCK_COUNT,
    ramdisk_ioctl,
    rd
  );
  rtems_test_assert(sc == RTEMS_INVALID_NUMBER);

  sc = rtems_blkdev_create(
    rda,
    BLOCK_SIZE,
    0,
    ramdisk_ioctl,
    rd
  );
  rtems_test_assert(sc == RTEMS_INVALID_NUMBER);

  opaque = rtems_heap_greedy_allocate(0);
  sc = rtems_blkdev_create(
    rda,
    BLOCK_SIZE,
    BLOCK_COUNT,
    ramdisk_ioctl,
    rd
  );
  rtems_test_assert(sc == RTEMS_NO_MEMORY);
  rtems_heap_greedy_free(opaque);

  opaque = rtems_heap_greedy_allocate(sizeof(rtems_disk_device) + sizeof(int));
  sc = rtems_blkdev_create(
    rda,
    BLOCK_SIZE,
    BLOCK_COUNT,
    ramdisk_ioctl,
    rd
  );
  rtems_test_assert(sc == RTEMS_UNSATISFIED);
  rtems_heap_greedy_free(opaque);

  sc = rtems_blkdev_create(
    rda,
    BLOCK_SIZE,
    BLOCK_COUNT,
    ramdisk_ioctl,
    rd
  );
  ASSERT_SC(sc);

  sc = rtems_blkdev_create_partition(
    rda1,
    not_exist,
    0,
    BLOCK_COUNT
  );
  rtems_test_assert(sc == RTEMS_INVALID_ID);

  rv = mknod(not_blkdev, S_IFREG | S_IRWXU | S_IRWXG | S_IRWXO, 0);
  rtems_test_assert(rv == 0);

  sc = rtems_blkdev_create_partition(
    rda1,
    not_blkdev,
    0,
    BLOCK_COUNT
  );
  rtems_test_assert(sc == RTEMS_INVALID_NODE);

  rv = mknod(invalid_blkdev, S_IFBLK | S_IRWXU | S_IRWXG | S_IRWXO, 0);
  rtems_test_assert(rv == 0);

  sc = rtems_blkdev_create_partition(
    rda1,
    invalid_blkdev,
    0,
    BLOCK_COUNT
  );
  rtems_test_assert(sc == RTEMS_NOT_IMPLEMENTED);

  sc = rtems_blkdev_create_partition(
    rda1,
    rda,
    0,
    0
  );
  rtems_test_assert(sc == RTEMS_INVALID_NUMBER);

  sc = rtems_blkdev_create_partition(
//.........这里部分代码省略.........
开发者ID:medivhc,项目名称:rtems,代码行数:101,代码来源:init.c

示例4: Init

rtems_task Init(
  rtems_task_argument argument
)
{
  clock_t    start;
  clock_t    end;
  clock_t    now;
  clock_t    sc;
  clock_t    difference;
  struct tms start_tm;
  struct tms end_tm;

  puts( "\n\n*** TEST TIMES 01 ***" );

  puts( "times( NULL ) -- EFAULT" );
  sc = times( NULL );
  rtems_test_assert( sc == -1 );
  rtems_test_assert( errno == EFAULT );

  puts( "_times_r( NULL, NULL ) -- EFAULT" );
  start = _times_r( NULL, NULL );
  rtems_test_assert( sc == -1 );
  rtems_test_assert( errno == EFAULT );

  while ( rtems_clock_get_ticks_since_boot() == 0 )
    ;

  puts( "_times( &start_tm ) -- OK" );
  now = _times( &start_tm );
  rtems_test_assert( start != 0 );
  rtems_test_assert( now != 0 );
  
  rtems_test_spin_for_ticks(5);

  puts( "_times( &end_tm ) -- OK" );
  end = _times( &end_tm );
  rtems_test_assert( end != 0 );
  
  puts( "Check various values" );
  difference = end - start;
  rtems_test_assert( difference >= 5 );

  rtems_test_assert( end_tm.tms_utime >= start_tm.tms_utime );
  rtems_test_assert( end_tm.tms_stime >= start_tm.tms_stime );
  rtems_test_assert( end_tm.tms_cutime == 0 );
  rtems_test_assert( end_tm.tms_cstime == 0 );
  
  puts( "*** END OF TEST TIMES 01 ***" );

  rtems_test_exit(0);
}
开发者ID:0871087123,项目名称:rtems,代码行数:51,代码来源:init.c

示例5: test_chain_with_notification

static void test_chain_with_notification(void)
{
  rtems_status_code sc = RTEMS_SUCCESSFUL;
  rtems_chain_control chain;
  rtems_chain_node a;
  rtems_chain_node b;
  rtems_chain_node *p = (rtems_chain_node *) 1;
  rtems_event_set out = 0;

  puts( "INIT - Verify rtems_chain_append_with_notification" );
  rtems_chain_initialize_empty( &chain );
  sc = rtems_chain_append_with_notification(
    &chain,
    &a,
    rtems_task_self(),
    EVENT
  );
  rtems_test_assert( sc == RTEMS_SUCCESSFUL );
  sc = rtems_chain_get_with_wait( &chain, EVENT, TIMEOUT, &p );
  rtems_test_assert( sc == RTEMS_SUCCESSFUL );
  rtems_test_assert( p == &a );

  rtems_chain_initialize_empty( &chain );

  rtems_chain_append( &chain, &b );
  sc = rtems_chain_append_with_notification(
    &chain,
    &a,
    rtems_task_self(),
    EVENT
  );
  rtems_test_assert( sc == RTEMS_SUCCESSFUL );
  rtems_test_assert( p == &a );

  puts( "INIT - Verify rtems_chain_prepend_with_notification" );
  rtems_chain_initialize_empty( &chain );
  sc = rtems_chain_prepend_with_notification(
    &chain,
    &a,
    rtems_task_self(),
    EVENT
  );
  rtems_test_assert( sc == RTEMS_SUCCESSFUL );
  sc = rtems_chain_get_with_wait( &chain, EVENT, TIMEOUT, &p );
  rtems_test_assert( sc == RTEMS_SUCCESSFUL );
  rtems_test_assert( p == &a );

  rtems_chain_prepend( &chain, &b );
  sc = rtems_chain_prepend_with_notification(
    &chain,
    &a,
    rtems_task_self(),
    EVENT
  );
  rtems_test_assert( sc == RTEMS_SUCCESSFUL );
  rtems_test_assert( p == &a );

  puts( "INIT - Verify rtems_chain_prepend_with_notification" );
  puts( "INIT - Verify rtems_chain_get_with_notification" );
  rtems_chain_initialize_empty( &chain );

  rtems_chain_append( &chain, &b );
  rtems_chain_append( &chain, &a );

  sc = rtems_chain_get_with_notification(&chain, rtems_task_self(), EVENT, &p);
  rtems_test_assert( sc == RTEMS_SUCCESSFUL );
  rtems_test_assert( p == &b );

  sc = rtems_chain_get_with_notification(&chain, rtems_task_self(), EVENT, &p);
  rtems_test_assert( sc == RTEMS_SUCCESSFUL );
  rtems_test_assert( p == &a );
  sc = rtems_event_receive(
    EVENT,
    RTEMS_EVENT_ALL | RTEMS_WAIT,
    TIMEOUT,
    &out
  );
  rtems_test_assert( sc == RTEMS_SUCCESSFUL );
  rtems_test_assert( out == EVENT );
}
开发者ID:0871087123,项目名称:rtems,代码行数:80,代码来源:init.c

示例6: area_compare

static void area_compare(const long *area_a, const long *area_b, bool equal)
{
  bool actual_equal = memcmp(area_a, area_b, AREA_SIZE) == 0;
  rtems_test_assert(actual_equal == equal);
}
开发者ID:medivhc,项目名称:rtems,代码行数:5,代码来源:init.c

示例7: test

static void test(void)
{
  rtems_status_code   sc;
  uint32_t            cpu_count;
  int                 cpu;
  int                 i;
  cpu_set_t           cpuset;

  /* Get the number of processors that we are using. */
  cpu_count = rtems_get_processor_count();
  if (cpu_count < 2) {
    printf("Error: Test requires at least 2 cpus\n");
    return;
  }

  printf("Create Semaphore\n");
  sc = rtems_semaphore_create(  
    rtems_build_name('S', 'E', 'M', '0'),
    1,                                               /* initial count = 1 */
    RTEMS_LOCAL                   |
    RTEMS_SIMPLE_BINARY_SEMAPHORE |
    RTEMS_NO_INHERIT_PRIORITY     |
    RTEMS_NO_PRIORITY_CEILING     |
    RTEMS_FIFO,
    0,
    &task_sem
  );  
  rtems_test_assert(sc == RTEMS_SUCCESSFUL);

  /*
   * Create and start TA1 at a higher priority
   * than the init task. 
   */
  sc = rtems_task_create(
    rtems_build_name('T', 'A', '0', '1'),
    4,
    RTEMS_MINIMUM_STACK_SIZE,
    RTEMS_DEFAULT_MODES,
    RTEMS_DEFAULT_ATTRIBUTES,
    &task_data.id
  );
  rtems_test_assert(sc == RTEMS_SUCCESSFUL);

  printf("Start TA1\n");
  sc = rtems_task_start( task_data.id, task, 0 );
  rtems_test_assert(sc == RTEMS_SUCCESSFUL);

  /* 
   * Verify the Init task is running on the max core.
   */ 
  printf("Verify Init task is on cpu %ld\n",cpu_count-1);
  cpu = rtems_get_current_processor();
  rtems_test_assert(cpu == (cpu_count-1));

  /* Walk TA1 across all of the cores */
  for(i=0; i < cpu_count; i++) {
    /* Set the Affinity to core i */
    CPU_ZERO(&cpuset);
    CPU_SET(i, &cpuset);
    printf("Set Affinity TA1 to cpu %d\n", i);
    sc = rtems_task_set_affinity( task_data.id, sizeof(cpuset), &cpuset );
    rtems_test_assert(sc == RTEMS_SUCCESSFUL);

    /* Wait a bit to be sure it has switched cores then clear the task data */
    test_delay(50);
    while( rtems_semaphore_obtain (task_sem, RTEMS_NO_WAIT, 0) != RTEMS_SUCCESSFUL );
    task_data.ran = false;
    task_data.expected_cpu = i;
    rtems_semaphore_release(task_sem);
    test_delay(50);

    /* Verify the task ran on core i */
    while( rtems_semaphore_obtain (task_sem, RTEMS_NO_WAIT, 0) != RTEMS_SUCCESSFUL );
    if (task_data.ran != true)
      printf("Error: TA01 never ran.\n");
    else
      printf(
        "TA1 expected cpu: %d actual cpu %d\n", 
        task_data.expected_cpu,
        task_data.actual_cpu
      );
    rtems_test_assert(task_data.ran == true);
    rtems_test_assert(task_data.expected_cpu == task_data.actual_cpu);
    rtems_semaphore_release(task_sem);
  }
}
开发者ID:heshamelmatary,项目名称:rtems-gsoc2014,代码行数:86,代码来源:init.c

示例8: main

int main(){
  struct sigaction act;
  pthread_t        newThread;
  pthread_t        mainThread;
  int              status;
  int              i;

  status = sem_init(&GC_suspend_ack_sem, 0, 0);
  rtems_test_assert( status == 0 );

  status = sigemptyset(&act.sa_mask);
  rtems_test_assert( status == 0 );

  status = sigaddset(&act.sa_mask,SIG_SUSPEND);
  rtems_test_assert( status == 0 );

  status = sigaddset(&act.sa_mask,SIG_THR_RESTART);
  rtems_test_assert( status == 0 );

  status = pthread_sigmask(SIG_UNBLOCK,&act.sa_mask,NULL);
  rtems_test_assert( status == 0 );

  act.sa_handler=GC_suspend_handler;

  status = sigaction(SIG_SUSPEND,&act,NULL);
  rtems_test_assert( status == 0 );

  act.sa_handler=GC_restart_handler;

  status = sigaction(SIG_THR_RESTART,&act,NULL);
  rtems_test_assert( status == 0 );

  status = sigfillset(&suspend_handler_mask);
  rtems_test_assert( status == 0 );

  status = sigdelset(&suspend_handler_mask, SIG_THR_RESTART);
  rtems_test_assert( status == 0 );

  mainThread = pthread_self();
  status = pthread_create(&newThread,NULL,thread1,NULL);
  rtems_test_assert( status == 0 );

  GC_threads[0] = mainThread;
  GC_threads[1] = newThread;

  for(i=0; i<5; i++){
    printf("%d\n",i);
    status = sleep(1);
    printf("sleep returned %d/%s\n", status, strerror(errno) );
  }

  status = pthread_join( newThread, NULL );
  if(status) printf("MainThread pthread_join return %d\n", status);
  rtems_test_assert( status == 0 );

  printf( "Back from MainThread pthread_join times: %d\n", times );
  puts( "*** END OF TEST ***" );
  return 0;
}
开发者ID:lj8175,项目名称:practice,代码行数:59,代码来源:pthreadsignal.c

示例9: test_gid

void test_gid(void)
{
  gid_t gid;
  int sc;

  gid = getegid();
  rtems_test_assert( gid == 0 );
  printf( "getegid = %d\n", gid );

  gid = getgid();
  rtems_test_assert( gid == 0 );
  printf( "getgid = %d\n", gid );

  puts( "setgid(5)" );
  sc = setgid(5);
  rtems_test_assert( sc == 0 );

  gid = getegid();
  rtems_test_assert( gid == 0 );
  printf( "getegid = %d\n", gid );

  gid = getgid();
  rtems_test_assert( gid == 5 );
  printf( "getgid = %d\n", gid );

  puts( "setegid(5)" );
  sc = setegid(5);
  rtems_test_assert( sc == 0 );

  gid = getegid();
  rtems_test_assert( gid == 5 );
  printf( "getegid = %d\n", gid );

  gid = getgid();
  rtems_test_assert( gid == 5 );
  printf( "getgid = %d\n", gid );

  puts( "setgid(0)" );
  sc = setgid(0);
  rtems_test_assert( sc == 0 );

  puts( "setegid(0)" );
  sc = setegid(0);
  rtems_test_assert( sc == 0 );

  errno = 0;
  puts( "setpgid(getpid(), 10) - ENOSYS" );
  sc = setpgid( getpid(), 10 );
  rtems_test_assert( sc == -1 );
  rtems_test_assert( errno == ENOSYS );
}
开发者ID:AlexShiLucky,项目名称:rtems,代码行数:51,代码来源:init.c

示例10: validate_task

static void validate_task(rtems_task_argument arg)
{
  _CPU_Context_validate(arg);
  rtems_test_assert(0);
}
开发者ID:AlexShiLucky,项目名称:rtems,代码行数:5,代码来源:init.c

示例11: Init

rtems_task Init(rtems_task_argument arg)
{
  rtems_status_code  status;
  int                sc;
  uintptr_t          max_free_size = 13 * RTEMS_MINIMUM_STACK_SIZE;
  void              *greedy;

  all_thread_created = 0;

  TEST_BEGIN();

  puts( "Init - Semaphore 1 create - OK" );
  name1 = rtems_build_name('S', 'E', 'M', '1');
  sc = rtems_semaphore_create(
    name1, 0,
    RTEMS_SIMPLE_BINARY_SEMAPHORE | RTEMS_FIFO,
    0,
    &sema1
  );
  rtems_test_assert( sc == RTEMS_SUCCESSFUL );

  puts( "Init - Semaphore 2 create - OK" );
  name2 = rtems_build_name('S', 'E', 'M', '2');
  sc = rtems_semaphore_create(
    name2,
    0,
    RTEMS_SIMPLE_BINARY_SEMAPHORE | RTEMS_FIFO,
    0,
    &sema2
  );
  rtems_test_assert( sc == RTEMS_SUCCESSFUL );

  puts( "Init - pthread Key create - OK" );
  sc = pthread_key_create( &Key, NULL );
  rtems_test_assert( !sc );

  /* Reduce workspace size if necessary to shorten test time */
  greedy = rtems_workspace_greedy_allocate( &max_free_size, 1 );

  for ( ; ; ) {
    rtems_id task_id;

    sc = rtems_task_create(
      rtems_build_name('T','A',created_task_count, ' '),
      1,
      RTEMS_MINIMUM_STACK_SIZE,
      RTEMS_DEFAULT_MODES,
      RTEMS_DEFAULT_ATTRIBUTES,
      &task_id
    );
    rtems_test_assert(
      (sc == RTEMS_UNSATISFIED) ||
      (sc == RTEMS_TOO_MANY) ||
      (sc == RTEMS_SUCCESSFUL)
    );

    /**
     * when return is RTEMS_TOO_MANY or RTEMS_UNSATISFIED, there is not
     * enough source to create task.
     */
    if ( (sc == RTEMS_TOO_MANY) || (sc == RTEMS_UNSATISFIED) ) {
      break;
    }
    ++created_task_count;

    sc = rtems_task_start( task_id,  test_task, 0 );
    rtems_test_assert( sc == RTEMS_SUCCESSFUL );

    sc = rtems_semaphore_obtain( sema1, RTEMS_WAIT, 0 );
    rtems_test_assert( sc == RTEMS_SUCCESSFUL );
  }

  rtems_workspace_greedy_free( greedy );

  printf(
    "Init - %d tasks have been created - OK\n"
    "Init - %d tasks have been setted key data - OK\n",
    setted_task_count,
    created_task_count
  );
  rtems_test_assert( created_task_count == setted_task_count );

  /* unblock all created tasks to let them set key data.*/
  puts( "Init - flush semaphore 2 - OK" );
  sc = rtems_semaphore_flush( sema2 );
  rtems_test_assert( sc == RTEMS_SUCCESSFUL );

  puts( "Init - sleep to yield processor - OK" );
  status = rtems_task_wake_after( RTEMS_YIELD_PROCESSOR );
  directive_failed( status, "rtems_task_wake_after" );

  printf( "Init - %d Tasks have been got key data - OK\n", got_task_count );
  rtems_test_assert( created_task_count == got_task_count );
  puts( "Init - pthread Key delete - OK" );
  sc = pthread_key_delete( Key );
  rtems_test_assert( sc == 0 );

  puts( "Init - semaphore 1 delete - OK" );
  sc = rtems_semaphore_delete( sema1 );
  rtems_test_assert( !sc );
//.........这里部分代码省略.........
开发者ID:AlexShiLucky,项目名称:rtems,代码行数:101,代码来源:init.c

示例12: mmap_bad_arguments

static void mmap_bad_arguments( void )
{
  int devfd, pagesize, shmfd, zerofd;
  void* p;

  rtems_test_assert((pagesize = getpagesize()) > 0);
  rtems_test_assert((devfd = open(&test_driver_name[0], O_RDONLY)) >= 0);
  rtems_test_assert((shmfd = shm_open("/shm", O_CREAT | O_RDWR, 0644)) >= 0);
  rtems_test_assert(ftruncate(shmfd, pagesize) == 0);
  rtems_test_assert((zerofd = open("/dev/zero", O_RDONLY)) >= 0);

  /*
   * These should normally work on FREEBSD. Test cases below that fail are
   * due to unsupported features in RTEMS.
   */
  checked_mmap(PROT_READ | PROT_WRITE, MAP_ANON, -1, 0,
      "simple MAP_ANON");
  checked_mmap(PROT_READ | PROT_WRITE, MAP_SHARED, shmfd, 0,
      "simple shm fd shared");
  checked_mmap(PROT_READ | PROT_WRITE, MAP_PRIVATE, shmfd, 0,
      "simple shm fd private");
  /* RTEMS cannot protect against writes so this will fail */
  checked_mmap(PROT_READ, MAP_SHARED, zerofd, ENOTSUP,
      "simple /dev/zero shared");
   /*
    * Repeat with no write protection. Will fail because of unimplemented
    * mmap handler in /dev/zero.
    */
  checked_mmap(PROT_READ | PROT_WRITE, MAP_SHARED, zerofd, ENOTSUP,
      "simple /dev/zero shared");
  /* RTEMS /dev/zero is a character device so this will fail */
  checked_mmap(PROT_READ | PROT_WRITE, MAP_PRIVATE, zerofd, EINVAL,
      "simple /dev/zero private");
  /* RTEMS cannot protect against writes so this will fail */
  checked_mmap(PROT_READ, MAP_SHARED, devfd, ENOTSUP,
      "simple test driver shared");
   /*
    * Repeat with no write protection. Should fail because of unimplemented
    * mmap handler in /dev/null.
    */
  p = checked_mmap(PROT_READ | PROT_WRITE, MAP_SHARED, devfd, 0,
      "simple test driver shared");
  rtems_test_assert(p == &test_data[0]);

  /* Extra PROT flags. */
  checked_mmap(PROT_READ | PROT_WRITE | 0x100000, MAP_ANON, -1, EINVAL,
      "MAP_ANON with extra PROT flags");
  checked_mmap(0xffff, MAP_SHARED, shmfd, EINVAL,
      "shm fd with garbage PROT");

  /* Undefined flag. */
  checked_mmap(PROT_READ | PROT_WRITE, MAP_ANON | MAP_RESERVED0080, -1,
      EINVAL, "Undefined flag");

  /* Both MAP_SHARED and MAP_PRIVATE */
  checked_mmap(PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE |
      MAP_SHARED, -1, EINVAL, "MAP_ANON with both SHARED and PRIVATE");
  checked_mmap(PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_SHARED, shmfd,
      EINVAL, "shm fd with both SHARED and PRIVATE");

  /* At least one of MAP_SHARED or MAP_PRIVATE without ANON */
  checked_mmap(PROT_READ | PROT_WRITE, 0, shmfd, EINVAL,
      "shm fd without sharing flag");

  /* MAP_ANON with sharing flag. Will fail on RTEMS*/
  checked_mmap(PROT_READ | PROT_WRITE, MAP_ANON | MAP_SHARED, -1, EINVAL,
      "shared MAP_ANON");
  /* MAP_ANON with private flag*/
  checked_mmap(PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0,
      "private MAP_ANON");

  /* MAP_ANON should require an fd of -1. */
  checked_mmap(PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, 0, EINVAL,
      "MAP_ANON with fd != -1");

  /*
   * Writable MAP_SHARED should fail on read-only descriptors. Will fail
   * on RTEMS because of unimplemented mmap handler in /dev/null and the fact
   * that there is no read only protection.
   */
  checked_mmap(PROT_READ | PROT_WRITE, MAP_SHARED, zerofd, ENOTSUP,
      "MAP_SHARED of read-only /dev/zero");

  /*
   * Character devices other than /dev/zero do not support private
   * mappings. RTEMS cannot protect against writes so this will fail with
   * ENOTSUP
   */
  checked_mmap(PROT_READ, MAP_PRIVATE, devfd, ENOTSUP,
      "MAP_PRIVATE of test driver");

   /*
    * Repeat with no write protection.
    */
  checked_mmap(PROT_READ | PROT_WRITE, MAP_PRIVATE, devfd, EINVAL,
      "MAP_PRIVATE of test driver");

  close(devfd);
  close(shmfd);
  close(zerofd);
//.........这里部分代码省略.........
开发者ID:gedare,项目名称:rtems,代码行数:101,代码来源:init.c

示例13: Init

rtems_task Init(
  rtems_task_argument argument
)
{
  struct timespec tv;
  struct timespec tr;
  int             sc;
  time_t          seconds;
  time_t          seconds1;
  unsigned int    remaining;
  struct tm       tm;
  struct timespec delay_request;

  puts( "\n\n*** POSIX CLOCK TEST ***" );

  tm_build_time( &tm, TM_FRIDAY, TM_MAY, 24, 96, 11, 5, 0 );

  /* error cases in clock_gettime and clock_settime */

  puts( "Init: clock_gettime - EINVAL (NULL timespec)" );
  sc = clock_gettime( CLOCK_REALTIME, NULL );
  rtems_test_assert( sc == -1 );
  rtems_test_assert( errno == EINVAL );

  puts( "Init: clock_gettime - EINVAL (invalid clockid)" );
  sc = clock_gettime( (clockid_t)-1, &tv );
  rtems_test_assert( sc == -1 );
  rtems_test_assert( errno == EINVAL );

  puts( "Init: clock_settime - EINVAL (invalid clockid)" );
  sc = clock_settime( (clockid_t)-1, &tv );
  rtems_test_assert( sc == -1 );
  rtems_test_assert( errno == EINVAL );

  /* way back near the dawn of time :D */
  tv.tv_sec = 1;
  tv.tv_nsec = 0;
  printf( ctime( &tv.tv_sec ) );
  puts( "Init: clock_settime - before 1988 EINVAL" );
  sc = clock_settime( CLOCK_REALTIME, &tv );
  rtems_test_assert( sc == -1 );
  rtems_test_assert( errno == EINVAL );

  /* exercise clock_getres */

  puts( "Init: clock_getres - EINVAL (invalid clockid)" );
  sc = clock_getres( (clockid_t) -1, &tv );
  rtems_test_assert( sc == -1 );
  rtems_test_assert( errno == EINVAL );

  puts( "Init: clock_getres - EINVAL (NULL resolution)" );
  sc = clock_getres( CLOCK_REALTIME, NULL );
  rtems_test_assert( sc == -1 );
  rtems_test_assert( errno == EINVAL );

  puts( "Init: clock_getres - SUCCESSFUL" );
  sc = clock_getres( CLOCK_REALTIME, &tv );
  printf( "Init: resolution = sec (%" PRIdtime_t "), nsec (%ld)\n", tv.tv_sec, tv.tv_nsec );
  rtems_test_assert( !sc );

  /* set the time of day, and print our buffer in multiple ways */

  tv.tv_sec = mktime( &tm );
  rtems_test_assert( tv.tv_sec != -1 );

  tv.tv_nsec = 0;

  /* now set the time of day */

  empty_line();

  printf( asctime( &tm ) );
  puts( "Init: clock_settime - SUCCESSFUL" );
  sc = clock_settime( CLOCK_REALTIME, &tv );
  rtems_test_assert( !sc );

  printf( asctime( &tm ) );
  printf( ctime( &tv.tv_sec ) );

  /* use sleep to delay */

  remaining = sleep( 3 );
  rtems_test_assert( !remaining );

  /* print new times to make sure it has changed and we can get the realtime */
  sc = clock_gettime( CLOCK_PROCESS_CPUTIME_ID, &tv );
  rtems_test_assert( !sc );
  printf("Time since boot: (%" PRIdtime_t ", %ld)\n", tv.tv_sec,tv.tv_nsec );

  sc = clock_gettime( CLOCK_REALTIME, &tv );
  rtems_test_assert( !sc );

  printf( ctime( &tv.tv_sec ) );

  seconds = time( NULL );
  printf( ctime( &seconds ) );

  /*  just to have the value copied out through the parameter */

  seconds = time( &seconds1 );
//.........这里部分代码省略.........
开发者ID:chch1028,项目名称:rtems,代码行数:101,代码来源:init.c

示例14: suspend

static void suspend(size_t i)
{
  rtems_status_code sc = rtems_task_suspend(task_ids[i]);
  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
}
开发者ID:chch1028,项目名称:rtems,代码行数:5,代码来源:init.c

示例15: test_chain_control_initializer

static void test_chain_control_initializer(void)
{
  rtems_chain_control chain = RTEMS_CHAIN_INITIALIZER_EMPTY( chain );
  puts( "INIT - Verify rtems_chain_control initializer" );
  rtems_test_assert( rtems_chain_is_empty( &chain ) );
}
开发者ID:0871087123,项目名称:rtems,代码行数:6,代码来源:init.c


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