Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp1219171pxx; Tue, 27 Oct 2020 11:01:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwzy31BY5gAietsnT1ecxMSHUA0GEoP5W2HE2aSoTFmCswNLnoOWszVfl5K+YpFU7/nKQ7W X-Received: by 2002:a05:600c:2217:: with SMTP id z23mr4157616wml.133.1603821702416; Tue, 27 Oct 2020 11:01:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603821702; cv=none; d=google.com; s=arc-20160816; b=VNjFRgeoWJxofE332IQilHmIyjtK4cYGrxq/OS3a9r+3oOwuseht0VDEV+Lwt5eHPm 2VMdxcFWqxaN/SZj2Qqjk0LwlhhehZaKKOnk9mXi3qiSKtZtHI7knTZxTOZLvOcSe2H5 4HxGWb7QtC8Plr+ml5T0o8oJM9QQeivCUUnfygmreZR66yXzGK6hCOxLMHm+x0onAmNP RPDcT4L4UjCrP+h15XQiM7lLtJPMoRNeKbIL6IweNW6ZSQwXxxwwARkrcky+hhjndZYT YJsC5hXgxypq3Em01GKEuQPqnBeT+W7AptFRmYH3aTWuaCT2tFwV1dLq+1hGhLAndHxI Kcgg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=DJdrHkP5GhFWBxOBTxYJLlq85LF0Y8rsT83lHf4BoXA=; b=pwrDzpae+kPysj3S80Vbf1CzEYgq9lqiszhYxCFBSQ5zPcc77y/aIpZrZMHO6OVOVQ zIw4fzs/KOdsbeq7BMCWQGRJfEpW4oSsf8h6nkqKTBbuOXlEsQbshxfemB85sLt6O8Zx o1G/WOchIGOL0MF0/v/7tkDtd37YBTZhgqsfGfZOOiwolhv/rD3gOL4YpCwTk5GPSAms OBEHQevVhE/1vQycJGE34cYp3UpuYCi5oNrcYITQ4vfuS7KtEk2AkfCE0r4TudvVD8XN HODjWxP2JsNTQBaJsH0PtcM80n2LQGUfZvs0vWo1kJHh/OCcPgSxaW+JI9uuW3yuZobM o6Kg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=rElie7nC; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u10si1420139edd.315.2020.10.27.11.01.11; Tue, 27 Oct 2020 11:01:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=rElie7nC; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1820263AbgJ0ReQ (ORCPT + 99 others); Tue, 27 Oct 2020 13:34:16 -0400 Received: from mail-qt1-f194.google.com ([209.85.160.194]:40715 "EHLO mail-qt1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1820258AbgJ0ReO (ORCPT ); Tue, 27 Oct 2020 13:34:14 -0400 Received: by mail-qt1-f194.google.com with SMTP id m9so1602794qth.7 for ; Tue, 27 Oct 2020 10:34:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=DJdrHkP5GhFWBxOBTxYJLlq85LF0Y8rsT83lHf4BoXA=; b=rElie7nCB2CSbeT6c/CaRa3JHjFQyZbh0vMF7smW6sS0e7lP2rguaapbfqKZlnXJMt H/al2Ps4yGge5TkCv7RwrkHawwOXy7AJkP6a/iHLDnTJvdGRLGrXBrr8QHt4+yioaM7L jm5b8mvRFwige6iwO7e8ADEX+VDoGG6tk9ObciKNvJ/nDOLSqFj9Bih4li5/oehtBTtQ HTj5kT4vsEwtH4CacmE/gNkfyvQUZep5AoMjgt2VbxMKwj/AeKBpLHynlUJJOdSdLoKM ZHyiJ1lH32gzTeEwyueSWFnkIQ8aVPKVnxVB0hEwI3ylp/eOUfkYi538tWiNR0Gj79Ui cp8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=DJdrHkP5GhFWBxOBTxYJLlq85LF0Y8rsT83lHf4BoXA=; b=dNp5E5tvhp5DvtEmAf/IMf+7GIl2C+SJiQJltlhKYPzCiiD/BvBDjfll3ZTAlRgzpy ++rkhUNL5ehS8g7x/BK+EGTBDcaMwLG5i9bWiSrUKH+SFVWh5kHHrkYPSbmK8vMQhdoz fPV53/b4cBug0aLHexUIJQ9BjQ1eKS/dRj41CVQ7Q8lC8Y6f2nt96WuGUCIjvqpr5ycS hvHG/izy45r123zZJzwXko0iQyPuVJIit32+reQ4Z0ctLHuNEs/xiJVrBaQSE8q9mg1T xV+aVwzu+pNQ9LKAE2Kry+RWiMYAYHPZV2tqIRNP8oCVTH0JajSv+1DxKC60A0TuwgNe P5tg== X-Gm-Message-State: AOAM5317UWi2GKHeV20uZ1m6cPWESWXaS+eG8fS6I6Wqxqlt8kPScr4a k0/GwixsaXAiyhE2w6/R8dGDR/4kXpcHF1l97kcu X-Received: by 2002:ac8:4e49:: with SMTP id e9mr3216124qtw.114.1603820051180; Tue, 27 Oct 2020 10:34:11 -0700 (PDT) MIME-Version: 1.0 References: <20201026183523.82749-1-98.arpi@gmail.com> <20201026183639.82883-1-98.arpi@gmail.com> In-Reply-To: <20201026183639.82883-1-98.arpi@gmail.com> From: Iurii Zaikin Date: Tue, 27 Oct 2020 10:33:34 -0700 Message-ID: Subject: Re: [PATCH v3 2/2] fs: ext4: Modify inode-test.c to use KUnit parameterized testing feature To: Arpitha Raghunandan <98.arpi@gmail.com> Cc: Brendan Higgins , Shuah Khan , Marco Elver , "Theodore Ts'o" , Andreas Dilger , "open list:KERNEL SELFTEST FRAMEWORK" , KUnit Development , Linux Kernel Mailing List , linux-kernel-mentees@lists.linuxfoundation.org, Ext4 Developers List Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org > > Modify fs/ext4/inode-test.c to use the parameterized testing > feature of KUnit. > > Signed-off-by: Arpitha Raghunandan <98.arpi@gmail.com> > --- > 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..3a449623b775 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 = -0x80000000LL, .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 = 0x7fffffffLL, .tv_nsec = 0L}, > + }, > + > + { > + .test_case_name = LOWER_BOUND_NEG_LO_1_CASE, > + .msb_set = true, > + .lower_bound = true, > + .extra_bits = 1, > + .expected = {.tv_sec = 0x80000000LL, .tv_nsec = 0L}, > + }, > + > + { > + .test_case_name = UPPER_BOUND_NEG_LO_1_CASE, > + .msb_set = true, > + .lower_bound = false, > + .extra_bits = 1, > + .expected = {.tv_sec = 0xffffffffLL, .tv_nsec = 0L}, > + }, > + > + { > + .test_case_name = LOWER_BOUND_NONNEG_LO_1_CASE, > + .msb_set = false, > + .lower_bound = true, > + .extra_bits = 1, > + .expected = {.tv_sec = 0x100000000LL, .tv_nsec = 0L}, > + }, > + > + { > + .test_case_name = UPPER_BOUND_NONNEG_LO_1_CASE, > + .msb_set = false, > + .lower_bound = false, > + .extra_bits = 1, > + .expected = {.tv_sec = 0x17fffffffLL, .tv_nsec = 0L}, > + }, > + > + { > + .test_case_name = LOWER_BOUND_NEG_HI_1_CASE, > + .msb_set = true, > + .lower_bound = true, > + .extra_bits = 2, > + .expected = {.tv_sec = 0x180000000LL, .tv_nsec = 0L}, > + }, > + > + { > + .test_case_name = UPPER_BOUND_NEG_HI_1_CASE, > + .msb_set = true, > + .lower_bound = false, > + .extra_bits = 2, > + .expected = {.tv_sec = 0x1ffffffffLL, .tv_nsec = 0L}, > + }, > + > + { > + .test_case_name = LOWER_BOUND_NONNEG_HI_1_CASE, > + .msb_set = false, > + .lower_bound = true, > + .extra_bits = 2, > + .expected = {.tv_sec = 0x200000000LL, .tv_nsec = 0L}, > + }, > + > + { > + .test_case_name = UPPER_BOUND_NONNEG_HI_1_CASE, > + .msb_set = false, > + .lower_bound = false, > + .extra_bits = 2, > + .expected = {.tv_sec = 0x27fffffffLL, .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 = 0x27fffffffLL, .tv_nsec = 1L}, > + }, > + > + { > + .test_case_name = LOWER_BOUND_NONNEG_HI_1_NS_MAX_CASE, > + .msb_set = false, > + .lower_bound = true, > + .extra_bits = 0xFFFFFFFF, > + .expected = {.tv_sec = 0x300000000LL, > + .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 = 0x300000000LL, .tv_nsec = 0L}, > + }, > + > + { > + .test_case_name = UPPER_BOUND_NONNEG_EXTRA_BITS_1_CASE, > + .msb_set = false, > + .lower_bound = false, > + .extra_bits = 3, > + .expected = {.tv_sec = 0x37fffffffLL, .tv_nsec = 0L}, > + } > +}; > + > +KUNIT_PARAM_GENERATOR(ext4_inode, test_data); > + > static time64_t get_32bit_time(const struct timestamp_expectation * const test) > { > if (test->msb_set) { > @@ -101,166 +234,35 @@ static time64_t get_32bit_time(const struct timestamp_expectation * const test) > */ > static void inode_test_xtimestamp_decoding(struct kunit *test) > { > - 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 = -0x80000000LL, .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 = 0x7fffffffLL, .tv_nsec = 0L}, > - }, > - > - { > - .test_case_name = LOWER_BOUND_NEG_LO_1_CASE, > - .msb_set = true, > - .lower_bound = true, > - .extra_bits = 1, > - .expected = {.tv_sec = 0x80000000LL, .tv_nsec = 0L}, > - }, > - > - { > - .test_case_name = UPPER_BOUND_NEG_LO_1_CASE, > - .msb_set = true, > - .lower_bound = false, > - .extra_bits = 1, > - .expected = {.tv_sec = 0xffffffffLL, .tv_nsec = 0L}, > - }, > - > - { > - .test_case_name = LOWER_BOUND_NONNEG_LO_1_CASE, > - .msb_set = false, > - .lower_bound = true, > - .extra_bits = 1, > - .expected = {.tv_sec = 0x100000000LL, .tv_nsec = 0L}, > - }, > - > - { > - .test_case_name = UPPER_BOUND_NONNEG_LO_1_CASE, > - .msb_set = false, > - .lower_bound = false, > - .extra_bits = 1, > - .expected = {.tv_sec = 0x17fffffffLL, .tv_nsec = 0L}, > - }, > - > - { > - .test_case_name = LOWER_BOUND_NEG_HI_1_CASE, > - .msb_set = true, > - .lower_bound = true, > - .extra_bits = 2, > - .expected = {.tv_sec = 0x180000000LL, .tv_nsec = 0L}, > - }, > - > - { > - .test_case_name = UPPER_BOUND_NEG_HI_1_CASE, > - .msb_set = true, > - .lower_bound = false, > - .extra_bits = 2, > - .expected = {.tv_sec = 0x1ffffffffLL, .tv_nsec = 0L}, > - }, > - > - { > - .test_case_name = LOWER_BOUND_NONNEG_HI_1_CASE, > - .msb_set = false, > - .lower_bound = true, > - .extra_bits = 2, > - .expected = {.tv_sec = 0x200000000LL, .tv_nsec = 0L}, > - }, > - > - { > - .test_case_name = UPPER_BOUND_NONNEG_HI_1_CASE, > - .msb_set = false, > - .lower_bound = false, > - .extra_bits = 2, > - .expected = {.tv_sec = 0x27fffffffLL, .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 = 0x27fffffffLL, .tv_nsec = 1L}, > - }, > - > - { > - .test_case_name = LOWER_BOUND_NONNEG_HI_1_NS_MAX_CASE, > - .msb_set = false, > - .lower_bound = true, > - .extra_bits = 0xFFFFFFFF, > - .expected = {.tv_sec = 0x300000000LL, > - .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 = 0x300000000LL, .tv_nsec = 0L}, > - }, > - > - { > - .test_case_name = UPPER_BOUND_NONNEG_EXTRA_BITS_1_CASE, > - .msb_set = false, > - .lower_bound = false, > - .extra_bits = 3, > - .expected = {.tv_sec = 0x37fffffffLL, .tv_nsec = 0L}, > - } > - }; > - > struct timespec64 timestamp; > - int i; > - > - for (i = 0; i < ARRAY_SIZE(test_data); ++i) { > - timestamp.tv_sec = get_32bit_time(&test_data[i]); > - ext4_decode_extra_time(×tamp, > - cpu_to_le32(test_data[i].extra_bits)); > - > - KUNIT_EXPECT_EQ_MSG(test, > - test_data[i].expected.tv_sec, > - timestamp.tv_sec, > - CASE_NAME_FORMAT, > - test_data[i].test_case_name, > - test_data[i].msb_set, > - test_data[i].lower_bound, > - test_data[i].extra_bits); > - KUNIT_EXPECT_EQ_MSG(test, > - test_data[i].expected.tv_nsec, > - timestamp.tv_nsec, > - CASE_NAME_FORMAT, > - test_data[i].test_case_name, > - test_data[i].msb_set, > - test_data[i].lower_bound, > - test_data[i].extra_bits); > - } > + > + struct timestamp_expectation *test_param = > + (struct timestamp_expectation *)(test->param_values); > + > + timestamp.tv_sec = get_32bit_time(test_param); > + ext4_decode_extra_time(×tamp, > + cpu_to_le32(test_param->extra_bits)); > + > + KUNIT_EXPECT_EQ_MSG(test, > + test_param->expected.tv_sec, > + timestamp.tv_sec, > + CASE_NAME_FORMAT, > + test_param->test_case_name, > + test_param->msb_set, > + test_param->lower_bound, > + test_param->extra_bits); > + KUNIT_EXPECT_EQ_MSG(test, > + test_param->expected.tv_nsec, > + timestamp.tv_nsec, > + CASE_NAME_FORMAT, > + test_param->test_case_name, > + test_param->msb_set, > + test_param->lower_bound, > + test_param->extra_bits); > } > > static struct kunit_case ext4_inode_test_cases[] = { > - KUNIT_CASE(inode_test_xtimestamp_decoding), > + KUNIT_CASE_PARAM(inode_test_xtimestamp_decoding, ext4_inode_gen_params), > {} > }; > > -- > 2.25.1 > Reviewed-by: Iurii Zaikin