Back to home page

LXR

 
 

    


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

0001 /* SPDX-License-Identifier: BSD-2-Clause */
0002 
0003 /*
0004  *  COPYRIGHT (c) 2013.
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 #include <tmacros.h>
0034 #include "test_support.h"
0035 
0036 const char rtems_test_name[] = "SPCLOCK_ERR 2";
0037 
0038 /* forward declaration to avoid warnings */
0039 rtems_task Init(rtems_task_argument argument);
0040 
0041 rtems_task Init(
0042   rtems_task_argument argument
0043 )
0044 {
0045   TEST_BEGIN();
0046 
0047   rtems_time_of_day time;
0048   rtems_status_code status;
0049 
0050   status = rtems_io_close( 0xffff, 0x0000, NULL);
0051   fatal_directive_status(
0052     status,
0053     RTEMS_INVALID_NUMBER,
0054     "rtems_io_close with bad major number"
0055   );
0056   puts( "TA1 - rtems_io_close - RTEMS_INVALID_NUMBER" );
0057   status = rtems_io_control( 0xffff, 0x00000, NULL);
0058   fatal_directive_status(
0059     status,
0060     RTEMS_INVALID_NUMBER,
0061     "rtems_io_close with bad major number"
0062   );
0063   puts( "TA1 - rtems_io_control - RTEMS_INVALID_NUMBER" );
0064   status = rtems_io_initialize( 0xffff, 0x00000, NULL);
0065   fatal_directive_status(
0066     status,
0067     RTEMS_INVALID_NUMBER,
0068     "rtems_io_initialize with bad major number"
0069   );
0070   puts( "TA1 - rtems_io_initialize - RTEMS_INVALID_NUMBER" );
0071   status = rtems_io_open( 0xffff, 0x00000, NULL);
0072   fatal_directive_status(
0073     status,
0074     RTEMS_INVALID_NUMBER,
0075     "rtems_io_open with bad major number"
0076   );
0077   puts( "TA1 - rtems_io_open - RTEMS_INVALID_NUMBER" );
0078   status = rtems_io_read( 0xffff, 0x00000, NULL);
0079   fatal_directive_status(
0080     status,
0081     RTEMS_INVALID_NUMBER,
0082     "rtems_io_read with bad major number"
0083   );
0084   puts( "TA1 - rtems_io_read - RTEMS_INVALID_NUMBER" );
0085   status = rtems_io_write( 0xffff, 0x0ffff, NULL);
0086   fatal_directive_status(
0087     status,
0088     RTEMS_INVALID_NUMBER,
0089     "rtems_io_write with bad major number"
0090   );
0091   puts( "TA1 - rtems_io_write - RTEMS_INVALID_NUMBER" );
0092 
0093   build_time( &time, 12, 31, 2000, 23, 59, 59, 0 );
0094   status = rtems_clock_set( &time );
0095   directive_failed( status, "rtems_clock_set" );
0096   print_time( "TA1 - rtems_clock_set - ", &time, " - RTEMS_SUCCESSFUL\n" );
0097   status = rtems_task_wake_after( rtems_clock_get_ticks_per_second() );
0098   status = rtems_clock_get_tod( &time );
0099   directive_failed( status, "rtems_clock_set" );
0100   print_time( "TA1 - rtems_clock_get_tod - ", &time, " - RTEMS_SUCCESSFUL\n" );
0101 
0102   build_time( &time, 12, 31, 1999, 23, 59, 59, 0 );
0103   status = rtems_clock_set( &time );
0104   directive_failed( status, "rtems_clock_set" );
0105   print_time( "TA1 - rtems_clock_set - ", &time, " - RTEMS_SUCCESSFUL\n" );
0106   status = rtems_task_wake_after( rtems_clock_get_ticks_per_second() );
0107   status = rtems_clock_get_tod( &time );
0108   directive_failed( status, "rtems_clock_get_tod" );
0109   print_time( "TA1 - rtems_clock_get_tod - ", &time, " - RTEMS_SUCCESSFUL\n" );
0110 
0111   build_time( &time, 12, 31, 2099, 23, 59, 59, 0 );
0112   status = rtems_clock_set( &time );
0113   directive_failed( status, "rtems_clock_set" );
0114   print_time( "TA1 - rtems_clock_set - ", &time, " - RTEMS_SUCCESSFUL\n" );
0115   status = rtems_task_wake_after( rtems_clock_get_ticks_per_second() );
0116   status = rtems_clock_get_tod( &time );
0117   directive_failed( status, "rtems_clock_set" );
0118   print_time( "TA1 - rtems_clock_get_tod - ", &time, " - RTEMS_SUCCESSFUL\n" );
0119 
0120   build_time( &time, 1, 1, 2100, 0, 0, 0, 0 );
0121   status = rtems_clock_set( &time );
0122   fatal_directive_status( status, RTEMS_INVALID_CLOCK, "rtems_clock_set" );
0123   print_time( "TA1 - rtems_clock_set - ", &time, " - RTEMS_INVALID_CLOCK\n" );
0124   status = rtems_task_wake_after( rtems_clock_get_ticks_per_second() );
0125   status = rtems_clock_get_tod( &time );
0126   directive_failed( status, "rtems_clock_set" );
0127   print_time( "TA1 - rtems_clock_get_tod - ", &time, " - RTEMS_SUCCESSFUL\n" );
0128 
0129   build_time( &time, 12, 31, 1991, 23, 59, 59, 0 );
0130   status = rtems_clock_set( &time );
0131   directive_failed( status, "rtems_clock_set" );
0132   print_time( "TA1 - rtems_clock_set - ", &time, " - RTEMS_SUCCESSFUL\n" );
0133   status = rtems_task_wake_after( rtems_clock_get_ticks_per_second() );
0134   status = rtems_clock_get_tod( &time );
0135   directive_failed( status, "rtems_clock_set" );
0136   print_time( "TA1 - rtems_clock_get_tod - ", &time, " - RTEMS_SUCCESSFUL\n" );
0137 
0138   TEST_END();
0139   rtems_test_exit( 0 );
0140 }
0141 
0142 #define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
0143 #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
0144 
0145 #define CONFIGURE_MAXIMUM_TASKS             1
0146 #define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
0147 
0148 #define CONFIGURE_RTEMS_INIT_TASKS_TABLE
0149 
0150 #define CONFIGURE_INIT
0151 
0152 #include <rtems/confdefs.h>
0153 /* end of file */