Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:24:48

0001 /* SPDX-License-Identifier: BSD-2-Clause */
0002 
0003 /*
0004  *  COPYRIGHT (c) 2014.
0005  *  On-Line Applications Research Corporation (OAR).
0006  *
0007  * Redistribution and use in source and binary forms, with or without
0008  * modification, are permitted provided that the following conditions
0009  * are met:
0010  * 1. Redistributions of source code must retain the above copyright
0011  *    notice, this list of conditions and the following disclaimer.
0012  * 2. Redistributions in binary form must reproduce the above copyright
0013  *    notice, this list of conditions and the following disclaimer in the
0014  *    documentation and/or other materials provided with the distribution.
0015  *
0016  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
0017  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
0018  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
0019  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
0020  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
0021  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
0022  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
0023  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
0024  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
0025  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
0026  * POSSIBILITY OF SUCH DAMAGE.
0027  */
0028 
0029 #ifdef HAVE_CONFIG_H
0030 #include "config.h"
0031 #endif
0032 
0033 #define CONFIGURE_INIT
0034 #include "system.h"
0035 
0036 const char rtems_test_name[] = "SP MESSAGE QUEUE ERROR 2";
0037 
0038 rtems_task Init(
0039   rtems_task_argument argument
0040 )
0041 {
0042   long              buffer[ 4 ];
0043   rtems_status_code status;
0044 
0045   rtems_test_assert( MAX_MESSAGES == 2 );
0046   
0047   TEST_BEGIN();
0048   Queue_name[ 1 ]      =  rtems_build_name( 'M', 'Q', '1', ' ' );
0049   Task_name[ 3 ]       =  rtems_build_name( 'T', 'A', '3', ' ' );
0050  
0051   status = rtems_task_create(
0052     Task_name[ 3 ],
0053     1,
0054     RTEMS_MINIMUM_STACK_SIZE,
0055     RTEMS_DEFAULT_MODES,
0056     RTEMS_DEFAULT_ATTRIBUTES,
0057     &Task_id[ 3 ]
0058   );
0059   directive_failed( status, "rtems_task_create of TA3" );
0060   puts( "TA1 - rtems_task_create - TA3 created - RTEMS_SUCCESSFUL" );
0061   
0062   status = rtems_message_queue_create(
0063     Queue_name[ 1 ],
0064     MAX_MESSAGES,
0065     MESSAGE_SIZE,
0066     RTEMS_DEFAULT_ATTRIBUTES,
0067     &Queue_id[ 1 ]
0068   );
0069   directive_failed( status, "rtems_message_queue_create successful" );
0070   puts( "TA1 - rtems_message_queue_create - Q 1 - 2 DEEP - RTEMS_SUCCESSFUL" );
0071    
0072     status = rtems_message_queue_delete( Queue_id[ 1 ] );
0073   directive_failed( status, "rtems_message_queue_delete successful" );
0074   puts( "TA1 - rtems_message_queue_delete - Q 1 - RTEMS_SUCCESSFUL" );
0075 
0076   status = rtems_message_queue_create(
0077     Queue_name[ 1 ],
0078     MAX_MESSAGES,
0079     MESSAGE_SIZE,
0080     RTEMS_DEFAULT_ATTRIBUTES,
0081     &Queue_id[ 1 ]
0082   );
0083   directive_failed( status, "rtems_message_queue_create successful" );
0084   puts(
0085     "TA1 - rtems_message_queue_create - Q 1 - 2 DEEP - RTEMS_SUCCESSFUL"
0086   );
0087 
0088   status = rtems_message_queue_send( Queue_id[ 1 ], buffer, MESSAGE_SIZE );
0089   directive_failed( status, "rtems_message_queue_send successful" );
0090   puts( "TA1 - rtems_message_queue_send - BUFFER 1 TO Q 1 - RTEMS_SUCCESSFUL" );
0091 
0092   status = rtems_message_queue_send( Queue_id[ 1 ], buffer, MESSAGE_SIZE );
0093   directive_failed( status, "rtems_message_queue_send successful" );
0094   puts( "TA1 - rtems_message_queue_send - BUFFER 2 TO Q 1 - RTEMS_SUCCESSFUL" );
0095 
0096   status = rtems_message_queue_send( Queue_id[ 1 ], buffer, MESSAGE_SIZE );
0097   fatal_directive_status(
0098     status,
0099     RTEMS_TOO_MANY,
0100     "rtems_message_queue_send too many to limited queue"
0101   );
0102   puts( "TA1 - rtems_message_queue_send - BUFFER 3 TO Q 1 - RTEMS_TOO_MANY" );
0103 
0104   status = rtems_message_queue_delete( Queue_id[ 1 ] );
0105   directive_failed( status, "rtems_message_queue_delete successful" );
0106   puts( "TA1 - rtems_message_queue_delete - Q 1 - RTEMS_SUCCESSFUL" );
0107 
0108   status = rtems_message_queue_create(
0109     Queue_name[ 1 ],
0110     3,
0111     MESSAGE_SIZE,
0112     RTEMS_DEFAULT_ATTRIBUTES,
0113     &Queue_id[ 1 ]
0114   );
0115   directive_failed( status, "rtems_message_queue_create successful" );
0116   puts(
0117     "TA1 - rtems_message_queue_create - Q 1 - 3 DEEP - RTEMS_SUCCESSFUL"
0118   );
0119 
0120   status = rtems_message_queue_send( Queue_id[ 1 ], buffer, MESSAGE_SIZE );
0121   directive_failed( status, "rtems_message_queue_send successful" );
0122   puts( "TA1 - rtems_message_queue_send - BUFFER 1 TO Q 1 - RTEMS_SUCCESSFUL" );
0123 
0124   status = rtems_message_queue_send( Queue_id[ 1 ], buffer, MESSAGE_SIZE );
0125   directive_failed( status, "rtems_message_queue_send successful" );
0126   puts( "TA1 - rtems_message_queue_send - BUFFER 2 TO Q 1 - RTEMS_SUCCESSFUL" );
0127 
0128   status = rtems_message_queue_send( Queue_id[ 1 ], buffer, MESSAGE_SIZE );
0129   directive_failed( status, "rtems_message_queue_send successful" );
0130   puts( "TA1 - rtems_message_queue_send - BUFFER 3 TO Q 1 - RTEMS_SUCCESSFUL" );
0131 
0132   status = rtems_message_queue_send( Queue_id[ 1 ], buffer, MESSAGE_SIZE );
0133   fatal_directive_status(
0134     status,
0135     RTEMS_TOO_MANY,
0136     "rtems_message_queue_send too many to limited queue"
0137   );
0138   puts(
0139     "TA1 - rtems_message_queue_send - BUFFER 4 TO Q 1 - RTEMS_TOO_MANY"
0140   );
0141 
0142   status = rtems_message_queue_delete( Queue_id[ 1 ] );
0143   directive_failed( status, "rtems_message_queue_delete successful" );
0144   puts( "TA1 - rtems_message_queue_delete - Q 1 - RTEMS_SUCCESSFUL" );
0145 
0146   status = rtems_message_queue_create(
0147     Queue_name[ 1 ],
0148     3,
0149     MESSAGE_SIZE,
0150     RTEMS_DEFAULT_ATTRIBUTES,
0151     &Queue_id[ 1 ]
0152   );
0153   directive_failed( status, "rtems_message_queue_create successful" );
0154   puts(
0155     "TA1 - rtems_message_queue_create - Q 1 - 3 DEEP - RTEMS_SUCCESSFUL"
0156   );
0157 
0158   puts( "TA1 - rtems_task_start - start TA3 - RTEMS_SUCCESSFUL" );
0159   status = rtems_task_start( Task_id[ 3 ], Task_3, 0 );
0160   directive_failed( status, "rtems_task_start of TA3" );
0161 
0162   puts( "TA1 - rtems_task_wake_after - yield processor - RTEMS_SUCCESSFUL" );
0163   status = rtems_task_wake_after( RTEMS_YIELD_PROCESSOR );
0164   directive_failed( status, "rtems_task_wake_after (yield)" );
0165 
0166   puts( "TA1 - rtems_message_queue_delete - delete Q 1 - RTEMS_SUCCESSFUL" );
0167   status = rtems_message_queue_delete( Queue_id[ 1 ] );
0168   directive_failed( status, "rtems_message_queue_delete successful" );
0169 
0170   puts( "TA1 - rtems_task_wake_after - yield processor - RTEMS_SUCCESSFUL" );
0171   status = rtems_task_wake_after( RTEMS_YIELD_PROCESSOR );
0172   directive_failed( status, "rtems_task_wake_after (yield)" );
0173 
0174   TEST_END();
0175 }