| 15 | #define MAX_BULK 32 |
| 16 | |
| 17 | static int |
| 18 | test_stack_push_pop(struct rte_stack *s, void **obj_table, unsigned int bulk_sz) |
| 19 | { |
| 20 | unsigned int i, ret; |
| 21 | void **popped_objs; |
| 22 | |
| 23 | popped_objs = rte_calloc(NULL, STACK_SIZE, sizeof(void *), 0); |
| 24 | if (popped_objs == NULL) { |
| 25 | printf("[%s():%u] failed to calloc %zu bytes\n", |
| 26 | __func__, __LINE__, STACK_SIZE * sizeof(void *)); |
| 27 | return -1; |
| 28 | } |
| 29 | |
| 30 | for (i = 0; i < STACK_SIZE; i += bulk_sz) { |
| 31 | ret = rte_stack_push(s, &obj_table[i], bulk_sz); |
| 32 | |
| 33 | if (ret != bulk_sz) { |
| 34 | printf("[%s():%u] push returned: %d (expected %u)\n", |
| 35 | __func__, __LINE__, ret, bulk_sz); |
| 36 | rte_free(popped_objs); |
| 37 | return -1; |
| 38 | } |
| 39 | |
| 40 | if (rte_stack_count(s) != i + bulk_sz) { |
| 41 | printf("[%s():%u] stack count: %u (expected %u)\n", |
| 42 | __func__, __LINE__, rte_stack_count(s), |
| 43 | i + bulk_sz); |
| 44 | rte_free(popped_objs); |
| 45 | return -1; |
| 46 | } |
| 47 | |
| 48 | if (rte_stack_free_count(s) != STACK_SIZE - i - bulk_sz) { |
| 49 | printf("[%s():%u] stack free count: %u (expected %u)\n", |
| 50 | __func__, __LINE__, rte_stack_count(s), |
| 51 | STACK_SIZE - i - bulk_sz); |
| 52 | rte_free(popped_objs); |
| 53 | return -1; |
| 54 | } |
| 55 | } |
| 56 | |
| 57 | for (i = 0; i < STACK_SIZE; i += bulk_sz) { |
| 58 | ret = rte_stack_pop(s, &popped_objs[i], bulk_sz); |
| 59 | |
| 60 | if (ret != bulk_sz) { |
| 61 | printf("[%s():%u] pop returned: %d (expected %u)\n", |
| 62 | __func__, __LINE__, ret, bulk_sz); |
| 63 | rte_free(popped_objs); |
| 64 | return -1; |
| 65 | } |
| 66 | |
| 67 | if (rte_stack_count(s) != STACK_SIZE - i - bulk_sz) { |
| 68 | printf("[%s():%u] stack count: %u (expected %u)\n", |
| 69 | __func__, __LINE__, rte_stack_count(s), |
| 70 | STACK_SIZE - i - bulk_sz); |
| 71 | rte_free(popped_objs); |
| 72 | return -1; |
| 73 | } |
| 74 |
no test coverage detected