source: rtems/testsuites/validation/tc-clock.c @ 962904c

Last change on this file since 962904c was 034d0b2, checked in by Frank Kühndel <frank.kuehndel@…>, on 12/09/21 at 15:10:46

validation: Test Clock Manager

The test source code is generated from specification items
by the "./spec2modules.py" script contained in the
git://git.rtems.org/rtems-central.git Git repository.

Please read the "How-To" section in the "Software Requirements Engineering"
chapter of the RTEMS Software Engineering manual to get more information about
the process.

Update #3716.

  • Property mode set to 100644
File size: 4.0 KB
Line 
1/* SPDX-License-Identifier: BSD-2-Clause */
2
3/**
4 * @file
5 *
6 * @ingroup RTEMSTestCaseRtemsClockValClock
7 */
8
9/*
10 * Copyright (C) 2021 embedded brains GmbH (http://www.embedded-brains.de)
11 *
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
14 * are met:
15 * 1. Redistributions of source code must retain the above copyright
16 *    notice, this list of conditions and the following disclaimer.
17 * 2. Redistributions in binary form must reproduce the above copyright
18 *    notice, this list of conditions and the following disclaimer in the
19 *    documentation and/or other materials provided with the distribution.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
25 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 * POSSIBILITY OF SUCH DAMAGE.
32 */
33
34/*
35 * This file is part of the RTEMS quality process and was automatically
36 * generated.  If you find something that needs to be fixed or
37 * worded better please post a report or patch to an RTEMS mailing list
38 * or raise a bug report:
39 *
40 * https://www.rtems.org/bugs.html
41 *
42 * For information on updating and regenerating please refer to the How-To
43 * section in the Software Requirements Engineering chapter of the
44 * RTEMS Software Engineering manual.  The manual is provided as a part of
45 * a release.  For development sources please refer to the online
46 * documentation at:
47 *
48 * https://docs.rtems.org
49 */
50
51#ifdef HAVE_CONFIG_H
52#include "config.h"
53#endif
54
55#include <rtems.h>
56
57#include "ts-config.h"
58#include "tx-support.h"
59
60#include <rtems/test.h>
61
62/**
63 * @defgroup RTEMSTestCaseRtemsClockValClock spec:/rtems/clock/val/clock
64 *
65 * @ingroup RTEMSTestSuiteTestsuitesValidationNoClock0
66 *
67 * @brief Tests some @ref RTEMSAPIClassicClock directives.
68 *
69 * This test case performs the following actions:
70 *
71 * - Use the rtems_clock_get_ticks_since_boot() function.
72 *
73 *   - Check that clock tick gets incremented.
74 *
75 * - Use the rtems_clock_get_ticks_per_second() function.
76 *
77 *   - Check that rtems_clock_get_ticks_per_second() actually returns 1us /
78 *     CONFIGURE_MICROSECONDS_PER_TICK.
79 *
80 * @{
81 */
82
83/**
84 * @brief Use the rtems_clock_get_ticks_since_boot() function.
85 */
86static void RtemsClockValClock_Action_0( void )
87{
88  rtems_interval result_0;
89  rtems_interval result_1;
90  int32_t difference; /* Note: rtems_interval = uint32_t (unsigned!) */
91
92  result_0 = rtems_clock_get_ticks_since_boot();
93  ClockTick();
94  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;
101
102  /*
103   * Check that clock tick gets incremented.
104   */
105  T_step_eq_i32( 0, difference, 1 );
106}
107
108/**
109 * @brief Use the rtems_clock_get_ticks_per_second() function.
110 */
111static void RtemsClockValClock_Action_1( void )
112{
113  rtems_interval result;
114  result = rtems_clock_get_ticks_per_second();
115
116  /*
117   * Check that rtems_clock_get_ticks_per_second() actually returns 1us /
118   * CONFIGURE_MICROSECONDS_PER_TICK.
119   */
120  T_step_eq_u32( 1, result, 1000000UL / TEST_MICROSECONDS_PER_TICK );
121}
122
123/**
124 * @fn void T_case_body_RtemsClockValClock( void )
125 */
126T_TEST_CASE( RtemsClockValClock )
127{
128  T_plan( 2 );
129
130  RtemsClockValClock_Action_0();
131  RtemsClockValClock_Action_1();
132}
133
134/** @} */
Note: See TracBrowser for help on using the repository browser.