Changeset c005d41 in rtems


Ignore:
Timestamp:
Aug 6, 2009, 7:24:38 PM (10 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, master
Children:
288f8498
Parents:
0d214a7c
Message:

2009-08-06 Joel Sherrill <joel.sherrill@…>

  • psxmsgq04/init.c, psxmsgq04/psxmsgq04.scn: Tinker with test to ensure that it hits both failing to allocate memory for the message queue name and message buffers.
Location:
testsuites/psxtests
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • testsuites/psxtests/ChangeLog

    r0d214a7c rc005d41  
     12009-08-06      Joel Sherrill <joel.sherrill@OARcorp.com>
     2
     3        * psxmsgq04/init.c, psxmsgq04/psxmsgq04.scn: Tinker with test to ensure
     4        that it hits both failing to allocate memory for the message queue
     5        name and message buffers.
     6
    172009-08-06      Joel Sherrill <joel.sherrill@OARcorp.com>
    28
  • testsuites/psxtests/psxmsgq04/init.c

    r0d214a7c rc005d41  
    2828  mqd_t                   Queue, second_Queue;
    2929  int                     sc;
     30  Heap_Information_block  start;
    3031  Heap_Information_block  info;
     32  size_t                  to_alloc;
     33  void                   *alloced;
    3134  bool                    sb;
     35  const char             *name;
    3236
    3337  puts( "\n\n*** POSIX MESSAGE QUEUE TEST 4 ***" );
     
    6165  assert( sc == 0 );
    6266
     67  sb = rtems_workspace_get_information( &start );
     68  assert( start.Free.number == 1 );
     69  to_alloc = start.Free.largest;
     70
     71  /* find the largest we can actually allocate */
     72  while ( 1 ) {
     73    sb = rtems_workspace_allocate( to_alloc, &alloced );
     74    if ( sb )
     75      break;
     76    to_alloc -= 4;
     77  }
     78
     79  rtems_workspace_free( alloced );
     80
     81  /*
     82   * Now do the test
     83   */
    6384  puts( "Init - Memory allocation error test" );
    6485
    6586  sb = rtems_workspace_get_information( &info );
    6687
    67   attr.mq_msgsize = info.Free.largest;
     88  attr.mq_maxmsg = 1;
     89  attr.mq_msgsize = 200;
    6890
     91  name = Get_Longest_Name();
    6992  while ( attr.mq_msgsize > 0 ) {
    70     second_Queue = mq_open("second_queue",O_CREAT | O_RDWR, 0x777, &attr );
    71     if ( second_Queue!=(-1) )
     93    sb = rtems_workspace_allocate( to_alloc, &alloced );
     94    assert( sb );
     95   
     96    second_Queue = mq_open(name,O_CREAT | O_RDWR, 0x777, &attr );
     97
     98    /* free the memory we snagged, then check the status */
     99    rtems_workspace_free( alloced );
     100
     101    if ( second_Queue != (-1) )
    72102      break;
    73     attr.mq_msgsize -= 48;
     103
     104    /* attr.mq_msgsize -= 48; */
     105    to_alloc -= 4;
    74106  }
    75107
    76   if ( second_Queue == (-1) ) {
    77     perror( "mq_open failed" );
    78     assert( second_Queue != (-1) );
    79   }
     108  if ( second_Queue == -1 )
     109    rtems_test_exit(0);
    80110
    81111  puts( "Init - Message Queue created" );
     112
    82113  puts( "Init - Unlink message queue" );
    83     sc = mq_unlink( "second_queue" );
     114    sc = mq_unlink( name );
    84115    if ( sc != 0 )
    85116      perror( "mq_unlink failed" );
    86     assert( sc==0 );
     117    assert( sc == 0 );
    87118
    88119  puts( "Init - Close message queue" );
    89120    sc = mq_close( second_Queue );
    90     if ( sc !=0 )
     121    if ( sc != 0 )
    91122      perror( "mq_close failed" );
    92123    assert( sc == 0 );
     124
    93125  puts( "*** END OF POSIX MESSAGE QUEUE TEST 4 ***" );
    94126  rtems_test_exit( 0 );
     
    104136#define CONFIGURE_POSIX_INIT_THREAD_TABLE
    105137
     138/* account for message buffers and string names */
     139#define CONFIGURE_MESSAGE_BUFFER_MEMORY \
     140    CONFIGURE_MESSAGE_BUFFERS_FOR_QUEUE(1, sizeof(int))
     141
    106142#define CONFIGURE_MAXIMUM_POSIX_THREADS                   1
    107143#define CONFIGURE_MAXIMUM_POSIX_MESSAGE_QUEUES            1
     
    112148#define CONFIGURE_INIT
    113149#include <rtems/confdefs.h>
    114 /* end of include file */
  • testsuites/psxtests/psxmsgq04/psxmsgq04.scn

    r0d214a7c rc005d41  
    11*** POSIX MESSAGE QUEUE TEST 4 ***
    2 Init - Open message queue
     2Init - Open message queue instance 1
    33Init - Open message queue instance 2 - FAIL - ENFILE
    4 Init - Unlink message queue
    5 Init - Close message queue
     4Init - Unlink message queue instance 1
     5Init - Close message queue instance 1
    66Init - Memory allocation error test
    77Init - Message Queue created
Note: See TracChangeset for help on using the changeset viewer.