Changeset acf1e5b2 in rtems for testsuites/validation/tc-clock.c
- Timestamp:
- 09/22/22 11:19:34 (6 months ago)
- 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)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
testsuites/validation/tc-clock.c
r962904c racf1e5b2 8 8 9 9 /* 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) 11 11 * 12 12 * Redistribution and use in source and binary forms, with or without … … 69 69 * This test case performs the following actions: 70 70 * 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. 72 73 * 73 74 * - Check that clock tick gets incremented. 74 75 * 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. 76 87 * 77 88 * - Check that rtems_clock_get_ticks_per_second() actually returns 1us / … … 82 93 83 94 /** 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. 85 97 */ 86 98 static void RtemsClockValClock_Action_0( void ) … … 88 100 rtems_interval result_0; 89 101 rtems_interval result_1; 90 int32_t difference; /* Note: rtems_interval = uint32_t (unsigned!) */91 102 92 103 result_0 = rtems_clock_get_ticks_since_boot(); 93 104 ClockTick(); 94 105 result_1 = rtems_clock_get_ticks_since_boot(); 95 /*96 * Because of the ones-complement, the overflow97 * is handled correctly. result_0 = 0xFFFFFFFF will become -198 * and result_1 = 0x0 will become 0.99 */100 difference = (int32_t) result_1 - (int32_t) result_0;101 106 102 107 /* 103 108 * Check that clock tick gets incremented. 104 109 */ 105 T_step_eq_ i32( 0, difference, 1 );110 T_step_eq_u32( 0, result_1 - result_0, 1 ); 106 111 } 107 112 108 113 /** 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. 110 116 */ 111 117 static void RtemsClockValClock_Action_1( void ) 112 118 { 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 */ 137 static void RtemsClockValClock_Action_2( void ) 138 { 113 139 rtems_interval result; 140 114 141 result = rtems_clock_get_ticks_per_second(); 115 142 … … 118 145 * CONFIGURE_MICROSECONDS_PER_TICK. 119 146 */ 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 */ 153 static 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 ); 121 166 } 122 167 … … 126 171 T_TEST_CASE( RtemsClockValClock ) 127 172 { 128 T_plan( 2);173 T_plan( 4 ); 129 174 130 175 RtemsClockValClock_Action_0(); 131 176 RtemsClockValClock_Action_1(); 177 RtemsClockValClock_Action_2(); 178 RtemsClockValClock_Action_3(); 132 179 } 133 180
Note: See TracChangeset
for help on using the changeset viewer.