* Call insert, lookup/lookup_exact and delete for a single rule */
| 236 | * Call insert, lookup/lookup_exact and delete for a single rule |
| 237 | */ |
| 238 | int32_t |
| 239 | test_basic(void) |
| 240 | { |
| 241 | struct rte_rib *rib = NULL; |
| 242 | struct rte_rib_node *node; |
| 243 | struct rte_rib_conf config; |
| 244 | |
| 245 | uint32_t ip = RTE_IPV4(192, 0, 2, 0); |
| 246 | uint64_t next_hop_add = 10; |
| 247 | uint64_t next_hop_return; |
| 248 | uint8_t depth = 24; |
| 249 | int ret; |
| 250 | |
| 251 | config.max_nodes = MAX_RULES; |
| 252 | config.ext_sz = 0; |
| 253 | |
| 254 | rib = rte_rib_create(__func__, SOCKET_ID_ANY, &config); |
| 255 | RTE_TEST_ASSERT(rib != NULL, "Failed to create RIB\n"); |
| 256 | |
| 257 | node = rte_rib_insert(rib, ip, depth); |
| 258 | RTE_TEST_ASSERT(node != NULL, "Failed to insert rule\n"); |
| 259 | |
| 260 | ret = rte_rib_set_nh(node, next_hop_add); |
| 261 | RTE_TEST_ASSERT(ret == 0, |
| 262 | "Failed to set rte_rib_node field\n"); |
| 263 | |
| 264 | node = rte_rib_lookup(rib, ip); |
| 265 | RTE_TEST_ASSERT(node != NULL, "Failed to lookup\n"); |
| 266 | |
| 267 | ret = rte_rib_get_nh(node, &next_hop_return); |
| 268 | RTE_TEST_ASSERT((ret == 0) && (next_hop_add == next_hop_return), |
| 269 | "Failed to get proper nexthop\n"); |
| 270 | |
| 271 | node = rte_rib_lookup_exact(rib, ip, depth); |
| 272 | RTE_TEST_ASSERT(node != NULL, |
| 273 | "Failed to lookup\n"); |
| 274 | |
| 275 | ret = rte_rib_get_nh(node, &next_hop_return); |
| 276 | RTE_TEST_ASSERT((ret == 0) && (next_hop_add == next_hop_return), |
| 277 | "Failed to get proper nexthop\n"); |
| 278 | |
| 279 | rte_rib_remove(rib, ip, depth); |
| 280 | |
| 281 | node = rte_rib_lookup(rib, ip); |
| 282 | RTE_TEST_ASSERT(node == NULL, |
| 283 | "Lookup returns non existent rule\n"); |
| 284 | node = rte_rib_lookup_exact(rib, ip, depth); |
| 285 | RTE_TEST_ASSERT(node == NULL, |
| 286 | "Lookup returns non existent rule\n"); |
| 287 | |
| 288 | rte_rib_free(rib); |
| 289 | |
| 290 | return TEST_SUCCESS; |
| 291 | } |
| 292 | |
| 293 | int32_t |
| 294 | test_tree_traversal(void) |
nothing calls this directly
no test coverage detected