]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
test: dm: k210: Reduce duplication in test cases
authorSean Anderson <seanga2@gmail.com>
Sat, 11 Sep 2021 17:20:02 +0000 (13:20 -0400)
committerLeo Yu-Chi Liang <ycliang@andestech.com>
Thu, 7 Oct 2021 08:08:23 +0000 (16:08 +0800)
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>
Reviewed-by: Leo Yu-Chi Liang <ycliang@andestech.com>
test/dm/k210_pll.c

index 54764f269c58b304f756918fa3864be0050c23b0..5574ac96fa3e655cf4f98bfa699632a7b18d2e73 100644 (file)
@@ -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));
-
-       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));
+#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)
+
+       compare(390000000, 26000000);
+       compare(26000000, 390000000);
+       compare(400000000, 26000000);
+       compare(27000000, 26000000);
+       compare(26000000, 27000000);
 
        return 0;
 }