| 144 | } |
| 145 | |
| 146 | static int |
| 147 | test_lcores_callback(unsigned int eal_threads_count) |
| 148 | { |
| 149 | struct limit_lcore_context l; |
| 150 | void *handle; |
| 151 | |
| 152 | /* Refuse last lcore => callback register error. */ |
| 153 | memset(&l, 0, sizeof(l)); |
| 154 | l.max = eal_threads_count - 1; |
| 155 | handle = rte_lcore_callback_register("limit", limit_lcores_init, |
| 156 | limit_lcores_uninit, &l); |
| 157 | if (handle != NULL) { |
| 158 | printf("Error: lcore callback register should have failed\n"); |
| 159 | goto error; |
| 160 | } |
| 161 | /* Refusal happens at the n th call to the init callback. |
| 162 | * Besides, n - 1 were accepted, so we expect as many uninit calls when |
| 163 | * the rollback happens. |
| 164 | */ |
| 165 | if (l.init != eal_threads_count) { |
| 166 | printf("Error: lcore callback register failed but incorrect init calls, expected %u, got %u\n", |
| 167 | eal_threads_count, l.init); |
| 168 | goto error; |
| 169 | } |
| 170 | if (l.uninit != eal_threads_count - 1) { |
| 171 | printf("Error: lcore callback register failed but incorrect uninit calls, expected %u, got %u\n", |
| 172 | eal_threads_count - 1, l.uninit); |
| 173 | goto error; |
| 174 | } |
| 175 | |
| 176 | /* Accept all lcore and unregister. */ |
| 177 | memset(&l, 0, sizeof(l)); |
| 178 | l.max = eal_threads_count; |
| 179 | handle = rte_lcore_callback_register("limit", limit_lcores_init, |
| 180 | limit_lcores_uninit, &l); |
| 181 | if (handle == NULL) { |
| 182 | printf("Error: lcore callback register failed\n"); |
| 183 | goto error; |
| 184 | } |
| 185 | if (l.uninit != 0) { |
| 186 | printf("Error: lcore callback register succeeded but incorrect uninit calls, expected 0, got %u\n", |
| 187 | l.uninit); |
| 188 | goto error; |
| 189 | } |
| 190 | rte_lcore_callback_unregister(handle); |
| 191 | handle = NULL; |
| 192 | if (l.init != eal_threads_count) { |
| 193 | printf("Error: lcore callback unregister done but incorrect init calls, expected %u, got %u\n", |
| 194 | eal_threads_count, l.init); |
| 195 | goto error; |
| 196 | } |
| 197 | if (l.uninit != eal_threads_count) { |
| 198 | printf("Error: lcore callback unregister done but incorrect uninit calls, expected %u, got %u\n", |
| 199 | eal_threads_count, l.uninit); |
| 200 | goto error; |
| 201 | } |
| 202 | |
| 203 | return 0; |
no test coverage detected