Ignore:
Timestamp:
09/22/22 11:19:34 (6 months ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
9ed7103
Parents:
962904c
git-author:
Sebastian Huber <sebastian.huber@…> (09/22/22 11:19:34)
git-committer:
Sebastian Huber <sebastian.huber@…> (09/23/22 09:14:58)
Message:

rtems: Add rtems_clock_get_ticks_since_boot() function

This function was declared, however, a definition was missing. Add a
validation test for it.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • testsuites/validation/tc-clock.c

    r962904c racf1e5b2  
    88
    99/*
    10  * Copyright (C) 2021 embedded brains GmbH (http://www.embedded-brains.de)
     10 * Copyright (C) 2021, 2022 embedded brains GmbH (http://www.embedded-brains.de)
    1111 *
    1212 * Redistribution and use in source and binary forms, with or without
     
    6969 * This test case performs the following actions:
    7070 *
    71  * - Use the rtems_clock_get_ticks_since_boot() function.
     71 * - Use the rtems_clock_get_ticks_since_boot() directive before and after
     72 *   exactly one clock tick.
    7273 *
    7374 *   - Check that clock tick gets incremented.
    7475 *
    75  * - Use the rtems_clock_get_ticks_per_second() function.
     76 * - Use the rtems_clock_get_ticks_since_boot() directive before and after
     77 *   exactly one clock tick.
     78 *
     79 *   - Check that clock tick gets incremented.
     80 *
     81 * - Use the rtems_clock_get_ticks_per_second() directive.
     82 *
     83 *   - Check that rtems_clock_get_ticks_per_second() actually returns 1us /
     84 *     CONFIGURE_MICROSECONDS_PER_TICK.
     85 *
     86 * - Use the rtems_clock_get_ticks_per_second() directive.
    7687 *
    7788 *   - Check that rtems_clock_get_ticks_per_second() actually returns 1us /
     
    8293
    8394/**
    84  * @brief Use the rtems_clock_get_ticks_since_boot() function.
     95 * @brief Use the rtems_clock_get_ticks_since_boot() directive before and after
     96 *   exactly one clock tick.
    8597 */
    8698static void RtemsClockValClock_Action_0( void )
     
    88100  rtems_interval result_0;
    89101  rtems_interval result_1;
    90   int32_t difference; /* Note: rtems_interval = uint32_t (unsigned!) */
    91102
    92103  result_0 = rtems_clock_get_ticks_since_boot();
    93104  ClockTick();
    94105  result_1 = rtems_clock_get_ticks_since_boot();
    95   /*
    96    * Because of the ones-complement, the overflow
    97    * is handled correctly. result_0 = 0xFFFFFFFF will become -1
    98    * and result_1 = 0x0 will become 0.
    99    */
    100   difference = (int32_t) result_1 - (int32_t) result_0;
    101106
    102107  /*
    103108   * Check that clock tick gets incremented.
    104109   */
    105   T_step_eq_i32( 0, difference, 1 );
     110  T_step_eq_u32( 0, result_1 - result_0, 1 );
    106111}
    107112
    108113/**
    109  * @brief Use the rtems_clock_get_ticks_per_second() function.
     114 * @brief Use the rtems_clock_get_ticks_since_boot() directive before and after
     115 *   exactly one clock tick.
    110116 */
    111117static void RtemsClockValClock_Action_1( void )
    112118{
     119  rtems_interval result_0;
     120  rtems_interval result_1;
     121
     122  #undef rtems_clock_get_ticks_since_boot
     123
     124  result_0 = rtems_clock_get_ticks_since_boot();
     125  ClockTick();
     126  result_1 = rtems_clock_get_ticks_since_boot();
     127
     128  /*
     129   * Check that clock tick gets incremented.
     130   */
     131  T_step_eq_u32( 1, result_1 - result_0, 1 );
     132}
     133
     134/**
     135 * @brief Use the rtems_clock_get_ticks_per_second() directive.
     136 */
     137static void RtemsClockValClock_Action_2( void )
     138{
    113139  rtems_interval result;
     140
    114141  result = rtems_clock_get_ticks_per_second();
    115142
     
    118145   * CONFIGURE_MICROSECONDS_PER_TICK.
    119146   */
    120   T_step_eq_u32( 1, result, 1000000UL / TEST_MICROSECONDS_PER_TICK );
     147  T_step_eq_u32( 2, result, 1000000UL / TEST_MICROSECONDS_PER_TICK );
     148}
     149
     150/**
     151 * @brief Use the rtems_clock_get_ticks_per_second() directive.
     152 */
     153static void RtemsClockValClock_Action_3( void )
     154{
     155  rtems_interval result;
     156
     157  #undef rtems_clock_get_ticks_per_second
     158
     159  result = rtems_clock_get_ticks_per_second();
     160
     161  /*
     162   * Check that rtems_clock_get_ticks_per_second() actually returns 1us /
     163   * CONFIGURE_MICROSECONDS_PER_TICK.
     164   */
     165  T_step_eq_u32( 3, result, 1000000UL / TEST_MICROSECONDS_PER_TICK );
    121166}
    122167
     
    126171T_TEST_CASE( RtemsClockValClock )
    127172{
    128   T_plan( 2 );
     173  T_plan( 4 );
    129174
    130175  RtemsClockValClock_Action_0();
    131176  RtemsClockValClock_Action_1();
     177  RtemsClockValClock_Action_2();
     178  RtemsClockValClock_Action_3();
    132179}
    133180
Note: See TracChangeset for help on using the changeset viewer.