Re: [PATCH v6 2/2] fs: ext4: Modify inode-test.c to use KUnit parameterized testing feature

2020-11-06 Thread David Gow
On Sat, Nov 7, 2020 at 3:23 AM Arpitha Raghunandan <98.a...@gmail.com> wrote:
>
> Modify fs/ext4/inode-test.c to use the parameterized testing
> feature of KUnit.
>
> Signed-off-by: Arpitha Raghunandan <98.a...@gmail.com>
> ---

This looks good to me. Thanks!

Reviewed-by: David Gow 

-- David


[PATCH v6 2/2] fs: ext4: Modify inode-test.c to use KUnit parameterized testing feature

2020-11-06 Thread Arpitha Raghunandan
Modify fs/ext4/inode-test.c to use the parameterized testing
feature of KUnit.

Signed-off-by: Arpitha Raghunandan <98.a...@gmail.com>
---
Changes v5->v6:
- No change to this patch of the patch series
Changes v4->v5:
- No change to this patch of the patch series
Changes v3->v4:
- Modification based on latest implementation of KUnit parameterized testing
Changes v2->v3:
- Marked hardcoded test data const
- Modification based on latest implementation of KUnit parameterized testing
Changes v1->v2:
- Modification based on latest implementation of KUnit parameterized testing

 fs/ext4/inode-test.c | 314 ++-
 1 file changed, 158 insertions(+), 156 deletions(-)

diff --git a/fs/ext4/inode-test.c b/fs/ext4/inode-test.c
index d62d802c9c12..ebf1b1af4f1d 100644
--- a/fs/ext4/inode-test.c
+++ b/fs/ext4/inode-test.c
@@ -80,6 +80,139 @@ struct timestamp_expectation {
bool lower_bound;
 };
 
+static const struct timestamp_expectation test_data[] = {
+   {
+   .test_case_name = LOWER_BOUND_NEG_NO_EXTRA_BITS_CASE,
+   .msb_set = true,
+   .lower_bound = true,
+   .extra_bits = 0,
+   .expected = {.tv_sec = -0x8000LL, .tv_nsec = 0L},
+   },
+
+   {
+   .test_case_name = UPPER_BOUND_NEG_NO_EXTRA_BITS_CASE,
+   .msb_set = true,
+   .lower_bound = false,
+   .extra_bits = 0,
+   .expected = {.tv_sec = -1LL, .tv_nsec = 0L},
+   },
+
+   {
+   .test_case_name = LOWER_BOUND_NONNEG_NO_EXTRA_BITS_CASE,
+   .msb_set = false,
+   .lower_bound = true,
+   .extra_bits = 0,
+   .expected = {0LL, 0L},
+   },
+
+   {
+   .test_case_name = UPPER_BOUND_NONNEG_NO_EXTRA_BITS_CASE,
+   .msb_set = false,
+   .lower_bound = false,
+   .extra_bits = 0,
+   .expected = {.tv_sec = 0x7fffLL, .tv_nsec = 0L},
+   },
+
+   {
+   .test_case_name = LOWER_BOUND_NEG_LO_1_CASE,
+   .msb_set = true,
+   .lower_bound = true,
+   .extra_bits = 1,
+   .expected = {.tv_sec = 0x8000LL, .tv_nsec = 0L},
+   },
+
+   {
+   .test_case_name = UPPER_BOUND_NEG_LO_1_CASE,
+   .msb_set = true,
+   .lower_bound = false,
+   .extra_bits = 1,
+   .expected = {.tv_sec = 0xLL, .tv_nsec = 0L},
+   },
+
+   {
+   .test_case_name = LOWER_BOUND_NONNEG_LO_1_CASE,
+   .msb_set = false,
+   .lower_bound = true,
+   .extra_bits = 1,
+   .expected = {.tv_sec = 0x1LL, .tv_nsec = 0L},
+   },
+
+   {
+   .test_case_name = UPPER_BOUND_NONNEG_LO_1_CASE,
+   .msb_set = false,
+   .lower_bound = false,
+   .extra_bits = 1,
+   .expected = {.tv_sec = 0x17fffLL, .tv_nsec = 0L},
+   },
+
+   {
+   .test_case_name = LOWER_BOUND_NEG_HI_1_CASE,
+   .msb_set = true,
+   .lower_bound = true,
+   .extra_bits =  2,
+   .expected = {.tv_sec = 0x18000LL, .tv_nsec = 0L},
+   },
+
+   {
+   .test_case_name = UPPER_BOUND_NEG_HI_1_CASE,
+   .msb_set = true,
+   .lower_bound = false,
+   .extra_bits = 2,
+   .expected = {.tv_sec = 0x1LL, .tv_nsec = 0L},
+   },
+
+   {
+   .test_case_name = LOWER_BOUND_NONNEG_HI_1_CASE,
+   .msb_set = false,
+   .lower_bound = true,
+   .extra_bits = 2,
+   .expected = {.tv_sec = 0x2LL, .tv_nsec = 0L},
+   },
+
+   {
+   .test_case_name = UPPER_BOUND_NONNEG_HI_1_CASE,
+   .msb_set = false,
+   .lower_bound = false,
+   .extra_bits = 2,
+   .expected = {.tv_sec = 0x27fffLL, .tv_nsec = 0L},
+   },
+
+   {
+   .test_case_name = UPPER_BOUND_NONNEG_HI_1_NS_1_CASE,
+   .msb_set = false,
+   .lower_bound = false,
+   .extra_bits = 6,
+   .expected = {.tv_sec = 0x27fffLL, .tv_nsec = 1L},
+   },
+
+   {
+   .test_case_name = LOWER_BOUND_NONNEG_HI_1_NS_MAX_CASE,
+   .msb_set = false,
+   .lower_bound = true,
+   .extra_bits = 0x,
+   .expected = {.tv_sec = 0x3LL,
+.tv_nsec = MAX_NANOSECONDS},
+   },
+
+   {
+   .test_case_name = LOWER_BOUND_NONNEG_EXTRA_BITS_1_CASE,
+   .msb_set = false,
+   .lower_bound = true,
+   .extra_bits = 3,
+   .expected = {.tv_sec = 0x3LL, .tv_nsec = 0L},
+   },
+
+   {
+