Lines Matching full:test
3 * KUnit test for clk fixed rate basic type
15 #include <kunit/test.h>
77 * clk_hw_register_fixed_rate_kunit() - Test managed __clk_hw_register_fixed_rate()
78 * @test: The test context
84 clk_hw_register_fixed_rate_kunit(struct kunit *test, in clk_hw_register_fixed_rate_kunit() argument
89 hw = kunit_alloc_resource(test, in clk_hw_register_fixed_rate_kunit()
100 * clk_hw_unregister_fixed_rate_kunit() - Test managed clk_hw_unregister_fixed_rate()
101 * @test: The test context
102 * @hw: fixed rate clk to unregister upon test completion
104 * Automatically unregister @hw when @test is complete via
109 static int clk_hw_unregister_fixed_rate_kunit(struct kunit *test, struct clk_hw *hw) in clk_hw_unregister_fixed_rate_kunit() argument
111 if (!kunit_alloc_resource(test, NULL, in clk_hw_unregister_fixed_rate_kunit()
120 * Test that clk_get_rate() on a fixed rate clk registered with
123 static void clk_fixed_rate_rate_test(struct kunit *test) in clk_fixed_rate_rate_test() argument
129 hw = clk_hw_register_fixed_rate(NULL, "test-fixed-rate", NULL, 0, fixed_rate); in clk_fixed_rate_rate_test()
130 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, hw); in clk_fixed_rate_rate_test()
131 KUNIT_ASSERT_EQ(test, 0, clk_hw_unregister_fixed_rate_kunit(test, hw)); in clk_fixed_rate_rate_test()
133 clk = clk_hw_get_clk_prepared_enabled_kunit(test, hw, __func__); in clk_fixed_rate_rate_test()
134 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, clk); in clk_fixed_rate_rate_test()
136 KUNIT_EXPECT_EQ(test, fixed_rate, clk_get_rate(clk)); in clk_fixed_rate_rate_test()
140 * Test that clk_get_accuracy() on a fixed rate clk registered via
143 static void clk_fixed_rate_accuracy_test(struct kunit *test) in clk_fixed_rate_accuracy_test() argument
149 hw = clk_hw_register_fixed_rate_with_accuracy(NULL, "test-fixed-rate", in clk_fixed_rate_accuracy_test()
152 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, hw); in clk_fixed_rate_accuracy_test()
153 KUNIT_ASSERT_EQ(test, 0, clk_hw_unregister_fixed_rate_kunit(test, hw)); in clk_fixed_rate_accuracy_test()
155 clk = clk_hw_get_clk_kunit(test, hw, __func__); in clk_fixed_rate_accuracy_test()
156 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, clk); in clk_fixed_rate_accuracy_test()
158 KUNIT_EXPECT_EQ(test, fixed_accuracy, clk_get_accuracy(clk)); in clk_fixed_rate_accuracy_test()
161 /* Test suite for a fixed rate clk without any parent */
174 * Test that clk_get_parent() on a fixed rate clk gets the proper parent.
176 static void clk_fixed_rate_parent_test(struct kunit *test) in clk_fixed_rate_parent_test() argument
181 const char *parent_name = "test-fixed-rate-parent"; in clk_fixed_rate_parent_test()
186 parent_hw = clk_hw_register_fixed_rate_kunit(test, &parent_params); in clk_fixed_rate_parent_test()
187 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, parent_hw); in clk_fixed_rate_parent_test()
188 KUNIT_ASSERT_STREQ(test, parent_name, clk_hw_get_name(parent_hw)); in clk_fixed_rate_parent_test()
190 expected_parent = clk_hw_get_clk_kunit(test, parent_hw, __func__); in clk_fixed_rate_parent_test()
191 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, expected_parent); in clk_fixed_rate_parent_test()
193 hw = clk_hw_register_fixed_rate(NULL, "test-fixed-rate", parent_name, 0, 0); in clk_fixed_rate_parent_test()
194 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, hw); in clk_fixed_rate_parent_test()
195 KUNIT_ASSERT_EQ(test, 0, clk_hw_unregister_fixed_rate_kunit(test, hw)); in clk_fixed_rate_parent_test()
197 clk = clk_hw_get_clk_kunit(test, hw, __func__); in clk_fixed_rate_parent_test()
198 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, clk); in clk_fixed_rate_parent_test()
201 KUNIT_EXPECT_TRUE(test, clk_is_match(expected_parent, actual_parent)); in clk_fixed_rate_parent_test()
205 * Test that clk_get_rate() on a fixed rate clk ignores the parent rate.
207 static void clk_fixed_rate_parent_rate_test(struct kunit *test) in clk_fixed_rate_parent_rate_test() argument
213 const char *parent_name = "test-fixed-rate-parent"; in clk_fixed_rate_parent_rate_test()
219 parent_hw = clk_hw_register_fixed_rate_kunit(test, &parent_params); in clk_fixed_rate_parent_rate_test()
220 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, parent_hw); in clk_fixed_rate_parent_rate_test()
221 KUNIT_ASSERT_STREQ(test, parent_name, clk_hw_get_name(parent_hw)); in clk_fixed_rate_parent_rate_test()
223 hw = clk_hw_register_fixed_rate(NULL, "test-fixed-rate", parent_name, 0, in clk_fixed_rate_parent_rate_test()
225 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, hw); in clk_fixed_rate_parent_rate_test()
226 KUNIT_ASSERT_EQ(test, 0, clk_hw_unregister_fixed_rate_kunit(test, hw)); in clk_fixed_rate_parent_rate_test()
228 clk = clk_hw_get_clk_prepared_enabled_kunit(test, hw, __func__); in clk_fixed_rate_parent_rate_test()
229 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, clk); in clk_fixed_rate_parent_rate_test()
231 KUNIT_EXPECT_EQ(test, expected_rate, clk_get_rate(clk)); in clk_fixed_rate_parent_rate_test()
235 * Test that clk_get_accuracy() on a fixed rate clk ignores the parent accuracy.
237 static void clk_fixed_rate_parent_accuracy_test(struct kunit *test) in clk_fixed_rate_parent_accuracy_test() argument
243 const char *parent_name = "test-fixed-rate-parent"; in clk_fixed_rate_parent_accuracy_test()
249 parent_hw = clk_hw_register_fixed_rate_kunit(test, &parent_params); in clk_fixed_rate_parent_accuracy_test()
250 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, parent_hw); in clk_fixed_rate_parent_accuracy_test()
251 KUNIT_ASSERT_STREQ(test, parent_name, clk_hw_get_name(parent_hw)); in clk_fixed_rate_parent_accuracy_test()
253 hw = clk_hw_register_fixed_rate_with_accuracy(NULL, "test-fixed-rate", in clk_fixed_rate_parent_accuracy_test()
256 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, hw); in clk_fixed_rate_parent_accuracy_test()
257 KUNIT_ASSERT_EQ(test, 0, clk_hw_unregister_fixed_rate_kunit(test, hw)); in clk_fixed_rate_parent_accuracy_test()
259 clk = clk_hw_get_clk_kunit(test, hw, __func__); in clk_fixed_rate_parent_accuracy_test()
260 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, clk); in clk_fixed_rate_parent_accuracy_test()
262 KUNIT_EXPECT_EQ(test, expected_accuracy, clk_get_accuracy(clk)); in clk_fixed_rate_parent_accuracy_test()
265 /* Test suite for a fixed rate clk with a parent */
293 * Test that of_fixed_clk_setup() registers a fixed rate clk with the proper
296 static void clk_fixed_rate_of_probe_test(struct kunit *test) in clk_fixed_rate_of_probe_test() argument
298 struct clk_fixed_rate_of_test_context *ctx = test->priv; in clk_fixed_rate_of_probe_test()
302 clk = clk_get_kunit(test, dev, NULL); in clk_fixed_rate_of_probe_test()
303 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, clk); in clk_fixed_rate_of_probe_test()
305 KUNIT_ASSERT_EQ(test, 0, clk_prepare_enable_kunit(test, clk)); in clk_fixed_rate_of_probe_test()
306 KUNIT_EXPECT_EQ(test, TEST_FIXED_FREQUENCY, clk_get_rate(clk)); in clk_fixed_rate_of_probe_test()
310 * Test that of_fixed_clk_setup() registers a fixed rate clk with the proper
313 static void clk_fixed_rate_of_accuracy_test(struct kunit *test) in clk_fixed_rate_of_accuracy_test() argument
315 struct clk_fixed_rate_of_test_context *ctx = test->priv; in clk_fixed_rate_of_accuracy_test()
319 clk = clk_get_kunit(test, dev, NULL); in clk_fixed_rate_of_accuracy_test()
320 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, clk); in clk_fixed_rate_of_accuracy_test()
322 KUNIT_EXPECT_EQ(test, TEST_FIXED_ACCURACY, clk_get_accuracy(clk)); in clk_fixed_rate_of_accuracy_test()
342 static int clk_fixed_rate_of_init(struct kunit *test) in clk_fixed_rate_of_init() argument
346 { .compatible = "test,single-clk-consumer" }, in clk_fixed_rate_of_init()
350 KUNIT_ASSERT_EQ(test, 0, of_overlay_apply_kunit(test, kunit_clk_fixed_rate_test)); in clk_fixed_rate_of_init()
352 ctx = kunit_kzalloc(test, sizeof(*ctx), GFP_KERNEL); in clk_fixed_rate_of_init()
353 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ctx); in clk_fixed_rate_of_init()
354 test->priv = ctx; in clk_fixed_rate_of_init()
362 KUNIT_ASSERT_EQ(test, 0, kunit_platform_driver_register(test, &ctx->pdrv)); in clk_fixed_rate_of_init()
363 KUNIT_ASSERT_NE(test, 0, wait_for_completion_timeout(&ctx->probed, HZ)); in clk_fixed_rate_of_init()
380 MODULE_DESCRIPTION("KUnit test for clk fixed rate basic type");