summaryrefslogtreecommitdiffstats
path: root/testsuites/libtests/block08/block08.doc
blob: 84c26188e37c2b267868278d58ceaf1c195ca6c0 (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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
bdbuf tests
~~~~~~~~~~~

Test 1
~~~~~~

Tests of this group check the behaviour of rtems_bdbuf_read() function
in different situations.

Test 1.1
~~~~~~~~

Check the behaviour of rtems_bdbuf_read function with different 
reports from disk device driver.

1. Call rtems_bdbuf_read() function and disk device driver ioctl()
   function returns 0, and the result of asynchronous read complete 
   notification is successful.
   Check that rtems_bdbuf_read() returns RTEMS_SUCCESSFUL and
   provides buffer descriptor.
2. Call rtems_bdbuf_read() function and disk device driver ioctl()
   function returns -1 (there will be no asynchronous read complete
   notification).
   Check that rtems_bdbuf_read() returns RTEMS_IO_ERROR.
3. Call rtems_bdbuf_read() function and disk device driver ioctl()
   function returns 0, but the result of asynchronous read complete 
   notification is faulty (with some erroneous status).
   Check that rtems_bdbuf_read() returns that status and does not
   return buffer descriptor.

Test 1.2
~~~~~~~~

Check how rtems_bdbuf_read() handles two readers waiting for a buffer
for the same block number in cases when disk device driver reports 
failure in read complete notification.

1. Call rtems_bdbuf_read() function in thread #1 and block on 
   waiting for read complete notification.
2. Call rtems_bdbuf_read() function in thread #2 for the same block
   number. As the result it blocks on this read as well (but it will
   block on transfer semaphore).
3. Disk device reports an error in read complete notification.
   As the result an error is returned from rtems_bdbuf_read() in 
   thread #1.
4. rtems_bdbuf_read() called in thread #2 should try to re-read data
   again so disk device ioctl() function is called again for this
   block number.
5. Disk device reports an error in read complete notification.
   As the result an error is returned from rtems_bdbuf_read() in 
   thread #2.

Test 1.3
~~~~~~~~

Check how rtems_bdbuf_read() handles two readers waiting for a buffer
for the same block number in cases when disk device driver reports 
failure in read complete notification.

1. Call rtems_bdbuf_read() function in thread #1 and block on 
   waiting for read complete notification.
2. Call rtems_bdbuf_read() function in thread #2 for the same block
   number. As the result it blocks on this read as well (but it will
   block on transfer semaphore).
3. Disk device reports an error in read complete notification.
   As the result an error is returned from rtems_bdbuf_read() in 
   thread #1.
4. rtems_bdbuf_read() called in thread #2 should try to re-read data
   again so disk device ioctl() function is called again for this
   block number.
5. This time disk device reports success in read complete notification.
   As the result rtems_bdbuf_read() in thread #2 shall return RTEMS_SUCCESSFUL
   and provide buffer descriptor.
6. Call rtems_bdbuf_release() function in thread #2.

Test 1.4
~~~~~~~~

Check how rtems_bdbuf_read() handles two readers waiting for a buffer
for the same block number in cases when disk device driver reports 
success in read complete notification.

1. Call rtems_bdbuf_read() function in thread #1 and block on 
   waiting for read complete notification.
2. Call rtems_bdbuf_read() function in thread #2 for the same block
   number. As the result it blocks on this read as well (but it will
   block on transfer semaphore).
3. Disk device reports success in read complete notification.
   As the result rtems_bdbuf_read() function retuens RTEMS_SUCCESSFUL
   in thread #1.
4. Thread #1 releases buffer with rtems_bdbuf_release() function.
5. rtems_bdbuf_read() function in thread #2 unlocks and returns
   RTEMS_SUCCESSFUL.
6. Call rtems_bdbuf_release() function in thread #2.

ISSUE (A)
Due to implementation constrains of bdbuf library there is no way to 
handle such a situation according to task priority, but it is
coded in such a way that task requested this buffer first will get it
first (even though it is less priority task).

Test 1.5
~~~~~~~~

Check how rtems_bdbuf_read() handles read request for a buffer that
is owned by an application.

1. Call rtems_bdbuf_read() function in thread #1 and provide successful
   read complete notification for this operation.
   As the result rtems_bdbuf_read() returns RTEMS_SUCCESSFUL in thread #1.
2. In thread #2 call rtems_bdbuf_read() function for the same block number.
   A buffer for this block is owned by an application and as the result 
   thread #2 block on this function.
3. Call rtems_bdbuf_release() function in thread #1 in order to give
   it back under control of bdbuf library.
4. Buffer now is ready to be returned for another application and as 
   the result rtems_bdbuf_read() unblocks and returns RTEMS_SUCCESSFUL 
   in thread #2.
5. Call rtems_bdbuf_release() function in thread #2.


Test 2.1
~~~~~~~~

Check how rtems_bdbuf_read() and rtems_bdbuf_release_modified() coexist.
rtems_bdbuf_read() is blocked when required buffer is being transferred. 

1. Call rtems_bdbuf_read() function in thread #1 and block on 
   waiting for read complete notification.
2. Call rtems_bdbuf_read() function in thread #2 for the same block
   number. As the result it blocks on this read as well (but it will
   block on transfer semaphore).
3. Disk device reports success in read complete notification.
   As the result rtems_bdbuf_read() function retuens RTEMS_SUCCESSFUL
   in thread #1.
4. Thread #1 releases buffer with rtems_bdbuf_release_modified() function.
5. rtems_bdbuf_read() function in thread #2 unlocks and returns
   RTEMS_SUCCESSFUL.
6. Wait swapout period and check that the buffer is not requested to be
   flushed to a disk.
7. Call rtems_bdbuf_release() function in thread #2.
8. Check that this block number is requested for a flush in swapout period.

ISSUE (A)

Test 2.2
~~~~~~~~

The same as Test 2.1, but on step 7 thread #2 calls 
rtems_bdbuf_release_modified().
Check how rtems_bdbuf_read() and rtems_bdbuf_release_modified() coexist.
rtems_bdbuf_read() is blocked when required buffer is being transferred.

1. Call rtems_bdbuf_read() function in thread #1 and block on 
   waiting for read complete notification.
2. Call rtems_bdbuf_read() function in thread #2 for the same block
   number. As the result it blocks on this read as well (but it will
   block on transfer semaphore).
3. Disk device reports success in read complete notification.
   As the result rtems_bdbuf_read() function retuens RTEMS_SUCCESSFUL
   in thread #1.
4. Thread #1 releases buffer with rtems_bdbuf_release_modified() function.
5. rtems_bdbuf_read() function in thread #2 unlocks and returns
   RTEMS_SUCCESSFUL.
6. Wait swapout period and check that the buffer is not requested to be
   flushed to a disk.
7. Call rtems_bdbuf_release_modified() function in thread #2.
8. Check that this block number is requested for a flush in swapout period.

Test 2.3
~~~~~~~~

Check how rtems_bdbuf_read() and rtems_bdbuf_release_modified() coexist.
rtems_bdbuf_read() is blocked when required buffer is owned by another
application.

1. Call rtems_bdbuf_read() function in thread #1 and provide successful
   read complete notification for this operation.
   As the result rtems_bdbuf_read() returns RTEMS_SUCCESSFUL in thread #1.
2. In thread #2 call rtems_bdbuf_read() function for the same block number.
   A buffer for this block is owned by an application and as the result 
   thread #2 block on this function.
3. Call rtems_bdbuf_release_modified() function in thread #1 in order 
   to give it back under control of bdbuf library.
4. Buffer now is ready to be returned for another application and as 
   the result rtems_bdbuf_read() unblocks and returns RTEMS_SUCCESSFUL 
   in thread #2.
5. Wait swapout period and check that the buffer is not requested to be
   flushed to a disk.
6. Call rtems_bdbuf_release() function in thread #2.
7. Check that this block number is requested for a flush in swapout period.

Test 2.4
~~~~~~~~

Check how rtems_bdbuf_read() and rtems_bdbuf_release_modified() coexist.
rtems_bdbuf_read() is blocked when required buffer is owned by another
application.
The same as Test 2.3 but thread #2 releases buffer with 
rtems_bdbuf_release_modified() function.

1. Call rtems_bdbuf_read() function in thread #1 and provide successful
   read complete notification for this operation.
   As the result rtems_bdbuf_read() returns RTEMS_SUCCESSFUL in thread #1.
2. In thread #2 call rtems_bdbuf_read() function for the same block number.
   A buffer for this block is owned by an application and as the result 
   thread #2 block on this function.
3. Call rtems_bdbuf_release_modified() function in thread #1 in order 
   to give it back under control of bdbuf library.
4. Buffer now is ready to be returned for another application and as 
   the result rtems_bdbuf_read() unblocks and returns RTEMS_SUCCESSFUL 
   in thread #2.
5. Wait swapout period and check that the buffer is not requested to be
   flushed to a disk.
6. Call rtems_bdbuf_release_modified() function in thread #2.
7. Check that this block number is requested for a flush in swapout period.



Test 3
~~~~~~

Tests of this group check the behaviour of concurent reads from 
different tasks. Reads are done for different block numbers.

Test 3.1
~~~~~~~~

Check how read/release work in case of only one buffer in ready list.

1. In thread #1 call rtems_bdbuf_get(#N) to get an empty block #N.
2. In thread #1 call rtems_bdbuf_release_modified() for previously got buffer.
3. In thread #1 call rtems_bdbuf_read(#N) to get the same buffer
   (after this call a buffer is in AVL tree with ACCESS_MODIFIED state).
4. In thread #2 call rtems_bdbuf_read/get(#M).
5. In thread #1 call rtems_bdbuf_release(#N).
6. Check that in thread #2 a buffer is obtained.

Test 3.2
~~~~~~~~

Check that when there are some tasks waiting for an available buffer only
one of them get a buffer after some other task releases one.

1. Call rtems_bdbuf_read(#N1) in thread #1.
2. Call rtems_bdbuf_get(#N2) in thread #2.
   This thread blocks because we have no buffers available.
3. Call rtems_bdbuf_get(#N3) in thread #3.
   This thread also blocks because we have no buffers available.
4. Call rtems_bdbuf_release_modified(#N1) in thread #1.
5. Check that only one thread (thread #2 or thread #3) got a buffer.
   Another thread shall still be blocked.

Test 3.3
~~~~~~~~

The same as Test 3.2, but instead of calling rtems_bdbuf_get() in 
threads #1 and #2, it calls rtems_bdbuf_read().

1. Call rtems_bdbuf_read(#N1) in thread #1.
2. Call rtems_bdbuf_read(#N2) in thread #2.
   This thread blocks because we have no buffers available.
3. Call rtems_bdbuf_read(#N3) in thread #3.
   This thread also blocks because we have no buffers available.
4. Call rtems_bdbuf_release(#N1) in thread #1.
5. Check that only one thread (thread #2 or thread #3) got a buffer.
   Another thread shall still be blocked.
6. Call rtems_bdbuf_release(#N2) in thread #2 and check that thread #3
   got a buffer as the result.

Test 4
~~~~~~

Group of tests for sync buffer functionality.

Test 4.1
~~~~~~~~

1. Call rtems_bdbuf_read(#N) in thread #1.
2. Call rtems_bdbuf_read(#N) from thread #2.
   Thread #2 blocks on this call.
3. Call rtems_bdbuf_sync(#N) in thread #1.
4. After a while disk driver gets write request for block #N.
   Notify bdbuf library about write complete event.
5. Check that thread #1 unlocked after this.
6. Check that thread #2 unblocks and get buffer #N.
7. Release buffer in thread #2.

Test 4.2
~~~~~~~~

1. Call rtems_bdbuf_read(#N) in thread #1.
2. Call rtems_bdbuf_sync(#N) in thread #1.
3. After a while disk driver gets write request for block #N.
4. Call rtems_bdbuf_read(#N) from thread #2 (before reply from the driver).
   Thread #2 blocks on this call.
5. Notify bdbuf library about write complete event.
6. Check that rtems_bdbuf_sync(#N) in thread #1 unlocked after this.
   (in fact a thread to unlock might be any).
7. Check that thread #2 unblocks and get buffer #N.
8. Release buffer in thread #2.

Test 4.3
~~~~~~~~

1. Call rtems_bdbuf_read(#N) in thread #1.
2. Call rtems_bdbuf_sync(#N) in thread #1.
3. After a while disk driver gets write request for block #N.
   Notify bdbuf about write complete event.
4. Check that rtems_bdbuf_sync(#N) in thread #1 unlocked after this.
5. Call rtems_bdbuf_read(#N) in thread #2.
6. Check that buffer is successfully obtained in thread #2.
7. Call rtems_bdbuf_release(#N) in thread #2.


Test 4.4
~~~~~~~~

TODO: Two brances in sync() function should be tested.