Re: [PATCH] fat: add KUnit tests for timestamp conversion helpers

From: OGAWA Hirofumi

Date: Sun Mar 15 2026 - 13:45:54 EST


aviv.daum@xxxxxxxxx writes:

> +static void fat_time_unix2fat_clamp_test(struct kunit *test)
> +{
> + static struct msdos_sb_info fake_sb;
> + __le16 date, time;
> + u8 cs;
> + struct fat_unix2fat_clamp_testcase *testcase =
> + (struct fat_unix2fat_clamp_testcase *)test->param_value;
> +
> + fat_test_set_time_offset(&fake_sb, testcase->time_offset);
> +
> + fat_time_unix2fat(&fake_sb, &testcase->ts, &time, &date, &cs);
> + KUNIT_EXPECT_EQ_MSG(test,
> + le16_to_cpu(testcase->time),
> + le16_to_cpu(time),
> + "Clamped time mismatch\n");
> + KUNIT_EXPECT_EQ_MSG(test,
> + le16_to_cpu(testcase->date),
> + le16_to_cpu(date),
> + "Clamped date mismatch\n");

It is unnecessary to convert to native endian?

> + KUNIT_EXPECT_EQ_MSG(test,
> + testcase->cs,
> + cs,
> + "Clamped centisecond mismatch\n");
> +}

--
OGAWA Hirofumi <hirofumi@xxxxxxxxxxxxxxxxxx>