Changeset 73699608 in rtems


Ignore:
Timestamp:
Dec 13, 2011, 10:02:36 AM (7 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
4.11, master
Children:
06a8139
Parents:
849d4bbc
Message:

2011-12-13 Sebastian Huber <sebastian.huber@…>

  • psxconfig01/init.c: Create more objects.
Location:
testsuites/psxtests
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • testsuites/psxtests/ChangeLog

    r849d4bbc r73699608  
     12011-12-13      Sebastian Huber <sebastian.huber@embedded-brains.de>
     2
     3        * psxconfig01/init.c: Create more objects.
     4
    152011-12-13      Ralf Corsépius <ralf.corsepius@rtems.org>
    26
  • testsuites/psxtests/psxconfig01/init.c

    r849d4bbc r73699608  
    3131#include <sys/stat.h>
    3232#include <fcntl.h>
     33#include <inttypes.h>
     34#include <mqueue.h>
    3335#include <pthread.h>
     36#include <semaphore.h>
     37#include <signal.h>
    3438#include <stdio.h>
    35 #include <inttypes.h>
    36 
    37 #define MQ_0_COUNT 2
    38 #define MQ_1_COUNT 3
    39 #define MQ_2_COUNT 5
    40 #define MQ_3_COUNT 7
    41 #define MQ_4_COUNT 11
    42 #define MQ_5_COUNT 13
    43 #define MQ_6_COUNT 17
    44 
    45 #define MQ_0_SIZE 101
    46 #define MQ_1_SIZE 103
    47 #define MQ_2_SIZE 107
    48 #define MQ_3_SIZE 109
    49 #define MQ_4_SIZE 113
    50 #define MQ_5_SIZE 127
    51 #define MQ_6_SIZE 131
    52 
    53 #define CONFIGURE_MESSAGE_BUFFER_MEMORY \
    54   CONFIGURE_MESSAGE_BUFFERS_FOR_QUEUE(MQ_0_COUNT, MQ_0_SIZE) \
    55     + CONFIGURE_MESSAGE_BUFFERS_FOR_QUEUE(MQ_1_COUNT, MQ_1_SIZE) \
    56     + CONFIGURE_MESSAGE_BUFFERS_FOR_QUEUE(MQ_2_COUNT, MQ_2_SIZE) \
    57     + CONFIGURE_MESSAGE_BUFFERS_FOR_QUEUE(MQ_3_COUNT, MQ_3_SIZE) \
    58     + CONFIGURE_MESSAGE_BUFFERS_FOR_QUEUE(MQ_4_COUNT, MQ_4_SIZE) \
    59     + CONFIGURE_MESSAGE_BUFFERS_FOR_QUEUE(MQ_5_COUNT, MQ_5_SIZE) \
    60     + CONFIGURE_MESSAGE_BUFFERS_FOR_QUEUE(MQ_6_COUNT, MQ_6_SIZE)
    61 
    62 #define CONFIGURE_MAXIMUM_USER_EXTENSIONS 17
    63 
    64 #define CONFIGURE_MAXIMUM_BARRIERS 31
    65 #define CONFIGURE_MAXIMUM_MESSAGE_QUEUES 7
     39#include <time.h>
     40
     41#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 5
     42
    6643#define CONFIGURE_MAXIMUM_PARTITIONS 37
    6744#define CONFIGURE_MAXIMUM_PERIODS 41
     
    7148#define CONFIGURE_MAXIMUM_TASK_VARIABLES 13
    7249#define CONFIGURE_MAXIMUM_TIMERS 59
    73 
     50#define CONFIGURE_MAXIMUM_USER_EXTENSIONS 17
     51
     52#define CONFIGURE_MAXIMUM_POSIX_BARRIERS 31
    7453#define CONFIGURE_MAXIMUM_POSIX_CONDITION_VARIABLES 29
    7554#define CONFIGURE_MAXIMUM_POSIX_KEYS 23
     55#define POSIX_MQ_COUNT 5
    7656#define CONFIGURE_MAXIMUM_POSIX_MUTEXES 19
     57#define CONFIGURE_MAXIMUM_POSIX_QUEUED_SIGNALS 7
     58#define CONFIGURE_MAXIMUM_POSIX_RWLOCKS 31
     59#define CONFIGURE_MAXIMUM_POSIX_SEMAPHORES 41
     60#define CONFIGURE_MAXIMUM_POSIX_SPINLOCKS 17
    7761#define CONFIGURE_MAXIMUM_POSIX_THREADS 3
    78 
    79 static const uint8_t mq_counts [CONFIGURE_MAXIMUM_MESSAGE_QUEUES] = {
    80   MQ_0_COUNT,
    81   MQ_1_COUNT,
    82   MQ_2_COUNT,
    83   MQ_3_COUNT,
    84   MQ_4_COUNT,
    85   MQ_5_COUNT,
    86   MQ_6_COUNT
    87 };
    88 
    89 static const uint8_t mq_sizes [CONFIGURE_MAXIMUM_MESSAGE_QUEUES] = {
    90   MQ_0_SIZE,
    91   MQ_1_SIZE,
    92   MQ_2_SIZE,
    93   MQ_3_SIZE,
    94   MQ_4_SIZE,
    95   MQ_5_SIZE,
    96   MQ_6_SIZE
    97 };
     62#define CONFIGURE_MAXIMUM_POSIX_TIMERS 47
     63
     64#ifndef CONFIGURE_MAXIMUM_TASKS
     65  #define CONFIGURE_MAXIMUM_TASKS 1
     66#endif
     67
     68#ifdef CONFIGURE_MAXIMUM_MESSAGE_QUEUES
     69  #define MQ_0_COUNT 2
     70  #define MQ_1_COUNT 3
     71  #define MQ_2_COUNT 5
     72  #define MQ_3_COUNT 7
     73  #define MQ_4_COUNT 11
     74  #define MQ_5_COUNT 13
     75  #define MQ_6_COUNT 17
     76
     77  #define MQ_0_SIZE 101
     78  #define MQ_1_SIZE 103
     79  #define MQ_2_SIZE 107
     80  #define MQ_3_SIZE 109
     81  #define MQ_4_SIZE 113
     82  #define MQ_5_SIZE 127
     83  #define MQ_6_SIZE 131
     84
     85  #define MQ_BUFFER_MEMORY \
     86    (CONFIGURE_MESSAGE_BUFFERS_FOR_QUEUE(MQ_0_COUNT, MQ_0_SIZE) \
     87      + CONFIGURE_MESSAGE_BUFFERS_FOR_QUEUE(MQ_1_COUNT, MQ_1_SIZE) \
     88      + CONFIGURE_MESSAGE_BUFFERS_FOR_QUEUE(MQ_2_COUNT, MQ_2_SIZE) \
     89      + CONFIGURE_MESSAGE_BUFFERS_FOR_QUEUE(MQ_3_COUNT, MQ_3_SIZE) \
     90      + CONFIGURE_MESSAGE_BUFFERS_FOR_QUEUE(MQ_4_COUNT, MQ_4_SIZE) \
     91      + CONFIGURE_MESSAGE_BUFFERS_FOR_QUEUE(MQ_5_COUNT, MQ_5_SIZE) \
     92      + CONFIGURE_MESSAGE_BUFFERS_FOR_QUEUE(MQ_6_COUNT, MQ_6_SIZE))
     93
     94  static const uint8_t mq_counts [CONFIGURE_MAXIMUM_MESSAGE_QUEUES] = {
     95    MQ_0_COUNT,
     96    MQ_1_COUNT,
     97    MQ_2_COUNT,
     98    MQ_3_COUNT,
     99    MQ_4_COUNT,
     100    MQ_5_COUNT,
     101    MQ_6_COUNT
     102  };
     103
     104  static const uint8_t mq_sizes [CONFIGURE_MAXIMUM_MESSAGE_QUEUES] = {
     105    MQ_0_SIZE,
     106    MQ_1_SIZE,
     107    MQ_2_SIZE,
     108    MQ_3_SIZE,
     109    MQ_4_SIZE,
     110    MQ_5_SIZE,
     111    MQ_6_SIZE
     112  };
     113#else
     114  #define MQ_BUFFER_MEMORY 0
     115#endif
     116
     117#ifdef POSIX_MQ_COUNT
     118  #define CONFIGURE_MAXIMUM_POSIX_MESSAGE_QUEUE_DESCRIPTORS POSIX_MQ_COUNT
     119  #define CONFIGURE_MAXIMUM_POSIX_MESSAGE_QUEUES POSIX_MQ_COUNT
     120
     121  #define POSIX_MQ_0_COUNT 2
     122  #define POSIX_MQ_1_COUNT 3
     123  #define POSIX_MQ_2_COUNT 5
     124  #define POSIX_MQ_3_COUNT 7
     125  #define POSIX_MQ_4_COUNT 11
     126
     127  #define POSIX_MQ_0_SIZE 137
     128  #define POSIX_MQ_1_SIZE 139
     129  #define POSIX_MQ_2_SIZE 149
     130  #define POSIX_MQ_3_SIZE 151
     131  #define POSIX_MQ_4_SIZE 157
     132
     133  #define POSIX_MQ_BUFFER_MEMORY \
     134    (CONFIGURE_MESSAGE_BUFFERS_FOR_QUEUE(POSIX_MQ_0_COUNT, POSIX_MQ_0_SIZE) \
     135      + CONFIGURE_MESSAGE_BUFFERS_FOR_QUEUE(POSIX_MQ_1_COUNT, POSIX_MQ_1_SIZE) \
     136      + CONFIGURE_MESSAGE_BUFFERS_FOR_QUEUE(POSIX_MQ_2_COUNT, POSIX_MQ_2_SIZE) \
     137      + CONFIGURE_MESSAGE_BUFFERS_FOR_QUEUE(POSIX_MQ_3_COUNT, POSIX_MQ_3_SIZE) \
     138      + CONFIGURE_MESSAGE_BUFFERS_FOR_QUEUE(POSIX_MQ_4_COUNT, POSIX_MQ_4_SIZE))
     139
     140  static const uint8_t posix_mq_counts [POSIX_MQ_COUNT] = {
     141    POSIX_MQ_0_COUNT,
     142    POSIX_MQ_1_COUNT,
     143    POSIX_MQ_2_COUNT,
     144    POSIX_MQ_3_COUNT,
     145    POSIX_MQ_4_COUNT
     146  };
     147
     148  static const uint8_t posix_mq_sizes [POSIX_MQ_COUNT] = {
     149    POSIX_MQ_0_SIZE,
     150    POSIX_MQ_1_SIZE,
     151    POSIX_MQ_2_SIZE,
     152    POSIX_MQ_3_SIZE,
     153    POSIX_MQ_4_SIZE
     154  };
     155#else
     156  #define POSIX_MQ_BUFFER_MEMORY 0
     157#endif
     158
     159#define CONFIGURE_MESSAGE_BUFFER_MEMORY \
     160  (MQ_BUFFER_MEMORY + POSIX_MQ_BUFFER_MEMORY)
    98161
    99162typedef struct {
     
    101164} area;
    102165
    103 static area partition_areas [CONFIGURE_MAXIMUM_PARTITIONS];
    104 
    105 static area region_areas [CONFIGURE_MAXIMUM_REGIONS];
     166#ifdef CONFIGURE_MAXIMUM_PARTITIONS
     167  static area partition_areas [CONFIGURE_MAXIMUM_PARTITIONS];
     168#endif
     169
     170#ifdef CONFIGURE_MAXIMUM_REGIONS
     171  static area region_areas [CONFIGURE_MAXIMUM_REGIONS];
     172#endif
     173
     174static char posix_name [NAME_MAX];
    106175
    107176static void *task_var;
     177
     178static char *get_posix_name(char a, char b, char c, int i)
     179{
     180  posix_name [NAME_MAX - 5] = a;
     181  posix_name [NAME_MAX - 4] = b;
     182  posix_name [NAME_MAX - 3] = c;
     183  posix_name [NAME_MAX - 2] = 'A' + i;
     184
     185  return posix_name;
     186}
    108187
    109188static void task_var_dtor(void *var __attribute__((unused)))
     
    144223}
    145224
    146 rtems_task Init(rtems_task_argument argument)
     225static rtems_task Init(rtems_task_argument argument)
    147226{
    148227  rtems_status_code sc = RTEMS_SUCCESSFUL;
     228  int eno = 0;
     229  int rv = 0;
    149230  rtems_id id = RTEMS_ID_NONE;
    150231  rtems_name name = rtems_build_name('C', 'O', 'N', 'F');
    151232  rtems_extensions_table table;
    152   int oflag = O_WRONLY | O_CREAT | O_TRUNC;
    153   mode_t mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH;
    154   int fd_a = open("/a", oflag, mode);
    155   int fd_b = open("/b", oflag, mode);
    156233  int i = 0;
    157   int eno = 0;
    158234
    159235  puts("\n\n*** POSIX TEST CONFIG 01 ***");
    160236
     237  memset(posix_name, 'P', sizeof(posix_name) - 1);
     238
    161239  print_info();
    162240
    163   rtems_test_assert(fd_a == 3);
    164   rtems_test_assert(fd_b == 4);
    165 
     241#ifdef CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS
     242  for (i = 3; i < CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS; ++i) {
     243    int oflag = O_WRONLY | O_CREAT | O_TRUNC;
     244    mode_t mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH;
     245    char path [] = { 'F', 'I', 'L', 'E', 'A' + i, '\0' };
     246    int fd = open(path, oflag, mode);
     247    rtems_test_assert(fd == i);
     248  }
     249#endif
     250
     251#ifdef CONFIGURE_MAXIMUM_USER_EXTENSIONS
    166252  memset(&table, 0, sizeof(table));
    167253  for (i = 0; i < CONFIGURE_MAXIMUM_USER_EXTENSIONS; ++i) {
     
    169255    directive_failed(sc, "rtems_extension_create");
    170256  }
    171 
     257#endif
     258
     259#ifdef CONFIGURE_MAXIMUM_BARRIERS
    172260  for (i = 0; i < CONFIGURE_MAXIMUM_BARRIERS; ++i) {
    173261    sc = rtems_barrier_create(name, RTEMS_DEFAULT_ATTRIBUTES, 1, &id);
    174262    directive_failed(sc, "rtems_barrier_create");
    175263  }
    176 
     264#endif
     265
     266#ifdef CONFIGURE_MAXIMUM_MESSAGE_QUEUES
    177267  for (i = 0; i < CONFIGURE_MAXIMUM_MESSAGE_QUEUES; ++i) {
    178268    sc = rtems_message_queue_create(
     
    185275    directive_failed(sc, "rtems_message_queue_create");
    186276  }
    187 
     277#endif
     278
     279#ifdef CONFIGURE_MAXIMUM_PARTITIONS
    188280  for (i = 0; i < CONFIGURE_MAXIMUM_PARTITIONS; ++i) {
    189281    sc = rtems_partition_create(
     
    197289    directive_failed(sc, "rtems_partition_create");
    198290  }
    199 
     291#endif
     292
     293#ifdef CONFIGURE_MAXIMUM_PERIODS
    200294  for (i = 0; i < CONFIGURE_MAXIMUM_PERIODS; ++i) {
    201295    sc = rtems_rate_monotonic_create(name, &id);
    202296    directive_failed(sc, "rtems_rate_monotonic_create");
    203297  }
    204 
     298#endif
     299
     300#ifdef CONFIGURE_MAXIMUM_REGIONS
    205301  for (i = 0; i < CONFIGURE_MAXIMUM_REGIONS; ++i) {
    206302    sc = rtems_region_create(
     
    214310    directive_failed(sc, "rtems_region_create");
    215311  }
    216 
     312#endif
     313
     314#ifdef CONFIGURE_MAXIMUM_SEMAPHORES
    217315  for (i = 0; i < CONFIGURE_MAXIMUM_SEMAPHORES; ++i) {
    218316    sc = rtems_semaphore_create(
     
    225323    directive_failed(sc, "rtems_semaphore_create");
    226324  }
    227 
    228   for (i = 0; i < CONFIGURE_MAXIMUM_TASKS - 1; ++i) {
     325#endif
     326
     327#ifdef CONFIGURE_MAXIMUM_TASKS
     328  for (i = 1; i < CONFIGURE_MAXIMUM_TASKS; ++i) {
    229329    sc = rtems_task_create(
    230330      name,
     
    237337    directive_failed(sc, "rtems_task_create");
    238338  }
    239 
     339#endif
     340
     341#ifdef CONFIGURE_MAXIMUM_TASK_VARIABLES
    240342  for (i = 0; i < CONFIGURE_MAXIMUM_TASK_VARIABLES; ++i) {
    241343    sc = rtems_task_variable_add(RTEMS_SELF, &task_var, task_var_dtor);
    242344    directive_failed(sc, "rtems_task_variable_add");
    243345  }
    244 
     346#endif
     347
     348#ifdef CONFIGURE_MAXIMUM_TIMERS
    245349  for (i = 0; i < CONFIGURE_MAXIMUM_TIMERS; ++i) {
    246350    sc = rtems_timer_create(name, &id);
    247351    directive_failed(sc, "rtems_timer_create");
    248352  }
    249 
     353#endif
     354
     355#ifdef CONFIGURE_MAXIMUM_POSIX_BARRIERS
     356  for (i = 0; i < CONFIGURE_MAXIMUM_POSIX_BARRIERS; ++i) {
     357    pthread_barrier_t barrier;
     358    eno = pthread_barrier_init(&barrier, NULL, 1);
     359    rtems_test_assert(eno == 0);
     360  }
     361#endif
     362
     363#ifdef CONFIGURE_MAXIMUM_POSIX_CONDITION_VARIABLES
    250364  for (i = 0; i < CONFIGURE_MAXIMUM_POSIX_CONDITION_VARIABLES; ++i) {
    251365    pthread_cond_t cond;
     
    253367    rtems_test_assert(eno == 0);
    254368  }
    255 
     369#endif
     370
     371#ifdef CONFIGURE_MAXIMUM_POSIX_KEYS
    256372  for (i = 0; i < CONFIGURE_MAXIMUM_POSIX_KEYS; ++i) {
    257373    pthread_key_t key;
     
    259375    rtems_test_assert(eno == 0);
    260376  }
    261 
     377#endif
     378
     379#ifdef POSIX_MQ_COUNT
     380  for (i = 0; i < POSIX_MQ_COUNT; ++i) {
     381    int oflag = O_RDWR | O_CREAT | O_EXCL;
     382    mode_t mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH;
     383    struct mq_attr attr = {
     384      .mq_maxmsg = posix_mq_counts [i],
     385      .mq_msgsize = posix_mq_sizes [i]
     386    };
     387    char *path = get_posix_name('M', 'S', 'Q', i);
     388    mqd_t mq = mq_open(path, oflag, mode, &attr);
     389    rtems_test_assert(mq >= 0);
     390  }
     391#endif
     392
     393#ifdef CONFIGURE_MAXIMUM_POSIX_MUTEXES
    262394  for (i = 0; i < CONFIGURE_MAXIMUM_POSIX_MUTEXES; ++i) {
    263395    pthread_mutex_t mutex;
     
    265397    rtems_test_assert(eno == 0);
    266398  }
    267 
     399#endif
     400
     401#ifdef CONFIGURE_MAXIMUM_POSIX_RWLOCKS
     402  for (i = 0; i < CONFIGURE_MAXIMUM_POSIX_RWLOCKS; ++i) {
     403    pthread_rwlock_t rwlock;
     404    eno = pthread_rwlock_init(&rwlock, NULL);
     405    rtems_test_assert(eno == 0);
     406  }
     407#endif
     408
     409#ifdef CONFIGURE_MAXIMUM_POSIX_SEMAPHORES
     410  for (i = 0; i < CONFIGURE_MAXIMUM_POSIX_SEMAPHORES; ++i) {
     411    int oflag = O_RDWR | O_CREAT | O_EXCL;
     412    mode_t mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH;
     413    unsigned int value = 0;
     414    char *path = get_posix_name('S', 'E', 'M', i);
     415    sem_t *sem = sem_open(path, oflag, mode, value);
     416    rtems_test_assert(sem != SEM_FAILED);
     417  }
     418#endif
     419
     420#ifdef CONFIGURE_MAXIMUM_POSIX_SPINLOCKS
     421  for (i = 0; i < CONFIGURE_MAXIMUM_POSIX_SPINLOCKS; ++i) {
     422    pthread_spinlock_t spinlock;
     423    eno = pthread_spin_init(&spinlock, 0);
     424    rtems_test_assert(eno == 0);
     425  }
     426#endif
     427
     428#ifdef CONFIGURE_MAXIMUM_POSIX_THREADS
    268429  for (i = 0; i < CONFIGURE_MAXIMUM_POSIX_THREADS; ++i) {
    269430    pthread_t thread;
     
    271432    rtems_test_assert(eno == 0);
    272433  }
     434#endif
     435
     436#ifdef CONFIGURE_MAXIMUM_POSIX_TIMERS
     437  for (i = 0; i < CONFIGURE_MAXIMUM_POSIX_TIMERS; ++i) {
     438    timer_t timer_id;
     439    rv = timer_create(CLOCK_REALTIME, NULL, &timer_id);
     440    rtems_test_assert(rv == 0);
     441  }
     442#endif
    273443
    274444  printf("object creation done\n");
     
    283453#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
    284454
    285 #define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 5
    286 
    287455#define CONFIGURE_MAXIMUM_DRIVERS 2
    288456
Note: See TracChangeset for help on using the changeset viewer.