summaryrefslogtreecommitdiffstats
path: root/spec/rtems/io/req/put-char.yml
blob: 6c4fe876dc374783088aaadd53a82e8fa0564aa6 (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
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
functional-type: action
links:
- role: interface-function
  uid: ../if/put-char
post-conditions:
- name: Output
  states:
  - name: CrNl
    test-code: |
      T_eq_int( ctx->output[ 0 ], (unsigned char) '\r' );
      T_eq_int( ctx->output[ 1 ], (unsigned char) '\n' );
      T_eq_sz( ctx->output_count, 2 );
    text: |
      The function referenced by ${../if/bsp-output-char:/name} shall be called
      with a ``CR`` character followed by a call with a ``NL`` character.
  - name: Other
    test-code: |
      T_eq_int( ctx->output[ 0 ], 0xff );
      T_eq_sz( ctx->output_count, 1 );
    text: |
      The function referenced by ${../if/bsp-output-char:/name} shall be called
      with the character specified by ${../if/put-char:/params[0]/name}.
  test-epilogue: null
  test-prologue: null
pre-conditions:
- name: Char
  states:
  - name: Nl
    test-code: |
      ctx->character = '\n';
    text: |
      While the ${../if/put-char:/params[0]/name} parameter is
      equal to ``NL``.
  - name: Other
    test-code: |
      ctx->character = 0xff;
    text: |
      While the ${../if/put-char:/params[0]/name} parameter is
      not equal to ``NL``.
  test-epilogue: null
  test-prologue: null
rationale: null
references: []
requirement-type: functional
skip-reasons: {}
test-action: |
  BSP_output_char_function_type output_char;

  ctx->output[ 0 ] = -1;
  ctx->output[ 1 ] = -1;
  ctx->output_count = 0;
  output_char = BSP_output_char;
  BSP_output_char = OutputChar;
  rtems_put_char( ctx->character, NULL );
  BSP_output_char = output_char;
test-brief: null
test-cleanup: null
test-context:
- brief: |
    This member contains the character output.
  description: null
  member: |
    int output[ 2 ]
- brief: |
    This member contains the character output count.
  description: null
  member: |
    size_t output_count
- brief: |
    This member specifies if the ${../if/put-char:/params[0]/name}
    parameter value.
  description: null
  member: |
    int character
test-context-support: null
test-description: null
test-header: null
test-includes:
- rtems/bspIo.h
test-local-includes: []
test-prepare: null
test-setup: null
test-stop: null
test-support: |
  typedef ${.:/test-context-type} Context;

  static void Output( int value )
  {
    Context *ctx;

    ctx = T_fixture_context();

    if ( ctx->output_count < RTEMS_ARRAY_SIZE( ctx->output ) ) {
      ctx->output[ ctx->output_count ] = value;
    }

    ++ctx->output_count;
  }

  static void WrongOutput( char c )
  {
    (void) c;
    Output( -1 );
  }

  static void OutputChar( char c )
  {
    BSP_output_char = WrongOutput;
    Output( (unsigned char) c );
  }
test-target: testsuites/validation/tc-io-put-char.c
test-teardown: null
text: ${.:text-template}
transition-map:
- enabled-by: true
  post-conditions:
    Output: CrNl
  pre-conditions:
    Char:
    - Nl
- enabled-by: true
  post-conditions:
    Output: Other
  pre-conditions:
    Char:
    - Other
type: requirement