aboutsummaryrefslogtreecommitdiffstats
path: root/src/vppinfra/vector/test/array_mask.c
diff options
context:
space:
mode:
authorMohsin Kazmi <sykazmi@cisco.com>2021-08-03 17:56:05 +0000
committerBeno�t Ganne <bganne@cisco.com>2021-08-04 09:19:43 +0000
commit992d996ff5672ae647b21e27901d258aace79058 (patch)
tree847afe576eb65337f85fd8f5958a00c0646c1a72 /src/vppinfra/vector/test/array_mask.c
parent3edae3519858682cae65ce572480020f13f65079 (diff)
vppinfra: fix the array mask function
Type: fix Fixes: 0ec7dad7a00852663eb88554561347987f87bb53 Signed-off-by: Mohsin Kazmi <sykazmi@cisco.com> Change-Id: I7fab80b3c7e86ac712a34c24ea3e526b0b5bb7ad
Diffstat (limited to 'src/vppinfra/vector/test/array_mask.c')
-rw-r--r--src/vppinfra/vector/test/array_mask.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/vppinfra/vector/test/array_mask.c b/src/vppinfra/vector/test/array_mask.c
index 703c70abbe9..a1f4da728d4 100644
--- a/src/vppinfra/vector/test/array_mask.c
+++ b/src/vppinfra/vector/test/array_mask.c
@@ -76,13 +76,15 @@ static array_mask_test_t tests[] = {
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 } },
+ /* mask values 0x1, output array of 1, 0, 1, 0,.. */
+ { .mask = 1, .expected = { 1, 0, 1, 0, 1, 0, 1, 0, 1, 0 } },
};
static clib_error_t *
test_clib_array_mask_u32 (clib_error_t *err)
{
u32 i, j;
- for (i = 0; i < ARRAY_LEN (tests); i++)
+ for (i = 0; i < ARRAY_LEN (tests) - 1; i++)
{
u32 src[256];
for (j = 0; j < ARRAY_LEN (src); j++)
@@ -99,6 +101,20 @@ test_clib_array_mask_u32 (clib_error_t *err)
i, j, src[j], t->expected[j]);
}
}
+
+ u32 src[10] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
+ array_mask_test_t *t = tests + i;
+
+ clib_array_mask_u32_wrapper (src, t->mask, ARRAY_LEN (src));
+ for (j = 0; j < ARRAY_LEN (src); j++)
+ {
+ if (src[j] != t->expected[j])
+ return clib_error_return (err,
+ "testcase %u failed at "
+ "(src[%u] = 0x%x, expected 0x%x)",
+ i, j, src[j], t->expected[j]);
+ }
+
return err;
}