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

Function test_add_update_delete

dpdk/app/test/test_hash.c:360–411  ·  view source on GitHub ↗

* Sequence of operations for a single key: * - delete: miss * - add * - lookup: hit * - add: update * - lookup: hit (updated data) * - delete: hit * - delete: miss * - lookup: miss */

Source from the content-addressed store, hash-verified

358 * - lookup: miss
359 */
360static int test_add_update_delete(void)
361{
362 struct rte_hash *handle;
363 int pos0, expectedPos0;
364
365 ut_params.name = "test2";
366 handle = rte_hash_create(&ut_params);
367 RETURN_IF_ERROR(handle == NULL, "hash creation failed");
368
369 pos0 = rte_hash_del_key(handle, &keys[0]);
370 print_key_info("Del", &keys[0], pos0);
371 RETURN_IF_ERROR(pos0 != -ENOENT,
372 "fail: found non-existent key (pos0=%d)", pos0);
373
374 pos0 = rte_hash_add_key(handle, &keys[0]);
375 print_key_info("Add", &keys[0], pos0);
376 RETURN_IF_ERROR(pos0 < 0, "failed to add key (pos0=%d)", pos0);
377 expectedPos0 = pos0;
378
379 pos0 = rte_hash_lookup(handle, &keys[0]);
380 print_key_info("Lkp", &keys[0], pos0);
381 RETURN_IF_ERROR(pos0 != expectedPos0,
382 "failed to find key (pos0=%d)", pos0);
383
384 pos0 = rte_hash_add_key(handle, &keys[0]);
385 print_key_info("Add", &keys[0], pos0);
386 RETURN_IF_ERROR(pos0 != expectedPos0,
387 "failed to re-add key (pos0=%d)", pos0);
388
389 pos0 = rte_hash_lookup(handle, &keys[0]);
390 print_key_info("Lkp", &keys[0], pos0);
391 RETURN_IF_ERROR(pos0 != expectedPos0,
392 "failed to find key (pos0=%d)", pos0);
393
394 pos0 = rte_hash_del_key(handle, &keys[0]);
395 print_key_info("Del", &keys[0], pos0);
396 RETURN_IF_ERROR(pos0 != expectedPos0,
397 "failed to delete key (pos0=%d)", pos0);
398
399 pos0 = rte_hash_del_key(handle, &keys[0]);
400 print_key_info("Del", &keys[0], pos0);
401 RETURN_IF_ERROR(pos0 != -ENOENT,
402 "fail: deleted already deleted key (pos0=%d)", pos0);
403
404 pos0 = rte_hash_lookup(handle, &keys[0]);
405 print_key_info("Lkp", &keys[0], pos0);
406 RETURN_IF_ERROR(pos0 != -ENOENT,
407 "fail: found key after deleting! (pos0=%d)", pos0);
408
409 rte_hash_free(handle);
410 return 0;
411}
412
413/*
414 * Sequence of operations for a single key with 'disable free on del' set:

Callers 1

test_hashFunction · 0.70

Calls 6

rte_hash_createFunction · 0.85
rte_hash_del_keyFunction · 0.85
rte_hash_add_keyFunction · 0.85
rte_hash_lookupFunction · 0.85
rte_hash_freeFunction · 0.85
print_key_infoFunction · 0.70

Tested by

no test coverage detected