| 1 | /*************************************************************************** |
|---|
| 2 | * Copyright (c) 2003, Broadcom Corporation |
|---|
| 3 | * All Rights Reserved |
|---|
| 4 | * Confidential Property of Broadcom Corporation |
|---|
| 5 | * |
|---|
| 6 | * THIS SOFTWARE MAY ONLY BE USED SUBJECT TO AN EXECUTED SOFTWARE LICENSE |
|---|
| 7 | * AGREEMENT BETWEEN THE USER AND BROADCOM. YOU HAVE NO RIGHT TO USE OR |
|---|
| 8 | * EXPLOIT THIS MATERIAL EXCEPT SUBJECT TO THE TERMS OF SUCH AN AGREEMENT. |
|---|
| 9 | * |
|---|
| 10 | * $brcm_Workfile: list_test.c $ |
|---|
| 11 | * $brcm_Revision: Hydra_Software_Devel/6 $ |
|---|
| 12 | * $brcm_Date: 1/15/04 11:27a $ |
|---|
| 13 | * |
|---|
| 14 | * Module Description: |
|---|
| 15 | * |
|---|
| 16 | * Revision History: |
|---|
| 17 | * |
|---|
| 18 | * $brcm_Log: /magnum/commonutils/lst/test/list_test.c $ |
|---|
| 19 | * |
|---|
| 20 | * Hydra_Software_Devel/6 1/15/04 11:27a vsilyaev |
|---|
| 21 | * PR 9321: Added test for BLST_Q_INSERT_TAIL |
|---|
| 22 | * |
|---|
| 23 | * Hydra_Software_Devel/5 12/11/03 4:24p vsilyaev |
|---|
| 24 | * PR 8559: Added test for BLST_SQ_INSERT_TAIL |
|---|
| 25 | * |
|---|
| 26 | * Hydra_Software_Devel/4 10/14/03 10:15a vsilyaev |
|---|
| 27 | * Added tests for the circular queue |
|---|
| 28 | * |
|---|
| 29 | * Hydra_Software_Devel/3 3/17/03 7:35p vsilyaev |
|---|
| 30 | * Include bkni.h only once. Changed deinitialization order. |
|---|
| 31 | * |
|---|
| 32 | * Hydra_Software_Devel/2 3/17/03 2:17p vsilyaev |
|---|
| 33 | * Added new private functions. |
|---|
| 34 | * |
|---|
| 35 | * Hydra_Software_Devel/1 3/14/03 7:51p vsilyaev |
|---|
| 36 | * Linked list test module. |
|---|
| 37 | * |
|---|
| 38 | ***************************************************************************/ |
|---|
| 39 | |
|---|
| 40 | #include "bstd.h" |
|---|
| 41 | #include "bkni.h" |
|---|
| 42 | |
|---|
| 43 | #include "blst_list.h" |
|---|
| 44 | #include "blst_queue.h" |
|---|
| 45 | #include "blst_slist.h" |
|---|
| 46 | #include "blst_squeue.h" |
|---|
| 47 | #include "blst_circleq.h" |
|---|
| 48 | |
|---|
| 49 | |
|---|
| 50 | |
|---|
| 51 | const static int data_set[] = |
|---|
| 52 | { |
|---|
| 53 | /* some random sequence */ |
|---|
| 54 | 1, 5, 7, 9, 10, 23, 45, 200, 12, 14, 78, 90, 1023, 343, 12, 14, 19, 1323, 932, 34, 544, 6346, 634 |
|---|
| 55 | }; |
|---|
| 56 | #define DATA_SET_LEN (sizeof(data_set)/sizeof(*data_set)) |
|---|
| 57 | |
|---|
| 58 | #define TEST_FAILED(name) BKNI_Printf("test '%s' failed at %s:%d\n", #name, __FILE__, __LINE__) |
|---|
| 59 | |
|---|
| 60 | |
|---|
| 61 | /* start of the test for singly-linked list */ |
|---|
| 62 | |
|---|
| 63 | #define LST_HEAD BLST_S_HEAD |
|---|
| 64 | #define LST_ENTRY BLST_S_ENTRY |
|---|
| 65 | #define LST_INIT BLST_S_INIT |
|---|
| 66 | #define LST_INITIALIZER BLST_S_INITIALIZER |
|---|
| 67 | #define LST_EMPTY BLST_S_EMPTY |
|---|
| 68 | #define LST_FIRST BLST_S_FIRST |
|---|
| 69 | #define LST_NEXT BLST_S_NEXT |
|---|
| 70 | #define LST_INSERT_HEAD BLST_S_INSERT_HEAD |
|---|
| 71 | #define LST_INSERT_AFTER BLST_S_INSERT_AFTER |
|---|
| 72 | #define LST_REMOVE_HEAD BLST_S_REMOVE_HEAD |
|---|
| 73 | |
|---|
| 74 | #define data sl_data |
|---|
| 75 | #define data_head sl_data_head |
|---|
| 76 | #define list_populate sl_list_populate |
|---|
| 77 | #define list_populate2 sl_list_populate2 |
|---|
| 78 | #define list_destroy sl_list_destroy |
|---|
| 79 | #define list_compare_content sl_list_compare_content |
|---|
| 80 | #define list_compare_content2 sl_list_compare_content2 |
|---|
| 81 | #define list_test sl_list_test |
|---|
| 82 | #define list_name "singly-linked list" |
|---|
| 83 | |
|---|
| 84 | |
|---|
| 85 | #include "list_test.inc" |
|---|
| 86 | |
|---|
| 87 | #undef LST_HEAD |
|---|
| 88 | #undef LST_ENTRY |
|---|
| 89 | #undef LST_INIT |
|---|
| 90 | #undef LST_INITIALIZER |
|---|
| 91 | #undef LST_EMPTY |
|---|
| 92 | #undef LST_FIRST |
|---|
| 93 | #undef LST_NEXT |
|---|
| 94 | #undef LST_INSERT_HEAD |
|---|
| 95 | #undef LST_INSERT_AFTER |
|---|
| 96 | #undef LST_REMOVE_HEAD |
|---|
| 97 | |
|---|
| 98 | #undef data |
|---|
| 99 | #undef data_head |
|---|
| 100 | #undef list_populate |
|---|
| 101 | #undef list_populate2 |
|---|
| 102 | #undef list_destroy |
|---|
| 103 | #undef list_compare_content |
|---|
| 104 | #undef list_compare_content2 |
|---|
| 105 | #undef list_test |
|---|
| 106 | #undef list_name |
|---|
| 107 | |
|---|
| 108 | /* start of the test for doubly linked list */ |
|---|
| 109 | |
|---|
| 110 | #define LST_HEAD BLST_D_HEAD |
|---|
| 111 | #define LST_ENTRY BLST_D_ENTRY |
|---|
| 112 | #define LST_INIT BLST_D_INIT |
|---|
| 113 | #define LST_INITIALIZER BLST_D_INITIALIZER |
|---|
| 114 | #define LST_EMPTY BLST_D_EMPTY |
|---|
| 115 | #define LST_FIRST BLST_D_FIRST |
|---|
| 116 | #define LST_NEXT BLST_D_NEXT |
|---|
| 117 | #define LST_INSERT_HEAD BLST_D_INSERT_HEAD |
|---|
| 118 | #define LST_INSERT_AFTER BLST_D_INSERT_AFTER |
|---|
| 119 | #define LST_REMOVE_HEAD BLST_D_REMOVE_HEAD |
|---|
| 120 | |
|---|
| 121 | #define data l_data |
|---|
| 122 | #define data_head l_data_head |
|---|
| 123 | #define list_populate l_list_populate |
|---|
| 124 | #define list_populate2 l_list_populate2 |
|---|
| 125 | #define list_destroy l_list_destroy |
|---|
| 126 | #define list_compare_content l_list_compare_content |
|---|
| 127 | #define list_compare_content2 l_list_compare_content2 |
|---|
| 128 | #define list_test l_list_test |
|---|
| 129 | #define list_name "doubly linked list" |
|---|
| 130 | |
|---|
| 131 | #include "list_test.inc" |
|---|
| 132 | |
|---|
| 133 | #undef LST_HEAD |
|---|
| 134 | #undef LST_ENTRY |
|---|
| 135 | #undef LST_INIT |
|---|
| 136 | #undef LST_INITIALIZER |
|---|
| 137 | #undef LST_EMPTY |
|---|
| 138 | #undef LST_FIRST |
|---|
| 139 | #undef LST_NEXT |
|---|
| 140 | #undef LST_INSERT_HEAD |
|---|
| 141 | #undef LST_INSERT_AFTER |
|---|
| 142 | #undef LST_REMOVE_HEAD |
|---|
| 143 | |
|---|
| 144 | #undef data |
|---|
| 145 | #undef data_head |
|---|
| 146 | #undef list_populate |
|---|
| 147 | #undef list_populate2 |
|---|
| 148 | #undef list_destroy |
|---|
| 149 | #undef list_compare_content |
|---|
| 150 | #undef list_compare_content2 |
|---|
| 151 | #undef list_test |
|---|
| 152 | #undef list_name |
|---|
| 153 | |
|---|
| 154 | /* start of the test for singly-linked queue */ |
|---|
| 155 | |
|---|
| 156 | |
|---|
| 157 | #define LST_HEAD BLST_SQ_HEAD |
|---|
| 158 | #define LST_ENTRY BLST_SQ_ENTRY |
|---|
| 159 | #define LST_INIT BLST_SQ_INIT |
|---|
| 160 | #define LST_INITIALIZER BLST_SQ_INITIALIZER |
|---|
| 161 | #define LST_EMPTY BLST_SQ_EMPTY |
|---|
| 162 | #define LST_FIRST BLST_SQ_FIRST |
|---|
| 163 | #define LST_NEXT BLST_SQ_NEXT |
|---|
| 164 | #define LST_INSERT_HEAD BLST_SQ_INSERT_HEAD |
|---|
| 165 | #define LST_INSERT_AFTER BLST_SQ_INSERT_AFTER |
|---|
| 166 | #define LST_REMOVE_HEAD BLST_SQ_REMOVE_HEAD |
|---|
| 167 | |
|---|
| 168 | #define data sq_data |
|---|
| 169 | #define data_head sq_data_head |
|---|
| 170 | #define list_populate sq_list_populate |
|---|
| 171 | #define list_populate2 sq_list_populate2 |
|---|
| 172 | #define list_destroy sq_list_destroy |
|---|
| 173 | #define list_compare_content sq_list_compare_content |
|---|
| 174 | #define list_compare_content2 sq_list_compare_content2 |
|---|
| 175 | #define list_test sq_list_test |
|---|
| 176 | #define list_name "singly-linked queue" |
|---|
| 177 | |
|---|
| 178 | |
|---|
| 179 | #include "list_test.inc" |
|---|
| 180 | |
|---|
| 181 | #undef LST_HEAD |
|---|
| 182 | #undef LST_ENTRY |
|---|
| 183 | #undef LST_INIT |
|---|
| 184 | #undef LST_INITIALIZER |
|---|
| 185 | #undef LST_EMPTY |
|---|
| 186 | #undef LST_FIRST |
|---|
| 187 | #undef LST_NEXT |
|---|
| 188 | #undef LST_INSERT_HEAD |
|---|
| 189 | #undef LST_INSERT_AFTER |
|---|
| 190 | #undef LST_REMOVE_HEAD |
|---|
| 191 | |
|---|
| 192 | #undef data |
|---|
| 193 | #undef data_head |
|---|
| 194 | #undef list_populate |
|---|
| 195 | #undef list_populate2 |
|---|
| 196 | #undef list_destroy |
|---|
| 197 | #undef list_compare_content |
|---|
| 198 | #undef list_compare_content2 |
|---|
| 199 | #undef list_test |
|---|
| 200 | #undef list_name |
|---|
| 201 | |
|---|
| 202 | |
|---|
| 203 | /* start of the test for doubly linked queue */ |
|---|
| 204 | |
|---|
| 205 | #define LST_HEAD BLST_Q_HEAD |
|---|
| 206 | #define LST_ENTRY BLST_Q_ENTRY |
|---|
| 207 | #define LST_INIT BLST_Q_INIT |
|---|
| 208 | #define LST_INITIALIZER BLST_Q_INITIALIZER |
|---|
| 209 | #define LST_EMPTY BLST_Q_EMPTY |
|---|
| 210 | #define LST_FIRST BLST_Q_FIRST |
|---|
| 211 | #define LST_NEXT BLST_Q_NEXT |
|---|
| 212 | #define LST_INSERT_HEAD BLST_Q_INSERT_HEAD |
|---|
| 213 | #define LST_INSERT_AFTER BLST_Q_INSERT_AFTER |
|---|
| 214 | #define LST_REMOVE_HEAD BLST_Q_REMOVE_HEAD |
|---|
| 215 | |
|---|
| 216 | #define data q_data |
|---|
| 217 | #define data_head q_data_head |
|---|
| 218 | #define list_populate q_list_populate |
|---|
| 219 | #define list_populate2 q_list_populate2 |
|---|
| 220 | #define list_destroy q_list_destroy |
|---|
| 221 | #define list_compare_content q_list_compare_content |
|---|
| 222 | #define list_compare_content2 q_list_compare_content2 |
|---|
| 223 | #define list_test q_list_test |
|---|
| 224 | #define list_name "doubly linked queue" |
|---|
| 225 | |
|---|
| 226 | |
|---|
| 227 | #include "list_test.inc" |
|---|
| 228 | |
|---|
| 229 | #undef LST_HEAD |
|---|
| 230 | #undef LST_ENTRY |
|---|
| 231 | #undef LST_INIT |
|---|
| 232 | #undef LST_INITIALIZER |
|---|
| 233 | #undef LST_EMPTY |
|---|
| 234 | #undef LST_FIRST |
|---|
| 235 | #undef LST_NEXT |
|---|
| 236 | #undef LST_INSERT_HEAD |
|---|
| 237 | #undef LST_INSERT_AFTER |
|---|
| 238 | #undef LST_REMOVE_HEAD |
|---|
| 239 | |
|---|
| 240 | #undef data |
|---|
| 241 | #undef data_head |
|---|
| 242 | #undef list_populate |
|---|
| 243 | #undef list_populate2 |
|---|
| 244 | #undef list_destroy |
|---|
| 245 | #undef list_compare_content |
|---|
| 246 | #undef list_compare_content2 |
|---|
| 247 | #undef list_test |
|---|
| 248 | #undef list_name |
|---|
| 249 | |
|---|
| 250 | |
|---|
| 251 | typedef struct cq_data { |
|---|
| 252 | char buf1[16]; |
|---|
| 253 | BLST_CQ_ENTRY(cq_data) link; |
|---|
| 254 | int number; |
|---|
| 255 | char buf2[16]; |
|---|
| 256 | } cq_data; |
|---|
| 257 | |
|---|
| 258 | |
|---|
| 259 | typedef struct cq_data_head cq_data_head; |
|---|
| 260 | |
|---|
| 261 | BLST_CQ_HEAD(cq_data_head, cq_data); |
|---|
| 262 | |
|---|
| 263 | static void |
|---|
| 264 | cq_list_populate( cq_data_head *list) |
|---|
| 265 | { |
|---|
| 266 | cq_data *itm; |
|---|
| 267 | int i; |
|---|
| 268 | |
|---|
| 269 | for(i=0;i< DATA_SET_LEN; i++) { |
|---|
| 270 | itm = BKNI_Malloc(sizeof(*itm)); |
|---|
| 271 | BKNI_Memset(itm, 0xCD, sizeof(*itm)); /* fill with junk */ |
|---|
| 272 | itm->number = data_set[i]; |
|---|
| 273 | BLST_CQ_INSERT_HEAD(list, itm, link); |
|---|
| 274 | } |
|---|
| 275 | return; |
|---|
| 276 | } |
|---|
| 277 | |
|---|
| 278 | |
|---|
| 279 | static void |
|---|
| 280 | cq_list_populate2( cq_data_head *list) |
|---|
| 281 | { |
|---|
| 282 | cq_data *itm, *cur, *last; |
|---|
| 283 | int i; |
|---|
| 284 | |
|---|
| 285 | for(i=0;i< DATA_SET_LEN; i++) { |
|---|
| 286 | itm = BKNI_Malloc(sizeof(*itm)); |
|---|
| 287 | BKNI_Memset(itm, 0xCD, sizeof(*itm)); /* fill with junk */ |
|---|
| 288 | itm->number = data_set[i]; |
|---|
| 289 | |
|---|
| 290 | for (last=NULL, cur=BLST_CQ_FIRST(list); cur;) { |
|---|
| 291 | last=cur; |
|---|
| 292 | cur = BLST_CQ_NEXT(cur, link); |
|---|
| 293 | if (cur==BLST_CQ_FIRST(list)) { break; } |
|---|
| 294 | } |
|---|
| 295 | if (last) { |
|---|
| 296 | BLST_CQ_INSERT_AFTER(list, last, itm, link); |
|---|
| 297 | } else { |
|---|
| 298 | BLST_CQ_INSERT_HEAD(list, itm, link); |
|---|
| 299 | } |
|---|
| 300 | } |
|---|
| 301 | return; |
|---|
| 302 | } |
|---|
| 303 | |
|---|
| 304 | static void |
|---|
| 305 | cq_list_populate3( cq_data_head *list) |
|---|
| 306 | { |
|---|
| 307 | cq_data *itm; |
|---|
| 308 | int i; |
|---|
| 309 | |
|---|
| 310 | for(i=DATA_SET_LEN-1;i>0 ; i--) { |
|---|
| 311 | itm = BKNI_Malloc(sizeof(*itm)); |
|---|
| 312 | BKNI_Memset(itm, 0xCD, sizeof(*itm)); /* fill with junk */ |
|---|
| 313 | itm->number = data_set[i]; |
|---|
| 314 | BLST_CQ_INSERT_TAIL(list, itm, link); |
|---|
| 315 | } |
|---|
| 316 | return; |
|---|
| 317 | } |
|---|
| 318 | |
|---|
| 319 | static int |
|---|
| 320 | cq_list_compare_content( cq_data_head *list) |
|---|
| 321 | { |
|---|
| 322 | int i; |
|---|
| 323 | cq_data *itm; |
|---|
| 324 | |
|---|
| 325 | for(i=DATA_SET_LEN-1, itm=BLST_CQ_FIRST(list); ; i--) { |
|---|
| 326 | if (itm->number!=data_set[i]) { |
|---|
| 327 | return -1; |
|---|
| 328 | } |
|---|
| 329 | itm=BLST_CQ_NEXT(itm, link); |
|---|
| 330 | if (itm == BLST_CQ_FIRST(list)) { break; } |
|---|
| 331 | } |
|---|
| 332 | return 0; |
|---|
| 333 | } |
|---|
| 334 | |
|---|
| 335 | static int |
|---|
| 336 | cq_list_compare_content2( cq_data_head *list) |
|---|
| 337 | { |
|---|
| 338 | int i; |
|---|
| 339 | cq_data *itm; |
|---|
| 340 | |
|---|
| 341 | for(i=0, itm=BLST_CQ_FIRST(list); ; i++) { |
|---|
| 342 | if (itm->number!=data_set[i]) { |
|---|
| 343 | return -1; |
|---|
| 344 | } |
|---|
| 345 | itm=BLST_CQ_NEXT(itm, link); |
|---|
| 346 | if (itm == BLST_CQ_FIRST(list)) { break; } |
|---|
| 347 | } |
|---|
| 348 | return 0; |
|---|
| 349 | } |
|---|
| 350 | |
|---|
| 351 | |
|---|
| 352 | static void |
|---|
| 353 | cq_list_destroy( cq_data_head *list) |
|---|
| 354 | { |
|---|
| 355 | cq_data *itm; |
|---|
| 356 | |
|---|
| 357 | while( NULL!=(itm=BLST_CQ_FIRST(list))) { |
|---|
| 358 | BLST_CQ_REMOVE_HEAD(list, link); |
|---|
| 359 | BKNI_Free(itm); |
|---|
| 360 | } |
|---|
| 361 | return; |
|---|
| 362 | |
|---|
| 363 | } |
|---|
| 364 | |
|---|
| 365 | int |
|---|
| 366 | cq_list_test(void) |
|---|
| 367 | { |
|---|
| 368 | cq_data_head list1 = BLST_CQ_INITIALIZER(&list1); |
|---|
| 369 | cq_data_head list2; |
|---|
| 370 | int rc; |
|---|
| 371 | |
|---|
| 372 | BKNI_Printf("Start list_test for %s\n", "circular queue"); |
|---|
| 373 | BLST_CQ_INIT(&list2); |
|---|
| 374 | |
|---|
| 375 | cq_list_populate(&list1); |
|---|
| 376 | cq_list_populate(&list2); |
|---|
| 377 | |
|---|
| 378 | rc = cq_list_compare_content(&list1); |
|---|
| 379 | if (rc<0) { |
|---|
| 380 | TEST_FAILED(cq_list_compare_content(&list1)); |
|---|
| 381 | return rc; |
|---|
| 382 | } |
|---|
| 383 | |
|---|
| 384 | cq_list_destroy(&list1); |
|---|
| 385 | |
|---|
| 386 | rc = cq_list_compare_content(&list2); |
|---|
| 387 | if (rc<0) { |
|---|
| 388 | TEST_FAILED(cq_list_compare_content(&list2)); |
|---|
| 389 | return rc; |
|---|
| 390 | } |
|---|
| 391 | |
|---|
| 392 | cq_list_destroy(&list2); |
|---|
| 393 | |
|---|
| 394 | BKNI_Printf("."); |
|---|
| 395 | |
|---|
| 396 | cq_list_populate2(&list1); |
|---|
| 397 | cq_list_populate2(&list2); |
|---|
| 398 | |
|---|
| 399 | rc = cq_list_compare_content2(&list1); |
|---|
| 400 | if (rc<0) { |
|---|
| 401 | TEST_FAILED(cq_list_compare_content(&list1)); |
|---|
| 402 | return rc; |
|---|
| 403 | } |
|---|
| 404 | |
|---|
| 405 | cq_list_destroy(&list1); |
|---|
| 406 | |
|---|
| 407 | rc = cq_list_compare_content2(&list2); |
|---|
| 408 | if (rc<0) { |
|---|
| 409 | TEST_FAILED(cq_list_compare_content(&list2)); |
|---|
| 410 | return rc; |
|---|
| 411 | } |
|---|
| 412 | |
|---|
| 413 | cq_list_destroy(&list2); |
|---|
| 414 | |
|---|
| 415 | cq_list_populate3(&list1); |
|---|
| 416 | cq_list_populate3(&list2); |
|---|
| 417 | |
|---|
| 418 | rc = cq_list_compare_content(&list1); |
|---|
| 419 | if (rc<0) { |
|---|
| 420 | TEST_FAILED(cq_list_compare_content(&list1)); |
|---|
| 421 | return rc; |
|---|
| 422 | } |
|---|
| 423 | |
|---|
| 424 | cq_list_destroy(&list1); |
|---|
| 425 | |
|---|
| 426 | rc = cq_list_compare_content(&list2); |
|---|
| 427 | if (rc<0) { |
|---|
| 428 | TEST_FAILED(cq_list_compare_content(&list2)); |
|---|
| 429 | return rc; |
|---|
| 430 | } |
|---|
| 431 | |
|---|
| 432 | cq_list_destroy(&list2); |
|---|
| 433 | |
|---|
| 434 | |
|---|
| 435 | BKNI_Printf("."); |
|---|
| 436 | |
|---|
| 437 | BKNI_Printf("\nDone\n"); |
|---|
| 438 | |
|---|
| 439 | return 0; |
|---|
| 440 | |
|---|
| 441 | } |
|---|
| 442 | |
|---|
| 443 | static void |
|---|
| 444 | q_list_populate3( q_data_head *list) |
|---|
| 445 | { |
|---|
| 446 | q_data *itm; |
|---|
| 447 | int i; |
|---|
| 448 | |
|---|
| 449 | for(i=0;i< DATA_SET_LEN; i++) { |
|---|
| 450 | itm = BKNI_Malloc(sizeof(*itm)); |
|---|
| 451 | BKNI_Memset(itm, 0xCD, sizeof(*itm)); /* fill with junk */ |
|---|
| 452 | itm->number = data_set[i]; |
|---|
| 453 | BLST_Q_INSERT_TAIL(list, itm, link); |
|---|
| 454 | } |
|---|
| 455 | return; |
|---|
| 456 | } |
|---|
| 457 | |
|---|
| 458 | static int |
|---|
| 459 | q_list_compare_content3( q_data_head *list) |
|---|
| 460 | { |
|---|
| 461 | int i; |
|---|
| 462 | q_data *itm; |
|---|
| 463 | |
|---|
| 464 | for(i=DATA_SET_LEN-1, itm=BLST_Q_LAST(list); i>=0; itm=BLST_Q_PREV(itm, link), i--) { |
|---|
| 465 | if (itm->number!=data_set[i]) { |
|---|
| 466 | return -1; |
|---|
| 467 | } |
|---|
| 468 | } |
|---|
| 469 | return 0; |
|---|
| 470 | } |
|---|
| 471 | |
|---|
| 472 | |
|---|
| 473 | |
|---|
| 474 | int |
|---|
| 475 | q_list_test2(void) |
|---|
| 476 | { |
|---|
| 477 | q_data_head list1 = BLST_Q_INITIALIZER(&list1); |
|---|
| 478 | int rc; |
|---|
| 479 | |
|---|
| 480 | BKNI_Printf("Start list_test for %s\n", "queue2"); |
|---|
| 481 | BLST_Q_INIT(&list1); |
|---|
| 482 | |
|---|
| 483 | q_list_populate3(&list1); |
|---|
| 484 | |
|---|
| 485 | rc = q_list_compare_content2(&list1); |
|---|
| 486 | if (rc<0) { |
|---|
| 487 | TEST_FAILED(q_list_compare_content2(&list1)); |
|---|
| 488 | return rc; |
|---|
| 489 | } |
|---|
| 490 | rc = q_list_compare_content3(&list1); |
|---|
| 491 | if (rc<0) { |
|---|
| 492 | TEST_FAILED(q_list_compare_content3(&list1)); |
|---|
| 493 | return rc; |
|---|
| 494 | } |
|---|
| 495 | |
|---|
| 496 | |
|---|
| 497 | q_list_destroy(&list1); |
|---|
| 498 | |
|---|
| 499 | BKNI_Printf("."); |
|---|
| 500 | |
|---|
| 501 | BKNI_Printf("\nDone\n"); |
|---|
| 502 | |
|---|
| 503 | return 0; |
|---|
| 504 | |
|---|
| 505 | } |
|---|
| 506 | |
|---|
| 507 | |
|---|
| 508 | int main(void) |
|---|
| 509 | { |
|---|
| 510 | BKNI_Init(); |
|---|
| 511 | BDBG_Init(); |
|---|
| 512 | |
|---|
| 513 | sl_list_test(); |
|---|
| 514 | l_list_test(); |
|---|
| 515 | sq_list_test(); |
|---|
| 516 | q_list_test(); |
|---|
| 517 | q_list_test2(); |
|---|
| 518 | cq_list_test(); |
|---|
| 519 | |
|---|
| 520 | BDBG_Uninit(); |
|---|
| 521 | BKNI_Uninit(); |
|---|
| 522 | |
|---|
| 523 | return 0; |
|---|
| 524 | |
|---|
| 525 | } |
|---|
| 526 | |
|---|