diff mbox series

[v2,3/4] test: dm: k210: Reduce duplication in test cases

Message ID 20210911172003.899301-3-seanga2@gmail.com
State Accepted
Delegated to: Andes
Headers show
Series [v2,1/4] clk: k210: Fix checking if ulongs are less than 0 | expand

Commit Message

Sean Anderson Sept. 11, 2021, 5:20 p.m. UTC
Having to copy-paste the same 3 lines makes adding new test cases
error-prone. Use a macro.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
---

(no changes since v1)

 test/dm/k210_pll.c | 30 ++++++++++++------------------
 1 file changed, 12 insertions(+), 18 deletions(-)

Comments

Leo Liang Sept. 14, 2021, 8:48 a.m. UTC | #1
On Sat, Sep 11, 2021 at 01:20:02PM -0400, Sean Anderson wrote:
> Having to copy-paste the same 3 lines makes adding new test cases
> error-prone. Use a macro.
>
> Signed-off-by: Sean Anderson <seanga2@gmail.com>
> Reviewed-by: Simon Glass <sjg@chromium.org>
> ---
>
> (no changes since v1)
>
>  test/dm/k210_pll.c | 30 ++++++++++++------------------
>  1 file changed, 12 insertions(+), 18 deletions(-)
>
Reviewed-by: Leo Yu-Chi Liang <ycliang@andestech.com>
CONFIDENTIALITY NOTICE:

This e-mail (and its attachments) may contain confidential and legally privileged information or information protected from disclosure. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution, or use of the information contained herein is strictly prohibited. In this case, please immediately notify the sender by return e-mail, delete the message (and any accompanying documents) and destroy all printed hard copies. Thank you for your cooperation.

Copyright ANDES TECHNOLOGY CORPORATION - All Rights Reserved.
diff mbox series

Patch

diff --git a/test/dm/k210_pll.c b/test/dm/k210_pll.c
index 54764f269c..5574ac96fa 100644
--- a/test/dm/k210_pll.c
+++ b/test/dm/k210_pll.c
@@ -69,27 +69,21 @@  static int dm_test_k210_pll(struct unit_test_state *uts)
 						  &theirs));
 	ut_asserteq(-EINVAL, k210_pll_calc_config(1500000000, 20000000,
 						  &theirs));
+	ut_asserteq(-EINVAL, k210_pll_calc_config(1750000000, 13300000,
+						  &theirs));
 
 	/* Verify we get the same output with brute-force */
-	ut_assertok(dm_test_k210_pll_calc_config(390000000, 26000000, &ours));
-	ut_assertok(k210_pll_calc_config(390000000, 26000000, &theirs));
-	ut_assertok(dm_test_k210_pll_compare(&ours, &theirs));
+#define compare(rate, rate_in) do { \
+	ut_assertok(dm_test_k210_pll_calc_config(rate, rate_in, &ours)); \
+	ut_assertok(k210_pll_calc_config(rate, rate_in, &theirs)); \
+	ut_assertok(dm_test_k210_pll_compare(&ours, &theirs)); \
+} while (0)
 
-	ut_assertok(dm_test_k210_pll_calc_config(26000000, 390000000, &ours));
-	ut_assertok(k210_pll_calc_config(26000000, 390000000, &theirs));
-	ut_assertok(dm_test_k210_pll_compare(&ours, &theirs));
-
-	ut_assertok(dm_test_k210_pll_calc_config(400000000, 26000000, &ours));
-	ut_assertok(k210_pll_calc_config(400000000, 26000000, &theirs));
-	ut_assertok(dm_test_k210_pll_compare(&ours, &theirs));
-
-	ut_assertok(dm_test_k210_pll_calc_config(27000000, 26000000, &ours));
-	ut_assertok(k210_pll_calc_config(27000000, 26000000, &theirs));
-	ut_assertok(dm_test_k210_pll_compare(&ours, &theirs));
-
-	ut_assertok(dm_test_k210_pll_calc_config(26000000, 27000000, &ours));
-	ut_assertok(k210_pll_calc_config(26000000, 27000000, &theirs));
-	ut_assertok(dm_test_k210_pll_compare(&ours, &theirs));
+	compare(390000000, 26000000);
+	compare(26000000, 390000000);
+	compare(400000000, 26000000);
+	compare(27000000, 26000000);
+	compare(26000000, 27000000);
 
 	return 0;
 }