MCPcopy Create free account
hub / github.com/F-Stack/f-stack / test_stack_basic

Function test_stack_basic

dpdk/app/test/test_stack.c:99–177  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

97}
98
99static int
100test_stack_basic(uint32_t flags)
101{
102 struct rte_stack *s = NULL;
103 void **obj_table = NULL;
104 int i, ret = -1;
105
106 obj_table = rte_calloc(NULL, STACK_SIZE, sizeof(void *), 0);
107 if (obj_table == NULL) {
108 printf("[%s():%u] failed to calloc %zu bytes\n",
109 __func__, __LINE__, STACK_SIZE * sizeof(void *));
110 goto fail_test;
111 }
112
113 for (i = 0; i < STACK_SIZE; i++)
114 obj_table[i] = (void *)(uintptr_t)i;
115
116 s = rte_stack_create(__func__, STACK_SIZE, rte_socket_id(), flags);
117 if (s == NULL) {
118 printf("[%s():%u] failed to create a stack\n",
119 __func__, __LINE__);
120 goto fail_test;
121 }
122
123 if (rte_stack_lookup(__func__) != s) {
124 printf("[%s():%u] failed to lookup a stack\n",
125 __func__, __LINE__);
126 goto fail_test;
127 }
128
129 if (rte_stack_count(s) != 0) {
130 printf("[%s():%u] stack count: %u (expected 0)\n",
131 __func__, __LINE__, rte_stack_count(s));
132 goto fail_test;
133 }
134
135 if (rte_stack_free_count(s) != STACK_SIZE) {
136 printf("[%s():%u] stack free count: %u (expected %u)\n",
137 __func__, __LINE__, rte_stack_count(s), STACK_SIZE);
138 goto fail_test;
139 }
140
141 ret = test_stack_push_pop(s, obj_table, 1);
142 if (ret) {
143 printf("[%s():%u] Single object push/pop failed\n",
144 __func__, __LINE__);
145 goto fail_test;
146 }
147
148 ret = test_stack_push_pop(s, obj_table, MAX_BULK);
149 if (ret) {
150 printf("[%s():%u] Bulk object push/pop failed\n",
151 __func__, __LINE__);
152 goto fail_test;
153 }
154
155 ret = rte_stack_push(s, obj_table, 2 * STACK_SIZE);
156 if (ret != 0) {

Callers 1

__test_stackFunction · 0.85

Calls 12

rte_callocFunction · 0.85
rte_stack_createFunction · 0.85
rte_socket_idFunction · 0.85
rte_stack_lookupFunction · 0.85
rte_stack_countFunction · 0.85
rte_stack_free_countFunction · 0.85
test_stack_push_popFunction · 0.85
rte_stack_pushFunction · 0.85
rte_stack_popFunction · 0.85
rte_stack_freeFunction · 0.85
rte_freeFunction · 0.85
printfFunction · 0.50

Tested by

no test coverage detected