summaryrefslogtreecommitdiffstats
path: root/spec/rtems/message/val/perf.yml
blob: 08232c9de8dd8195c133f89b58f848a0922a062a (plain) (blame)
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
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:
- role: validation
  uid: ../req/perf-runtime
params:
  sample-count: 100
test-brief: |
  This test case provides a context to run ${../if/group:/name} performance
  tests.
test-cleanup: null
test-context:
- brief: |
    This member provides a message queue identifier.
  description: null
  member: |
    rtems_id queue_id
- brief: |
    This member provides a message to send.
  description: null
  member: |
    long message
- brief: |
    This member provides a worker identifier.
  description: null
  member: |
    rtems_id worker_id
- brief: |
    This member provides a status code.
  description: null
  member: |
    rtems_status_code status
test-context-support: null
test-description: null
test-includes:
- rtems.h
test-local-includes:
- tx-support.h
test-prepare: null
test-setup:
  brief: |
    Create a message queue and a worker task.
  code: |
    rtems_status_code sc;

    SetSelfPriority( PRIO_NORMAL );

    sc = rtems_message_queue_construct( &config, &ctx->queue_id );
    T_rsc_success( sc );

    ctx->worker_id = CreateTask( "WORK", PRIO_HIGH );
    StartTask( ctx->worker_id, Worker, ctx );
  description: null
test-stop: null
test-support: |
  #define MAXIMUM_PENDING_MESSAGES 1

  #define MAXIMUM_MESSAGE_SIZE 8

  #define EVENT_END RTEMS_EVENT_0

  #define EVENT_SEND RTEMS_EVENT_1

  #define EVENT_SEND_END RTEMS_EVENT_2

  #define EVENT_RECEIVE RTEMS_EVENT_3

  #define EVENT_RECEIVE_END RTEMS_EVENT_4

  typedef ${.:/test-context-type} Context;

  static RTEMS_MESSAGE_QUEUE_BUFFER( MAXIMUM_MESSAGE_SIZE )
    storage_area[ MAXIMUM_PENDING_MESSAGES ];

  rtems_message_queue_config config = {
    .name = OBJECT_NAME,
    .maximum_pending_messages = MAXIMUM_PENDING_MESSAGES,
    .maximum_message_size = MAXIMUM_MESSAGE_SIZE,
    .storage_area = storage_area,
    .storage_size = sizeof( storage_area )
  };

  static void Send( const Context *ctx, rtems_event_set events )
  {
    SendEvents( ctx->worker_id, events );
  }

  static void Worker( rtems_task_argument arg )
  {
    Context *ctx;

    ctx = (Context *) arg;

    while ( true ) {
      rtems_event_set   events;
      rtems_status_code sc;
      T_ticks           ticks;

      sc = rtems_event_receive(
        RTEMS_ALL_EVENTS,
        RTEMS_EVENT_ANY | RTEMS_WAIT,
        RTEMS_NO_TIMEOUT,
        &events
      );
      ticks = T_tick();
      T_quiet_rsc_success( sc );

      if ( ( events & EVENT_END ) != 0 ) {
        ctx->end = ticks;
      }

      if ( ( events & EVENT_SEND ) != 0 ) {
        sc = rtems_message_queue_send(
          ctx->queue_id,
          &ctx->message,
          sizeof( ctx->message )
        );
        ticks = T_tick();
        T_quiet_rsc_success( sc );

        if ( ( events & EVENT_SEND_END ) != 0 ) {
          ctx->end = ticks;
        }
      }

      if ( ( events & EVENT_RECEIVE ) != 0 ) {
        long   message;
        size_t size;

        sc = rtems_message_queue_receive(
          ctx->queue_id,
          &message,
          &size,
          RTEMS_WAIT,
          RTEMS_NO_TIMEOUT
        );
        ticks = T_tick();
        T_quiet_rsc_success( sc );

        if ( ( events & EVENT_RECEIVE_END ) != 0 ) {
          ctx->end = ticks;
        }
      }
    }
  }
test-target: testsuites/validation/tc-message-performance.c
test-teardown:
  brief: |
    Delete the worker task and the message queue.
  code: |
    rtems_status_code sc;

    DeleteTask( ctx->worker_id );

    sc = rtems_message_queue_delete( ctx->queue_id );
    T_rsc_success( sc );

    RestoreRunnerPriority();
  description: null
type: runtime-measurement-test