Changeset fe7cc1ea in rtems


Ignore:
Timestamp:
09/29/11 09:40:32 (12 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
4.11, 5, master
Children:
8d7aea0d
Parents:
0d57369
Message:

2011-09-29 Sebastian Huber <sebastian.huber@…>

  • sp2038/init.c: More test cases.
Location:
testsuites/sptests
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • testsuites/sptests/ChangeLog

    r0d57369 rfe7cc1ea  
     12011-09-29      Sebastian Huber <sebastian.huber@embedded-brains.de>
     2
     3        * sp2038/init.c: More test cases.
     4
    152011-09-28      Sebastian Huber <sebastian.huber@embedded-brains.de>
    26
  • testsuites/sptests/sp2038/init.c

    r0d57369 rfe7cc1ea  
    3131#define ASSERT_SC(sc) rtems_test_assert((sc) == RTEMS_SUCCESSFUL)
    3232
     33static const uint32_t sample_seconds [] = {
     34  571213695UL,
     35  602836095UL,
     36  634372095UL,
     37  665908095UL,
     38  697444095UL,
     39  729066495UL,
     40  760602495UL,
     41  792138495UL,
     42  823674495UL,
     43  855296895UL,
     44  886832895UL,
     45  918368895UL,
     46  949904895UL,
     47  981527295UL,
     48  1013063295UL,
     49  1044599295UL,
     50  1076135295UL,
     51  1107757695UL,
     52  1139293695UL,
     53  1170829695UL,
     54  1202365695UL,
     55  1233988095UL,
     56  1265524095UL,
     57  1297060095UL,
     58  1328596095UL,
     59  1360218495UL,
     60  1391754495UL,
     61  1423290495UL,
     62  1454826495UL,
     63  1486448895UL,
     64  1517984895UL,
     65  1549520895UL,
     66  1581056895UL,
     67  1612679295UL,
     68  1644215295UL,
     69  1675751295UL,
     70  1707287295UL,
     71  1738909695UL,
     72  1770445695UL,
     73  1801981695UL,
     74  1833517695UL,
     75  1865140095UL,
     76  1896676095UL,
     77  1928212095UL,
     78  1959748095UL,
     79  1991370495UL,
     80  2022906495UL,
     81  2054442495UL,
     82  2085978495UL,
     83  2117600895UL,
     84  2149136895UL,
     85  2180672895UL,
     86  2212208895UL,
     87  2243831295UL,
     88  2275367295UL,
     89  2306903295UL,
     90  2338439295UL,
     91  2370061695UL,
     92  2401597695UL,
     93  2433133695UL,
     94  2464669695UL,
     95  2496292095UL,
     96  2527828095UL,
     97  2559364095UL,
     98  2590900095UL,
     99  2622522495UL,
     100  2654058495UL,
     101  2685594495UL,
     102  2717130495UL,
     103  2748752895UL,
     104  2780288895UL,
     105  2811824895UL,
     106  2843360895UL,
     107  2874983295UL,
     108  2906519295UL,
     109  2938055295UL,
     110  2969591295UL,
     111  3001213695UL,
     112  3032749695UL,
     113  3064285695UL,
     114  3095821695UL,
     115  3127444095UL,
     116  3158980095UL,
     117  3190516095UL,
     118  3222052095UL,
     119  3253674495UL,
     120  3285210495UL,
     121  3316746495UL,
     122  3348282495UL,
     123  3379904895UL,
     124  3411440895UL,
     125  3442976895UL,
     126  3474512895UL,
     127  3506135295UL,
     128  3537671295UL,
     129  3569207295UL,
     130  3600743295UL,
     131  3632365695UL,
     132  3663901695UL,
     133  3695437695UL,
     134  3726973695UL,
     135  3758596095UL,
     136  3790132095UL,
     137  3821668095UL,
     138  3853204095UL,
     139  3884826495UL,
     140  3916362495UL,
     141  3947898495UL,
     142  3979434495UL,
     143  4011056895UL,
     144  4042592895UL,
     145  4074128895UL,
     146  4105664895UL,
     147  4137200895UL,
     148  4168736895UL,
     149  4200272895UL,
     150  4231808895UL,
     151  4263431295UL,
     152  4294967295UL
     153};
     154
    33155static const rtems_time_of_day nearly_problem_2038 = {
    34156  .year = 2038,
     
    67189};
    68190
    69 static void test_case(void)
     191static void test_tod_to_seconds(void)
     192{
     193  rtems_status_code sc = RTEMS_SUCCESSFUL;
     194  size_t i = 0;
     195  size_t n = sizeof(sample_seconds) / sizeof(sample_seconds [0]);
     196
     197  for (i = 0; i < n; ++i) {
     198    rtems_time_of_day tod = nearly_problem_2106;
     199    uint32_t seconds = 0;
     200    rtems_interval seconds_as_interval = 0;
     201
     202    tod.year = 1988 + i;
     203    seconds = _TOD_To_seconds(&tod);
     204    rtems_test_assert(seconds == sample_seconds [i]);
     205
     206    sc = rtems_clock_set(&tod);
     207    ASSERT_SC(sc);
     208
     209    sc = rtems_clock_get_seconds_since_epoch(&seconds_as_interval);
     210    ASSERT_SC(sc);
     211    rtems_test_assert(seconds_as_interval == sample_seconds [i]);
     212  }
     213}
     214
     215static void test_problem_year(void)
    70216{
    71217#if TEST_APPLICABLE
    72218  rtems_status_code sc = RTEMS_SUCCESSFUL;
    73   int64_t one = 1;
    74   int64_t large = one << 32;
    75   time_t time_t_large = (time_t) large;
    76   bool time_t_is_32_bit = time_t_large != large;
    77   bool time_t_is_signed = (((time_t) 0) - ((time_t) 1)) < 0;
     219  time_t zero = 0;
     220  time_t one = 1;
     221  time_t maybe_negative = zero - one;
     222  bool time_t_is_32_bit = sizeof(time_t) == 4;
     223  bool time_t_is_signed = maybe_negative < zero;
    78224
    79225  if (time_t_is_32_bit) {
     
    109255  puts("\n\n*** TEST 2038 ***");
    110256
    111   test_case();
     257  test_tod_to_seconds();
     258  test_problem_year();
    112259
    113260  puts("*** END OF TEST 2038 ***");
Note: See TracChangeset for help on using the changeset viewer.