[PATCH v2 2/2] clk: tests: Add missing test case for mux determine_rate

From: Yang Xiwen via B4 Relay
Date: Tue Apr 25 2023 - 03:47:12 EST


From: Yang Xiwen <forbidden405@xxxxxxxxxxx>

Add a missing test case for determine_rate implemented by mux. It tests
the behavior of determine_rate when requesting a rate that none of the
parents could give.

Signed-off-by: Yang Xiwen <forbidden405@xxxxxxxxxxx>
---
drivers/clk/clk_test.c | 9 +++++++++
1 file changed, 9 insertions(+)

diff --git a/drivers/clk/clk_test.c b/drivers/clk/clk_test.c
index f9a5c2964c65d..9b1c90de90454 100644
--- a/drivers/clk/clk_test.c
+++ b/drivers/clk/clk_test.c
@@ -2215,6 +2215,15 @@ static void clk_leaf_mux_set_rate_parent_determine_rate(struct kunit *test)
KUNIT_EXPECT_EQ(test, req.best_parent_rate, DUMMY_CLOCK_RATE_2);
KUNIT_EXPECT_PTR_EQ(test, req.best_parent_hw, &ctx->mux_ctx.hw);

+ // Test a non-existant rate which none of the parents could give
+ clk_hw_init_rate_request(hw, &req, DUMMY_CLOCK_INIT_RATE);
+
+ ret = __clk_determine_rate(hw, &req);
+ KUNIT_ASSERT_EQ(test, ret, 0);
+
+ KUNIT_EXPECT_EQ(test, req.rate, DUMMY_CLOCK_RATE_1);
+ KUNIT_EXPECT_EQ(test, req.best_parent_rate, DUMMY_CLOCK_RATE_1);
+ KUNIT_EXPECT_PTR_EQ(test, req.best_parent_hw, &ctx->mux_ctx.hw);
clk_put(clk);
}


--
2.39.2