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 PORT ERROR 01";
0037 
0038 rtems_task Init(
0039   rtems_task_argument argument
0040 )
0041 {
0042   void              *converted;
0043   rtems_status_code status;
0044   
0045   TEST_BEGIN();
0046   Port_name[ 1 ]       =  rtems_build_name( 'D', 'P', '1', ' ' );
0047   status = rtems_port_create(
0048      0,
0049      Internal_port_area,
0050      External_port_area,
0051      sizeof( Internal_port_area ),
0052      &Junk_id
0053   );
0054   fatal_directive_status(
0055     status,
0056     RTEMS_INVALID_NAME,
0057     "rtems_port_create with illegal name"
0058   );
0059   puts( "TA1 - rtems_port_create - RTEMS_INVALID_NAME" );
0060 
0061 #if defined(_C3x) || defined(_C4x)
0062   puts( "TA1 - rtems_port_create - RTEMS_INVALID_ADDRESS - SKIPPED" );
0063 #else
0064   status = rtems_port_create(
0065      Port_name[ 1 ],
0066      &((char *)Internal_port_area)[ 1 ],
0067      External_port_area,
0068      sizeof( Internal_port_area ),
0069      &Junk_id
0070   );
0071   fatal_directive_status(
0072     status,
0073     RTEMS_INVALID_ADDRESS,
0074     "rtems_port_create with illegal address"
0075   );
0076   puts( "TA1 - rtems_port_create - bad range - RTEMS_INVALID_ADDRESS" );
0077 #endif
0078 
0079   status = rtems_port_create(
0080      Port_name[ 1 ],
0081      Internal_port_area,
0082      External_port_area,
0083      sizeof( Internal_port_area ),
0084      NULL
0085   );
0086   fatal_directive_status(
0087     status,
0088     RTEMS_INVALID_ADDRESS,
0089     "rtems_port_create null Id"
0090   );
0091   puts( "TA1 - rtems_port_create - null id - RTEMS_INVALID_ADDRESS" );
0092 
0093   status = rtems_port_create(
0094      Port_name[ 1 ],
0095      Internal_port_area,
0096      External_port_area,
0097      sizeof( Internal_port_area ),
0098      &Junk_id
0099   );
0100   fatal_directive_status(
0101     status,
0102     RTEMS_TOO_MANY,
0103     "rtems_port_create of too many"
0104   );
0105   puts( "TA1 - rtems_port_create - RTEMS_TOO_MANY" );
0106 
0107   status = rtems_port_delete( 0 );
0108   fatal_directive_status(
0109     status,
0110     RTEMS_INVALID_ID,
0111     "rtems_port_delete with illegal id"
0112   );
0113   puts( "TA1 - rtems_port_delete - RTEMS_INVALID_ID" );
0114 
0115   status = rtems_port_ident( 0, &Junk_id );
0116   fatal_directive_status(
0117     status,
0118     RTEMS_INVALID_NAME,
0119     "rtems_port_ident with illegal name"
0120   );
0121   puts( "TA1 - rtems_port_ident - RTEMS_INVALID_NAME" );
0122 
0123   status = rtems_port_external_to_internal(
0124     100,
0125     Internal_port_area,
0126     &converted
0127   );
0128   fatal_directive_status(
0129     status,
0130     RTEMS_INVALID_ID,
0131     "rtems_port_external_to_internal with illegal id"
0132   );
0133 
0134   status = rtems_port_external_to_internal(
0135     100,
0136     Internal_port_area,
0137     NULL
0138   );
0139   fatal_directive_status(
0140     status,
0141     RTEMS_INVALID_ADDRESS,
0142     "rtems_port_external_to_internal with NULL param"
0143   );
0144   puts( "TA1 - rtems_port_external_to_internal - RTEMS_INVALID_ADDRESS" );
0145 
0146   status = rtems_port_internal_to_external(
0147     100,
0148     Internal_port_area,
0149     &converted
0150   );
0151   fatal_directive_status(
0152     status,
0153     RTEMS_INVALID_ID,
0154     "rtems_port_internal_to_external with illegal id"
0155   );
0156   puts( "TA1 - rtems_port_internal_to_external - RTEMS_INVALID_ID" );
0157 
0158   status = rtems_port_internal_to_external(
0159     100,
0160     Internal_port_area,
0161     NULL
0162   );
0163   fatal_directive_status(
0164     status,
0165     RTEMS_INVALID_ADDRESS,
0166     "rtems_port_internal_to_external with NULL param"
0167   );
0168   puts( "TA1 - rtems_port_external_to_internal - RTEMS_INVALID_ADDRESS" );
0169  
0170  TEST_END();
0171 }