Back to home page

LXR

 
 

    


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

0001 /* SPDX-License-Identifier: BSD-2-Clause */
0002 
0003 /**
0004  *  @file
0005  *
0006  *  This routine is the initialization task of test to exercise some
0007  *  timezone functionality.
0008  */
0009 
0010 /*
0011  *  COPYRIGHT (c) 2007-2012.
0012  *  On-Line Applications Research Corporation (OAR).
0013  *
0014  * Redistribution and use in source and binary forms, with or without
0015  * modification, are permitted provided that the following conditions
0016  * are met:
0017  * 1. Redistributions of source code must retain the above copyright
0018  *    notice, this list of conditions and the following disclaimer.
0019  * 2. Redistributions in binary form must reproduce the above copyright
0020  *    notice, this list of conditions and the following disclaimer in the
0021  *    documentation and/or other materials provided with the distribution.
0022  *
0023  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
0024  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
0025  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
0026  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
0027  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
0028  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
0029  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
0030  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
0031  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
0032  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
0033  * POSSIBILITY OF SUCH DAMAGE.
0034  */
0035 
0036 #ifdef HAVE_CONFIG_H
0037 #include "config.h"
0038 #endif
0039 
0040 #define CONFIGURE_INIT
0041 
0042 #include <tmacros.h>
0043 #include <time.h>
0044 #include <stdlib.h>
0045 
0046 const char rtems_test_name[] = "TZTEST";
0047  
0048 /* forward declarations to avoid warnings */
0049 rtems_task Init(rtems_task_argument argument);
0050 void tztester(void);
0051 
0052 void tztester(void)
0053 {
0054   struct tm *tm;
0055   time_t now;
0056 
0057   printf("TZ:\"%s\"\n", getenv("TZ"));
0058 
0059   time(&now);
0060   tm = localtime(&now);
0061   printf ("%4.4d-%2.2d-%2.2d %2.2d:%2.2d:%2.2d\n",
0062      1900+tm->tm_year, tm->tm_mon+1, tm->tm_mday,
0063      tm->tm_hour, tm->tm_min, tm->tm_sec);
0064 
0065   tm = gmtime(&now);
0066   printf ("%4.4d-%2.2d-%2.2d %2.2d:%2.2d:%2.2d\n",
0067      1900+tm->tm_year, tm->tm_mon+1, tm->tm_mday,
0068      tm->tm_hour, tm->tm_min, tm->tm_sec);
0069 }
0070 
0071 rtems_task Init(
0072   rtems_task_argument argument
0073 )
0074 {
0075   rtems_time_of_day time;
0076   rtems_status_code status;
0077 
0078   TEST_BEGIN();
0079 
0080   build_time( &time, 3, 14, 2007, 15, 9, 26, 5 );
0081   status = rtems_clock_set( &time );
0082   directive_failed( status, "rtems_clock_set" );
0083 
0084   setenv( "TZ", "CST6CDT,M 3.2.0,M 11.1.0", 1 );
0085 
0086   tzset();
0087 
0088   tztester();
0089 
0090   TEST_END();
0091   exit(0);
0092 }
0093 
0094 
0095 #define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
0096 #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
0097 
0098 #define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
0099 
0100 #define CONFIGURE_RTEMS_INIT_TASKS_TABLE
0101 #define CONFIGURE_MAXIMUM_TASKS 1
0102 
0103 #include <rtems/confdefs.h>