1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
|
SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause
copyrights:
- Copyright (C) 2021 embedded brains GmbH (http://www.embedded-brains.de)
enabled-by: true
links: []
test-actions:
- action-brief: |
Create a couple of timers.
action-code: |
rtems_status_code sc;
size_t i;
T_assert_eq_sz( TEST_MAXIMUM_TIMERS, 10 );
_Atomic_Init_uint( &ctx->counter, 0 );
for ( i = 0; i < TEST_MAXIMUM_TIMERS ; ++i ) {
sc = rtems_timer_create(
rtems_build_name( 'T', 'E', 'S', 'T' ),
&ctx->timer_ids[ i ]
);
T_rsc_success( sc );
}
checks:
- brief: |
Schedule some timers at the same time point.
code: |
Fire( ctx, 3, 2 );
Fire( ctx, 0, 1 );
Fire( ctx, 7, 3 );
Fire( ctx, 4, 2 );
Fire( ctx, 5, 2 );
Fire( ctx, 8, 3 );
Fire( ctx, 9, 3 );
Fire( ctx, 1, 1 );
Fire( ctx, 2, 1 );
Fire( ctx, 6, 2 );
links: []
- brief: |
Fire the timers and check that they fired in the expected order.
code: |
FinalClockTick();
for ( i = 0; i < TEST_MAXIMUM_TIMERS ; ++i ) {
T_eq_sz( ctx->counter_snapshots[ i ], i + 1 );
}
links:
- role: validation
uid: ../req/fire-order
- brief: |
Clean up all used resources.
code: |
for ( i = 0; i < TEST_MAXIMUM_TIMERS ; ++i ) {
sc = rtems_timer_delete( ctx->timer_ids[ i ] );
T_rsc_success( sc );
}
links: []
links: []
test-brief: |
Tests general timer behaviour.
test-context:
- brief: |
This member contains the timer identifiers.
description: null
member: |
rtems_id timer_ids[ TEST_MAXIMUM_TIMERS ]
- brief: |
This member contains the counter.
description: null
member: |
Atomic_Uint counter
- brief: |
This member contains the timer counter snapshots.
description: null
member: |
unsigned int counter_snapshots[ TEST_MAXIMUM_TIMERS ]
test-context-support: null
test-description: null
test-header: null
test-includes:
- rtems.h
- rtems/score/atomic.h
test-local-includes:
- ts-config.h
- tx-support.h
test-setup: null
test-stop: null
test-support: |
typedef ${.:/test-context-type} Context;
static void Timer( rtems_id timer, void *arg )
{
Context *ctx;
unsigned int *counter;
ctx = T_fixture_context();
counter = arg;
*counter = _Atomic_Fetch_add_uint(
&ctx->counter,
1,
ATOMIC_ORDER_RELAXED
) + 1;
}
static void Fire( Context *ctx, size_t i, rtems_interval ticks )
{
rtems_status_code sc;
ctx->counter_snapshots[ i ] = 0;
sc = rtems_timer_fire_after(
ctx->timer_ids[ i ],
ticks,
Timer,
&ctx->counter_snapshots[ i ]
);
T_rsc_success( sc );
}
test-target: testsuites/validation/tc-timer.c
test-teardown: null
type: test-case
|