lkml.org 
[lkml]   [2020]   [Jan]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 6/7] lib: new testcases for bitmap_parse{_user}
Date
From Yury Norov <yury.norov@gmail.com>

New version of bitmap_parse() is unified with bitmap_parse_list(),
and therefore:
- weakens rules on whitespaces and commas between hex chunks;
- in addition to \0 allows using \n as the line ending symbol;
- allows passing UINT_MAX or any other big number as the length
of input string instead of actual string length.

The patch covers the cases.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Yury Norov <yury.norov@gmail.com>
---
lib/test_bitmap.c | 8 ++++++++
1 file changed, 8 insertions(+)

diff --git a/lib/test_bitmap.c b/lib/test_bitmap.c
index 830c9b195e405..fb4ffb88a8160 100644
--- a/lib/test_bitmap.c
+++ b/lib/test_bitmap.c
@@ -415,14 +415,22 @@ static const unsigned long parse_test2[] __initconst = {
};

static const struct test_bitmap_parselist parse_tests[] __initconst = {
+ {0, "", &parse_test[0 * step], 32, 0},
+ {0, " ", &parse_test[0 * step], 32, 0},
{0, "0", &parse_test[0 * step], 32, 0},
+ {0, "0\n", &parse_test[0 * step], 32, 0},
{0, "1", &parse_test[1 * step], 32, 0},
{0, "deadbeef", &parse_test[2 * step], 32, 0},
{0, "1,0", &parse_test[3 * step], 33, 0},
+ {0, "deadbeef,\n,0,1", &parse_test[2 * step], 96, 0},

{0, "deadbeef,1,0", &parse_test2[0 * 2 * step], 96, 0},
{0, "baadf00d,deadbeef,1,0", &parse_test2[1 * 2 * step], 128, 0},
{0, "badf00d,deadbeef,1,0", &parse_test2[2 * 2 * step], 124, 0},
+ {0, "badf00d,deadbeef,1,0", &parse_test2[2 * 2 * step], 124, NO_LEN},
+ {0, " badf00d,deadbeef,1,0 ", &parse_test2[2 * 2 * step], 124, 0},
+ {0, " , badf00d,deadbeef,1,0 , ", &parse_test2[2 * 2 * step], 124, 0},
+ {0, " , badf00d, ,, ,,deadbeef,1,0 , ", &parse_test2[2 * 2 * step], 124, 0},

{-EINVAL, "goodfood,deadbeef,1,0", NULL, 128, 0},
{-EOVERFLOW, "3,0", NULL, 33, 0},
--
2.20.1
\
 
 \ /
  Last update: 2020-01-02 05:32    [W:0.049 / U:5.648 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site