From: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
To: Christian Brauner <brauner@kernel.org>
Cc: Adi Nata <adinata.softwareengineer@gmail.com>,
linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH] kunit: fat: test cluster and directory i_pos layout helpers
Date: Sun, 05 Apr 2026 14:18:19 +0900 [thread overview]
Message-ID: <87y0j2m1d0.fsf@mail.parknet.co.jp> (raw)
In-Reply-To: <20260405011920.28622-1-adinata.softwareengineer@gmail.com>
Adi Nata <adinata.softwareengineer@gmail.com> writes:
> Add KUnit coverage for fat_clus_to_blknr() and fat_get_blknr_offset()
> using stub msdos_sb_info values so cluster-to-sector and i_pos split
> math stays correct.
>
> Signed-off-by: Adi Nata <adinata.softwareengineer@gmail.com>
Looks good.
Acked-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
Thanks.
> ---
> fs/fat/fat_test.c | 33 +++++++++++++++++++++++++++++++++
> 1 file changed, 33 insertions(+)
>
> diff --git a/fs/fat/fat_test.c b/fs/fat/fat_test.c
> index 1f0062659067..add44178f28e 100644
> --- a/fs/fat/fat_test.c
> +++ b/fs/fat/fat_test.c
> @@ -20,6 +20,37 @@ static void fat_checksum_test(struct kunit *test)
> KUNIT_EXPECT_EQ(test, fat_checksum("ABCDEFGHA "), (u8)98);
> }
>
> +static void fat_clus_to_blknr_test(struct kunit *test)
> +{
> + struct msdos_sb_info sbi = {
> + .sec_per_clus = 4,
> + .data_start = 100,
> + };
> +
> + KUNIT_EXPECT_EQ(test, (sector_t)100,
> + fat_clus_to_blknr(&sbi, FAT_START_ENT));
> + KUNIT_EXPECT_EQ(test, (sector_t)112, fat_clus_to_blknr(&sbi, 5));
> +}
> +
> +static void fat_get_blknr_offset_test(struct kunit *test)
> +{
> + struct msdos_sb_info sbi = {
> + .dir_per_block = 16,
> + .dir_per_block_bits = 4,
> + };
> +
> + sector_t blknr;
> + int offset;
> +
> + fat_get_blknr_offset(&sbi, 0, &blknr, &offset);
> + KUNIT_EXPECT_EQ(test, (sector_t)0, blknr);
> + KUNIT_EXPECT_EQ(test, 0, offset);
> +
> + fat_get_blknr_offset(&sbi, (10 << 4) | 7, &blknr, &offset);
> + KUNIT_EXPECT_EQ(test, (sector_t)10, blknr);
> + KUNIT_EXPECT_EQ(test, 7, offset);
> +}
> +
> struct fat_timestamp_testcase {
> const char *name;
> struct timespec64 ts;
> @@ -181,6 +212,8 @@ static void fat_time_unix2fat_test(struct kunit *test)
>
> static struct kunit_case fat_test_cases[] = {
> KUNIT_CASE(fat_checksum_test),
> + KUNIT_CASE(fat_clus_to_blknr_test),
> + KUNIT_CASE(fat_get_blknr_offset_test),
> KUNIT_CASE_PARAM(fat_time_fat2unix_test, fat_time_gen_params),
> KUNIT_CASE_PARAM(fat_time_unix2fat_test, fat_time_gen_params),
> {},
--
OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
prev parent reply other threads:[~2026-04-05 5:18 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-05 1:19 [PATCH] kunit: fat: test cluster and directory i_pos layout helpers Adi Nata
2026-04-05 5:18 ` OGAWA Hirofumi [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87y0j2m1d0.fsf@mail.parknet.co.jp \
--to=hirofumi@mail.parknet.co.jp \
--cc=adinata.softwareengineer@gmail.com \
--cc=brauner@kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox