tests: fix bihash unittest error reporting
This patch fixes test_bihash_unittest in two ways: 1. The number of searches, namely tm->search_iter, defaults to 0, thus disabling the test. This patch changes the default to 1. 2. Test errors are reported by clib_warning() instead of being returned, thus the caller test/test_bihash.py is never aware of them. This patch returns the errors constructed by clib_error_return(). Type: fix Signed-off-by: Jing Peng <pj.hades@gmail.com> Change-Id: I60e99a829ebe6aa2a56e7a9332cf973afa100311
This commit is contained in:
@ -338,14 +338,18 @@ test_bihash (bihash_test_main_t * tm)
|
|||||||
{
|
{
|
||||||
kv.key = tm->keys[i];
|
kv.key = tm->keys[i];
|
||||||
if (BV (clib_bihash_search) (h, &kv, &kv) < 0)
|
if (BV (clib_bihash_search) (h, &kv, &kv) < 0)
|
||||||
if (BV (clib_bihash_search) (h, &kv, &kv) < 0)
|
{
|
||||||
clib_warning
|
if (BV (clib_bihash_search) (h, &kv, &kv) < 0)
|
||||||
("[%d] search for key %lld failed unexpectedly\n", i,
|
{
|
||||||
tm->keys[i]);
|
return clib_error_return (
|
||||||
|
0, "[%d] search for key %lld failed unexpectedly\n", i,
|
||||||
|
tm->keys[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
if (kv.value != (u64) (i + 1))
|
if (kv.value != (u64) (i + 1))
|
||||||
clib_warning
|
return clib_error_return (
|
||||||
("[%d] search for key %lld returned %lld, not %lld\n", i,
|
0, "[%d] search for key %lld returned %lld, not %lld\n", i,
|
||||||
tm->keys, kv.value, (u64) (i + 1));
|
tm->keys, kv.value, (u64) (i + 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -373,7 +377,8 @@ test_bihash (bihash_test_main_t * tm)
|
|||||||
{
|
{
|
||||||
p = hash_get (tm->key_hash, tm->keys[i]);
|
p = hash_get (tm->key_hash, tm->keys[i]);
|
||||||
if (p == 0 || p[0] != (uword) (i + 1))
|
if (p == 0 || p[0] != (uword) (i + 1))
|
||||||
clib_warning ("ugh, couldn't find %lld\n", tm->keys[i]);
|
return clib_error_return (0, "ugh, couldn't find %lld\n",
|
||||||
|
tm->keys[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -401,8 +406,8 @@ test_bihash (bihash_test_main_t * tm)
|
|||||||
rv = BV (clib_bihash_add_del) (h, &kv, 0 /* is_add */ );
|
rv = BV (clib_bihash_add_del) (h, &kv, 0 /* is_add */ );
|
||||||
|
|
||||||
if (rv < 0)
|
if (rv < 0)
|
||||||
clib_warning ("delete key %lld not ok but should be",
|
return clib_error_return (
|
||||||
tm->keys[i]);
|
0, "delete key %lld not ok but should be", tm->keys[i]);
|
||||||
|
|
||||||
if (tm->careful_delete_tests)
|
if (tm->careful_delete_tests)
|
||||||
{
|
{
|
||||||
@ -412,14 +417,14 @@ test_bihash (bihash_test_main_t * tm)
|
|||||||
rv = BV (clib_bihash_search) (h, &kv, &kv);
|
rv = BV (clib_bihash_search) (h, &kv, &kv);
|
||||||
if (j <= i && rv >= 0)
|
if (j <= i && rv >= 0)
|
||||||
{
|
{
|
||||||
clib_warning
|
return clib_error_return (
|
||||||
("i %d j %d search ok but should not be, value %lld",
|
0, "i %d j %d search ok but should not be, value %lld",
|
||||||
i, j, kv.value);
|
i, j, kv.value);
|
||||||
}
|
}
|
||||||
if (j > i && rv < 0)
|
if (j > i && rv < 0)
|
||||||
{
|
{
|
||||||
clib_warning ("i %d j %d search not ok but should be",
|
return clib_error_return (
|
||||||
i, j);
|
0, "i %d j %d search not ok but should be", i, j);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -471,6 +476,7 @@ test_bihash_command_fn (vlib_main_t * vm,
|
|||||||
tm->ncycles = 10;
|
tm->ncycles = 10;
|
||||||
tm->report_every_n = 50000;
|
tm->report_every_n = 50000;
|
||||||
tm->seed = 0x1badf00d;
|
tm->seed = 0x1badf00d;
|
||||||
|
tm->search_iter = 1;
|
||||||
|
|
||||||
memset (&tm->stats, 0, sizeof (tm->stats));
|
memset (&tm->stats, 0, sizeof (tm->stats));
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user