|
@@ -124,6 +124,8 @@ static int list_check_contents ( struct list_head *list,
|
124
|
124
|
*/
|
125
|
125
|
static void list_test_exec ( void ) {
|
126
|
126
|
struct list_head *list = &test_list;
|
|
127
|
+ struct list_head target_list;
|
|
128
|
+ struct list_head *target = &target_list;
|
127
|
129
|
|
128
|
130
|
/* Test initialiser and list_empty() */
|
129
|
131
|
ok ( list_empty ( list ) );
|
|
@@ -153,6 +155,176 @@ static void list_test_exec ( void ) {
|
153
|
155
|
list_contents_ok ( list, "" );
|
154
|
156
|
ok ( list_empty ( list ) );
|
155
|
157
|
|
|
158
|
+ /* Test list_is_singular() */
|
|
159
|
+ INIT_LIST_HEAD ( list );
|
|
160
|
+ ok ( ! list_is_singular ( list ) );
|
|
161
|
+ list_add ( &list_tests[1].list, list );
|
|
162
|
+ ok ( list_is_singular ( list ) );
|
|
163
|
+ list_add ( &list_tests[3].list, list );
|
|
164
|
+ ok ( ! list_is_singular ( list ) );
|
|
165
|
+ list_del ( &list_tests[1].list );
|
|
166
|
+ ok ( list_is_singular ( list ) );
|
|
167
|
+
|
|
168
|
+ /* Test list_is_last() */
|
|
169
|
+ INIT_LIST_HEAD ( list );
|
|
170
|
+ list_add_tail ( &list_tests[6].list, list );
|
|
171
|
+ ok ( list_is_last ( &list_tests[6].list, list ) );
|
|
172
|
+ list_add_tail ( &list_tests[4].list, list );
|
|
173
|
+ ok ( list_is_last ( &list_tests[4].list, list ) );
|
|
174
|
+ ok ( ! list_is_last ( &list_tests[6].list, list ) );
|
|
175
|
+
|
|
176
|
+ /* Test list_cut_position() - empty list */
|
|
177
|
+ INIT_LIST_HEAD ( list );
|
|
178
|
+ INIT_LIST_HEAD ( target );
|
|
179
|
+ list_cut_position ( target, list, list );
|
|
180
|
+ list_contents_ok ( list, "" );
|
|
181
|
+ list_contents_ok ( target, "" );
|
|
182
|
+
|
|
183
|
+ /* Test list_cut_position() - singular list, move nothing */
|
|
184
|
+ INIT_LIST_HEAD ( list );
|
|
185
|
+ INIT_LIST_HEAD ( target );
|
|
186
|
+ list_add_tail ( &list_tests[4].list, list );
|
|
187
|
+ list_cut_position ( target, list, list );
|
|
188
|
+ list_contents_ok ( list, "4" );
|
|
189
|
+ list_contents_ok ( target, "" );
|
|
190
|
+
|
|
191
|
+ /* Test list_cut_position() - singular list, move singular entry */
|
|
192
|
+ INIT_LIST_HEAD ( list );
|
|
193
|
+ INIT_LIST_HEAD ( target );
|
|
194
|
+ list_add_tail ( &list_tests[9].list, list );
|
|
195
|
+ list_cut_position ( target, list, &list_tests[9].list );
|
|
196
|
+ list_contents_ok ( list, "" );
|
|
197
|
+ list_contents_ok ( target, "9" );
|
|
198
|
+
|
|
199
|
+ /* Test list_cut_position() - multi-entry list, move nothing */
|
|
200
|
+ INIT_LIST_HEAD ( list );
|
|
201
|
+ list_add_tail ( &list_tests[3].list, list );
|
|
202
|
+ list_add_tail ( &list_tests[2].list, list );
|
|
203
|
+ list_add_tail ( &list_tests[7].list, list );
|
|
204
|
+ INIT_LIST_HEAD ( target );
|
|
205
|
+ list_cut_position ( target, list, list );
|
|
206
|
+ list_contents_ok ( list, "327" );
|
|
207
|
+ list_contents_ok ( target, "" );
|
|
208
|
+
|
|
209
|
+ /* Test list_cut_position() - multi-entry list, move some */
|
|
210
|
+ INIT_LIST_HEAD ( list );
|
|
211
|
+ INIT_LIST_HEAD ( target );
|
|
212
|
+ list_add_tail ( &list_tests[8].list, list );
|
|
213
|
+ list_add_tail ( &list_tests[0].list, list );
|
|
214
|
+ list_add_tail ( &list_tests[9].list, list );
|
|
215
|
+ list_add_tail ( &list_tests[3].list, list );
|
|
216
|
+ list_add_tail ( &list_tests[2].list, list );
|
|
217
|
+ list_cut_position ( target, list, &list_tests[0].list );
|
|
218
|
+ list_contents_ok ( list, "932" );
|
|
219
|
+ list_contents_ok ( target, "80" );
|
|
220
|
+
|
|
221
|
+ /* Test list_cut_position() - multi-entry list, move everything */
|
|
222
|
+ INIT_LIST_HEAD ( list );
|
|
223
|
+ INIT_LIST_HEAD ( target );
|
|
224
|
+ list_add_tail ( &list_tests[3].list, list );
|
|
225
|
+ list_add_tail ( &list_tests[5].list, list );
|
|
226
|
+ list_add_tail ( &list_tests[4].list, list );
|
|
227
|
+ list_add_tail ( &list_tests[7].list, list );
|
|
228
|
+ list_add_tail ( &list_tests[1].list, list );
|
|
229
|
+ list_cut_position ( target, list, &list_tests[1].list );
|
|
230
|
+ list_contents_ok ( list, "" );
|
|
231
|
+ list_contents_ok ( target, "35471" );
|
|
232
|
+
|
|
233
|
+ /* Test list_splice() - empty list */
|
|
234
|
+ INIT_LIST_HEAD ( list );
|
|
235
|
+ INIT_LIST_HEAD ( target );
|
|
236
|
+ list_splice ( list, target );
|
|
237
|
+ list_contents_ok ( list, "" );
|
|
238
|
+ list_contents_ok ( target, "" );
|
|
239
|
+
|
|
240
|
+ /* Test list_splice() - both lists empty */
|
|
241
|
+ INIT_LIST_HEAD ( list );
|
|
242
|
+ INIT_LIST_HEAD ( target );
|
|
243
|
+ list_splice ( list, target );
|
|
244
|
+ list_contents_ok ( target, "" );
|
|
245
|
+
|
|
246
|
+ /* Test list_splice() - source list empty */
|
|
247
|
+ INIT_LIST_HEAD ( list );
|
|
248
|
+ INIT_LIST_HEAD ( target );
|
|
249
|
+ list_add_tail ( &list_tests[1].list, target );
|
|
250
|
+ list_add_tail ( &list_tests[3].list, target );
|
|
251
|
+ list_splice ( list, &list_tests[1].list );
|
|
252
|
+ list_contents_ok ( target, "13" );
|
|
253
|
+
|
|
254
|
+ /* Test list_splice() - destination list empty */
|
|
255
|
+ INIT_LIST_HEAD ( list );
|
|
256
|
+ INIT_LIST_HEAD ( target );
|
|
257
|
+ list_add_tail ( &list_tests[6].list, list );
|
|
258
|
+ list_add_tail ( &list_tests[5].list, list );
|
|
259
|
+ list_add_tail ( &list_tests[2].list, list );
|
|
260
|
+ list_splice ( list, target );
|
|
261
|
+ list_contents_ok ( target, "652" );
|
|
262
|
+
|
|
263
|
+ /* Test list_splice() - both lists non-empty */
|
|
264
|
+ INIT_LIST_HEAD ( list );
|
|
265
|
+ INIT_LIST_HEAD ( target );
|
|
266
|
+ list_add_tail ( &list_tests[8].list, list );
|
|
267
|
+ list_add_tail ( &list_tests[4].list, list );
|
|
268
|
+ list_add_tail ( &list_tests[5].list, list );
|
|
269
|
+ list_add_tail ( &list_tests[1].list, target );
|
|
270
|
+ list_add_tail ( &list_tests[9].list, target );
|
|
271
|
+ list_splice ( list, &list_tests[1].list );
|
|
272
|
+ list_contents_ok ( target, "18459" );
|
|
273
|
+
|
|
274
|
+ /* Test list_splice_tail() - both lists empty */
|
|
275
|
+ INIT_LIST_HEAD ( list );
|
|
276
|
+ INIT_LIST_HEAD ( target );
|
|
277
|
+ list_splice_tail ( list, target );
|
|
278
|
+ list_contents_ok ( target, "" );
|
|
279
|
+
|
|
280
|
+ /* Test list_splice_tail() - source list empty */
|
|
281
|
+ INIT_LIST_HEAD ( list );
|
|
282
|
+ INIT_LIST_HEAD ( target );
|
|
283
|
+ list_add_tail ( &list_tests[5].list, target );
|
|
284
|
+ list_splice_tail ( list, &list_tests[5].list );
|
|
285
|
+ list_contents_ok ( target, "5" );
|
|
286
|
+
|
|
287
|
+ /* Test list_splice_tail() - destination list empty */
|
|
288
|
+ INIT_LIST_HEAD ( list );
|
|
289
|
+ INIT_LIST_HEAD ( target );
|
|
290
|
+ list_add_tail ( &list_tests[2].list, list );
|
|
291
|
+ list_add_tail ( &list_tests[1].list, list );
|
|
292
|
+ list_add_tail ( &list_tests[0].list, list );
|
|
293
|
+ list_splice_tail ( list, target );
|
|
294
|
+ list_contents_ok ( target, "210" );
|
|
295
|
+
|
|
296
|
+ /* Test list_splice_tail() - both lists non-empty */
|
|
297
|
+ INIT_LIST_HEAD ( list );
|
|
298
|
+ INIT_LIST_HEAD ( target );
|
|
299
|
+ list_add_tail ( &list_tests[9].list, list );
|
|
300
|
+ list_add_tail ( &list_tests[5].list, list );
|
|
301
|
+ list_add_tail ( &list_tests[7].list, list );
|
|
302
|
+ list_add_tail ( &list_tests[2].list, target );
|
|
303
|
+ list_add_tail ( &list_tests[4].list, target );
|
|
304
|
+ list_splice_tail ( list, &list_tests[2].list );
|
|
305
|
+ list_contents_ok ( target, "95724" );
|
|
306
|
+
|
|
307
|
+ /* Test list_splice_init() */
|
|
308
|
+ INIT_LIST_HEAD ( list );
|
|
309
|
+ INIT_LIST_HEAD ( target );
|
|
310
|
+ list_add_tail ( &list_tests[4].list, list );
|
|
311
|
+ list_add_tail ( &list_tests[1].list, target );
|
|
312
|
+ list_splice_init ( list, target );
|
|
313
|
+ ok ( list_empty ( list ) );
|
|
314
|
+ list_contents_ok ( list, "" );
|
|
315
|
+ list_contents_ok ( target, "41" );
|
|
316
|
+
|
|
317
|
+ /* Test list_splice_tail_init() */
|
|
318
|
+ INIT_LIST_HEAD ( list );
|
|
319
|
+ INIT_LIST_HEAD ( target );
|
|
320
|
+ list_add_tail ( &list_tests[3].list, list );
|
|
321
|
+ list_add_tail ( &list_tests[2].list, list );
|
|
322
|
+ list_add_tail ( &list_tests[5].list, target );
|
|
323
|
+ list_splice_tail_init ( list, &list_tests[5].list );
|
|
324
|
+ ok ( list_empty ( list ) );
|
|
325
|
+ list_contents_ok ( list, "" );
|
|
326
|
+ list_contents_ok ( target, "325" );
|
|
327
|
+
|
156
|
328
|
/* Test list_entry() */
|
157
|
329
|
INIT_LIST_HEAD ( &list_tests[3].list ); // for list_check()
|
158
|
330
|
ok ( list_entry ( &list_tests[3].list, struct list_test, list )
|