From: Sean Anderson <seanga2@gmail.com>
To: u-boot@lists.denx.de, Leo Liang <ycliang@andestech.com>
Cc: Bin Meng <bmeng.cn@gmail.com>,
Damien Le Moal <Damien.LeMoal@wdc.com>,
Lukasz Majewski <lukma@denx.de>,
Sean Anderson <seanga2@gmail.com>, Simon Glass <sjg@chromium.org>
Subject: [PATCH v2 3/4] test: dm: k210: Reduce duplication in test cases
Date: Sat, 11 Sep 2021 13:20:02 -0400 [thread overview]
Message-ID: <20210911172003.899301-3-seanga2@gmail.com> (raw)
In-Reply-To: <20210911172003.899301-1-seanga2@gmail.com>
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(-)
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;
}
--
2.33.0
next prev parent reply other threads:[~2021-09-11 17:20 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-11 17:20 [PATCH v2 1/4] clk: k210: Fix checking if ulongs are less than 0 Sean Anderson
2021-09-11 17:20 ` [PATCH v2 2/4] k210: clk: Refactor out_of_spec tests Sean Anderson
2021-09-14 8:45 ` Leo Liang
2021-09-11 17:20 ` Sean Anderson [this message]
2021-09-14 8:48 ` [PATCH v2 3/4] test: dm: k210: Reduce duplication in test cases Leo Liang
2021-09-11 17:20 ` [PATCH v2 4/4] clk: k210: Try harder to get the best config Sean Anderson
2021-09-30 4:08 ` Simon Glass
2021-09-14 8:39 ` [PATCH v2 1/4] clk: k210: Fix checking if ulongs are less than 0 Leo Liang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210911172003.899301-3-seanga2@gmail.com \
--to=seanga2@gmail.com \
--cc=Damien.LeMoal@wdc.com \
--cc=bmeng.cn@gmail.com \
--cc=lukma@denx.de \
--cc=sjg@chromium.org \
--cc=u-boot@lists.denx.de \
--cc=ycliang@andestech.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.