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
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
|
/*
COLLECTION LIBRARY
Collection unit test.
Copyright (C) Dmitri Pal <dpal@redhat.com> 2009
Collection Library is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Collection Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with Collection Library. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdio.h>
#include <string.h>
#include <errno.h>
#define TRACE_HOME
#include "trace.h"
#include "collection.h"
#include "collection_tools.h"
int ref_collection_test()
{
struct collection_item *peer;
struct collection_item *socket;
char binary_dump[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8 };
int error = EOK;
TRACE_FLOW_STRING("ref_collection_test","Entry.");
printf("\n\nREF TEST!!!.\n\n\n");
printf("Creating PEER collection.\n");
if((error=create_collection(&peer,"peer",0)) ||
(error=add_str_property(peer,NULL,"hostname","peerhost.mytest.com",0)) ||
(error=add_str_property(peer,NULL,"IPv4","10.10.10.10",12)) || /* Expect trailing zero to be truncated */
(error=add_str_property(peer,NULL,"IPv6","bla:bla:bla:bla:bla:bla",0))) {
printf("Failed to add property. Error %d",error);
destroy_collection(peer);
return error;
}
printf("Creating SOCKET collection.\n");
if((error=create_collection(&socket,"socket",0)) ||
(error=add_int_property(socket,NULL,"id",1)) ||
(error=add_long_property(socket,NULL,"packets",100000000L)) ||
(error=add_binary_property(socket,NULL,"stack",binary_dump,sizeof(binary_dump)))) {
destroy_collection(peer);
destroy_collection(socket);
printf("Failed to add property. Error %d\n",error);
return error;
}
debug_collection(socket,COL_TRAVERSE_DEFAULT);
debug_collection(peer,COL_TRAVERSE_DEFAULT);
printf("Adding PEER collection to SOCKET collection as a reference named PEER\n");
/* Embed peer host into the socket2 as reference */
error = add_collection_to_collection(socket,NULL,"peer",peer,COL_ADD_MODE_REFERENCE);
if(error) {
destroy_collection(peer);
destroy_collection(socket);
printf("Failed to add collection to collection. Error %d\n",error);
return error;
}
debug_collection(socket,COL_TRAVERSE_DEFAULT);
debug_collection(peer,COL_TRAVERSE_DEFAULT);
printf("About to destroy PEER\n");
destroy_collection(peer);
debug_collection(socket,COL_TRAVERSE_DEFAULT);
printf("About to extract PEER\n");
error = get_collection_reference(socket,&peer,"peer");
if(error) {
destroy_collection(socket);
printf("Failed to extract collection. Error %d\n",error);
return error;
}
debug_collection(socket,COL_TRAVERSE_DEFAULT);
debug_collection(peer,COL_TRAVERSE_DEFAULT);
destroy_collection(peer);
debug_collection(socket,COL_TRAVERSE_DEFAULT);
destroy_collection(socket);
TRACE_FLOW_NUMBER("ref_collection_test. Returning",error);
printf("\n\nEND OF REF TEST!!!.\n\n\n");
return error;
}
int single_collection_test()
{
struct collection_item *handle;
int error = EOK;
TRACE_FLOW_STRING("single_collection_test","Entry.");
if((error=create_collection(&handle,"string_test",0)) ||
(error=add_str_property(handle,NULL,"property_1","some data",0)) ||
(error=add_str_property(handle,NULL,"property_2","some other data",2)) ||
(error=add_str_property(handle,NULL,"property_3","more data",7))) {
printf("Failed to add property. Error %d",error);
destroy_collection(handle);
return error;
}
error = add_str_property(handle,NULL,"property 1","some data",0);
if(error) printf("Expected error adding bad property to collection %d\n",error);
else {
printf("Expected error but got success\n");
return -1;
}
error=add_double_property(handle,NULL,"double",0.253545);
if(error) {
printf("Failed to add property. Error %d",error);
destroy_collection(handle);
return error;
}
error=update_double_property(handle,"double",COL_TRAVERSE_DEFAULT,1.999999);
if(error) {
printf("Failed to add property. Error %d",error);
destroy_collection(handle);
return error;
}
printf("Created collection\n");
/* Traverse collection */
error = debug_collection(handle,COL_TRAVERSE_DEFAULT);
if(error) {
printf("Error debugging collection %d\n",error);
return error;
}
error = print_collection(handle);
if(error) {
printf("Error printing collection %d\n",error);
return error;
}
destroy_collection(handle);
TRACE_FLOW_NUMBER("single_collection_test. Error: ",error);
return error;
}
int add_collection_test()
{
struct collection_item *peer;
struct collection_item *socket;
char binary_dump[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8 };
int error = EOK;
TRACE_FLOW_STRING("add_collection_test","Entry.");
printf("\n\nADD TEST!!!.\n\n\n");
printf("Creating PEER collection.\n");
if((error=create_collection(&peer,"peer",0)) ||
(error=add_str_property(peer,NULL,"hostname","peerhost.mytest.com",0)) ||
(error=add_str_property(peer,NULL,"IPv4","10.10.10.10",12)) || /* Expect trailing zero to be truncated */
(error=add_str_property(peer,NULL,"IPv6","bla:bla:bla:bla:bla:bla",0))) {
printf("Failed to add property. Error %d",error);
destroy_collection(peer);
return error;
}
printf("Creating SOCKET collection.\n");
if((error=create_collection(&socket,"socket",0)) ||
(error=add_int_property(socket,NULL,"id",1)) ||
(error=add_long_property(socket,NULL,"packets",100000000L)) ||
(error=add_binary_property(socket,NULL,"stack",binary_dump,sizeof(binary_dump)))) {
destroy_collection(peer);
destroy_collection(socket);
printf("Failed to add property. Error %d\n",error);
return error;
}
debug_collection(socket,COL_TRAVERSE_DEFAULT);
debug_collection(peer,COL_TRAVERSE_DEFAULT);
printf("Adding PEER collection to SOCKET collection as a reference named PEER\n");
/* Embed peer host into the socket2 as reference */
error = add_collection_to_collection(socket,NULL,"peer",peer,COL_ADD_MODE_REFERENCE);
if(error) {
destroy_collection(peer);
destroy_collection(socket);
printf("Failed to create collection. Error %d\n",error);
return error;
}
debug_collection(socket,COL_TRAVERSE_DEFAULT);
debug_collection(peer,COL_TRAVERSE_DEFAULT);
destroy_collection(peer);
debug_collection(socket,COL_TRAVERSE_DEFAULT);
destroy_collection(socket);
TRACE_FLOW_NUMBER("add_collection_test. Returning",error);
return error;
}
int mixed_collection_test()
{
struct collection_item *peer;
struct collection_item *socket1;
struct collection_item *socket2;
struct collection_item *event;
struct collection_item *host;
char binary_dump[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8 };
int found = 0;
unsigned int class = 0;
int error = EOK;
TRACE_FLOW_STRING("mixed_collection_test","Entry.");
printf("\n\nMIXED TEST!!!.\n\n\n");
printf("Creating PEER collection.\n");
if((error=create_collection(&peer,"peer",0)) ||
(error=add_str_property(peer,NULL,"hostname","peerhost.mytest.com",0)) ||
(error=add_str_property(peer,NULL,"IPv4","10.10.10.10",12)) || /* Expect trailing zero to be truncated */
(error=add_str_property(peer,NULL,"IPv6","bla:bla:bla:bla:bla:bla",0))) {
printf("Failed to add property. Error %d",error);
destroy_collection(peer);
return error;
}
debug_collection(peer,COL_TRAVERSE_DEFAULT);
printf("Creating HOST collection.\n");
if((error=create_collection(&host,"host",0)) ||
(error=add_str_property(host,NULL,"hostname","myhost.mytest.com",0)) ||
(error=add_str_property(host,NULL,"IPv4","20.20.20.20",13)) ||
(error=add_str_property(host,NULL,"IPv6","bla:bla:bla:bla:bla:bla",0)) ||
(error=add_double_property(host,NULL,"double",0.253545))) {
printf("Failed to add property. Error %d",error);
destroy_collection(peer);
destroy_collection(host);
return error;
}
debug_collection(host,COL_TRAVERSE_DEFAULT);
printf("Creating SOCKET1 collection.\n");
if((error=create_collection(&socket1,"socket1",0)) ||
(error=add_int_property(socket1,NULL,"id",1)) ||
(error=add_long_property(socket1,NULL,"packets",100000000L)) ||
(error=add_binary_property(socket1,NULL,"stack",binary_dump,sizeof(binary_dump)))) {
destroy_collection(peer);
destroy_collection(host);
destroy_collection(socket1);
printf("Failed to add property. Error %d\n",error);
return error;
}
debug_collection(socket1,COL_TRAVERSE_DEFAULT);
printf("Creating a copy of SOCKET1 collection named SOCKET2.\n");
error = copy_collection(&socket2,socket1,"socket2");
if(error) {
destroy_collection(peer);
destroy_collection(host);
destroy_collection(socket1);
printf("Failed to copy collection. Error %d\n",error);
return error;
}
debug_collection(socket2,COL_TRAVERSE_DEFAULT);
debug_collection(peer,COL_TRAVERSE_DEFAULT);
printf("Adding PEER collection to SOCKET2 collection as a reference named PEER2\n");
/* Embed peer host into the socket2 as reference */
error = add_collection_to_collection(socket2,NULL,"peer2",peer,COL_ADD_MODE_REFERENCE);
if(error) {
destroy_collection(peer);
destroy_collection(host);
destroy_collection(socket1);
destroy_collection(socket2);
printf("Failed to create collection. Error %d\n",error);
return error;
}
debug_collection(socket2,COL_TRAVERSE_DEFAULT);
printf("Creating an EVENT collection.\n");
/* Construct event */
error = create_collection(&event,"event",0);
if(error) {
destroy_collection(peer);
destroy_collection(host);
destroy_collection(socket1);
destroy_collection(socket2);
printf("Failed to create collection. Error %d\n",error);
return error;
}
debug_collection(event,COL_TRAVERSE_DEFAULT);
printf("Adding HOST to EVENT.\n");
/* Add host to event */
error = add_collection_to_collection(event,NULL,NULL,host,COL_ADD_MODE_REFERENCE);
if(error) {
destroy_collection(peer);
destroy_collection(host);
destroy_collection(socket1);
destroy_collection(socket2);
printf("Failed to add collections. Error %d\n",error);
return error;
}
debug_collection(event,COL_TRAVERSE_DEFAULT);
printf("Embed SOCKET1 into EVENT.\n");
/* Donate socket1 to event */
/* Socket1 should not be used after this */
error = add_collection_to_collection(event,NULL,NULL,socket1,COL_ADD_MODE_EMBED);
if(error) {
destroy_collection(peer);
destroy_collection(host);
destroy_collection(socket1);
destroy_collection(socket2);
printf("Failed to add collections. Error %d\n",error);
return error;
}
printf("Traverse one level:\n");
debug_collection(event,COL_TRAVERSE_ONELEVEL);
printf("Traverse ignore subcollections:\n");
debug_collection(event,COL_TRAVERSE_IGNORE);
printf("Traverse normal:\n");
debug_collection(event,COL_TRAVERSE_DEFAULT);
debug_collection(socket1,COL_TRAVERSE_DEFAULT);
printf("SOCKET1 MUST NO BE USED AFTER THIS POINT!!!\n");
socket1 = (struct collection_item *)(NULL);
printf("Add collection PEER as PEER1 to subcollection SOCKET1 of the EVENT.\n");
debug_collection(peer,COL_TRAVERSE_DEFAULT);
error = add_collection_to_collection(event,"socket1","peer1",peer,COL_ADD_MODE_CLONE);
if(error) {
destroy_collection(peer);
destroy_collection(host);
/* No socket1 any more :) */
destroy_collection(socket2);
printf("Failed to add collections. Error %d\n",error);
return error;
}
debug_collection(event,COL_TRAVERSE_DEFAULT);
printf("Add property named TIMEOUT to PEER collection.\n");
/* Add new property to the peer collection */
error = add_int_property(peer,NULL,"timeout",5);
if(error) {
destroy_collection(peer);
destroy_collection(host);
/* No socket1 any more :) */
destroy_collection(socket2);
printf("Failed to add property. Error %d\n",error);
return error;
}
debug_collection(socket2,COL_TRAVERSE_DEFAULT);
printf("Add property named DELAY to PEER1 collection.\n");
error = add_int_property(event,"peer1","delay",10);
if(error) {
destroy_collection(peer);
destroy_collection(host);
/* No socket1 any more :) */
destroy_collection(socket2);
printf("Failed to add property. Error %d\n",error);
return error;
}
debug_collection(event,COL_TRAVERSE_DEFAULT);
debug_collection(host,COL_TRAVERSE_DEFAULT);
printf("Check if property PEER1.DELAY is in the EVENT collection.\n");
/* Check if the property in the collection */
found = 0;
error = is_item_in_collection(event, "peer1.delay", COL_TYPE_ANY, COL_TRAVERSE_DEFAULT, &found);
if(error) {
destroy_collection(peer);
destroy_collection(host);
/* No socket1 any more :) */
destroy_collection(socket2);
printf("Failed to check property. Error %d\n",error);
return error;
}
if (found == 1) printf("Property is found!\n");
else printf("Error property is not found!\n");
print_item(event, "peer1.IPv6");
print_item(event, "event.socket1.peer1.IPv6");
print_item(event, "event.peer1.IPv6");
print_item(event, "speer1.IPv6");
print_item(event, "eer1.IPv6");
print_item(event, ".peer1.IPv6");
print_item(event, "t.peer1.IPv6");
/* Traverse collection */
error = print_collection2(event);
if(error) {
printf("Error printing collection %d\n",error);
return error;
}
printf("Delete property PEER1.DELAY from the EVENT collection.\n");
error = delete_property(event,"peer1.delay",COL_TYPE_ANY, COL_TRAVERSE_DEFAULT);
if(error) {
destroy_collection(peer);
destroy_collection(host);
/* No socket1 any more :) */
destroy_collection(socket2);
printf("Failed to delete property. Error %d\n",error);
return error;
}
printf("Printing EVENT.\n");
/* Traverse collection */
error = print_collection2(event);
if(error) {
printf("Error printing collection %d\n",error);
return error;
}
printf("Debugging EVENT.\n");
error = debug_collection(event,COL_TRAVERSE_DEFAULT);
if(error) {
printf("Error printing collection %d\n",error);
return error;
}
printf("Cleanup of the collections PEER, HOST and SOCKET2.\n");
/* Destroy a referenced collection */
destroy_collection(peer);
destroy_collection(host);
destroy_collection(socket2);
printf("Printing EVENT again.\n");
/* Traverse collection again - peer should still be there */
error = print_collection(event);
if(error) {
printf("Error printing collection %d\n",error);
return error;
}
printf("Debugging EVENT again.\n");
error = debug_collection(event,COL_TRAVERSE_DEFAULT);
if(error) {
printf("Error printing collection %d\n",error);
return error;
}
printf("Attempt to add property to a referenced collection.\n");
/* Some negative tests */
/* Can't add attributes to the referenced collection */
error = add_int_property(event,"host","session",500);
if(error != 0) printf("Error was NOT able to add property to a referenced collection.\n");
else {
printf("Unexpected success which is an implementation error.\n");
return error;
}
printf("Attempt to delete non-existent property.\n");
/* Can't delete non exitent property */
error = delete_property(event,"host.host",COL_TYPE_ANY, COL_TRAVERSE_DEFAULT);
if(error == 0) {
printf("Error was able to delete property that does not exist.\n");
return -1;
}
else printf("Expected error %d\n",error);
/* Set collection class */
error = set_collection_class(event,2);
if(error != 0) {
printf("Error was NOT able to set class.\n");
return error;
}
error = get_collection_class(event,&class);
if(error != 0) {
printf("Error was NOT able to get class.\n");
return error;
}
else printf("Class = %d\n",class);
if(is_of_class(event,2)) printf("Class mathced!\n");
else {
printf("Error - bad class.\n");
return -1;
}
printf("Done. Cleaning...\n");
destroy_collection(event);
printf("Exit.\n");
TRACE_FLOW_NUMBER("add_collection_test. Returning",EOK);
return EOK;
}
int iterator_test()
{
struct collection_item *peer;
struct collection_item *socket1;
struct collection_item *socket2;
struct collection_iterator *iterator = (struct collection_iterator *)(NULL);
int error = EOK;
struct collection_item *item = (struct collection_item *)(NULL);
char binary_dump[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8 };
int depth = 0;
printf("\n\n==== ITERATOR TEST ====\n\n");
if((error=create_collection(&peer,"peer",0)) ||
(error=add_str_property(peer,NULL,"hostname","peerhost.mytest.com",0)) ||
(error=add_str_property(peer,NULL,"IPv4","10.10.10.10",12)) || /* Expect trailing zero to be truncated */
(error=add_str_property(peer,NULL,"IPv6","bla:bla:bla:bla:bla:bla",0))) {
printf("Failed to add property. Error %d",error);
destroy_collection(peer);
return error;
}
if((error=create_collection(&socket1,"socket",0)) ||
(error=add_int_property(socket1,NULL,"id",1)) ||
(error=add_long_property(socket1,NULL,"packets",100000000L)) ||
(error=add_binary_property(socket1,NULL,"stack",binary_dump,sizeof(binary_dump)))) {
destroy_collection(peer);
destroy_collection(socket1);
printf("Failed to add property. Error %d\n",error);
return error;
}
if((error=create_collection(&socket2,"socket",0)) ||
(error=add_int_property(socket2,NULL,"id",2)) ||
(error=add_long_property(socket2,NULL,"packets",200000000L)) ||
(error=add_binary_property(socket2,NULL,"queue",binary_dump,sizeof(binary_dump)))) {
destroy_collection(peer);
destroy_collection(socket1);
destroy_collection(socket2);
printf("Failed to add property. Error %d\n",error);
return error;
}
error = add_collection_to_collection(peer,NULL,"first",socket1,COL_ADD_MODE_EMBED);
if(error) {
destroy_collection(peer);
destroy_collection(socket1);
destroy_collection(socket2);
printf("Failed to add collection to collection. Error %d\n",error);
return error;
}
error = add_collection_to_collection(peer,NULL,"second",socket2,COL_ADD_MODE_EMBED);
if(error) {
destroy_collection(peer);
destroy_collection(socket2);
printf("Failed to add collection to collection. Error %d\n",error);
return error;
}
/* Bind iterator */
error = bind_iterator(&iterator,peer,COL_TRAVERSE_DEFAULT);
if(error) {
printf("Error (bind): %d\n",error);
destroy_collection(peer);
return error;
}
printf("\n\nCollection:\n\n");
debug_collection(peer,COL_TRAVERSE_DEFAULT);
/* This should also work becuase iterator holds to collection */
destroy_collection(peer);
printf("\n\nIteration:\n\n");
do {
depth = 0;
get_iterator_depth(iterator,&depth);
/* Loop through a collection */
error = iterate_collection(iterator, &item);
if(error) {
printf("Error (iterate): %d\n",error);
unbind_iterator(iterator);
return error;
}
/* Are we done ? */
if(item == (struct collection_item *)(NULL)) break;
printf("%*s Property (%s), type = %d, data size = %d\n",
depth * 4, "",
get_item_property(item,NULL),
get_item_type(item),
get_item_length(item));
if((strcmp(get_item_property(item,NULL),"id")==0) &&
(*((int *)(get_item_data(item))) == 1)) {
printf("\n\nFound property we need - go up!!!\n\n\n");
error = iterate_up(iterator,5);
if(!error) {
printf("We expected error but got seucces - bad.\n");
unbind_iterator(iterator);
return -1;
}
/* This should work! */
error = iterate_up(iterator,1);
if(error) {
printf("We expected success but got error %d\n",error);
unbind_iterator(iterator);
return error;
}
if((error = modify_str_item(item,"id2","test",0)) ||
(error = debug_item(item)) ||
(error = modify_str_item(item,NULL,"test",2)) ||
(error = debug_item(item)) ||
(error = modify_binary_item(item,NULL,binary_dump,sizeof(binary_dump))) ||
(error = debug_item(item)) ||
(error = modify_bool_item(item,NULL,1)) ||
(error = debug_item(item)) ||
(error = modify_int_item(item,"int",1)) ||
(error = debug_item(item)) ||
(error = modify_long_item(item,"long",1000000000L)) ||
(error = debug_item(item)) ||
(error = modify_ulong_item(item,"ulong",4000000000UL)) ||
(error = debug_item(item)) ||
(error = modify_unsigned_item(item,"unsigned",4000000000U)) ||
(error = debug_item(item)) ||
(error = modify_double_item(item,"double",-1.1)) ||
(error = debug_item(item))) {
printf("Failed to change property.\n");
return error;
}
}
}
while(1);
/* Do not forget to unbind iterator - otherwise there will be a leak */
unbind_iterator(iterator);
return EOK;
}
/* Main function of the unit test */
int main()
{
int error = 0;
printf("Start\n");
if((error=ref_collection_test()) ||
(error=single_collection_test()) ||
(error=add_collection_test()) ||
(error=mixed_collection_test()) ||
(error=iterator_test())) {
printf("Failed!\n");
}
else printf("Success!\n");
/* Add other tests here ... */
return error;
}
|