public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Neil Armstrong <narmstrong@baylibre.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH u-boot v3 2/3] test: regmap: add regmap_read_poll_timeout test
Date: Wed, 14 Nov 2018 11:25:19 +0100	[thread overview]
Message-ID: <20181114102520.25346-3-narmstrong@baylibre.com> (raw)
In-Reply-To: <20181114102520.25346-1-narmstrong@baylibre.com>

Add test to regmap_read_poll_timeout() helper to check the timeout works
properly but cannot test proper condition matching since read/write calls
are not executed in sandbox.

Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
---
 test/dm/regmap.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/test/dm/regmap.c b/test/dm/regmap.c
index d4b86b3b03..00d61fe38c 100644
--- a/test/dm/regmap.c
+++ b/test/dm/regmap.c
@@ -116,3 +116,29 @@ static int dm_test_regmap_rw(struct unit_test_state *uts)
 }
 
 DM_TEST(dm_test_regmap_rw, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+
+/* Read polling test */
+static int dm_test_regmap_poll(struct unit_test_state *uts)
+{
+	struct udevice *dev;
+	struct regmap *map;
+	uint reg;
+	unsigned long start;
+
+	ut_assertok(uclass_get_device(UCLASS_SYSCON, 0, &dev));
+	map = syscon_get_regmap(dev);
+	ut_assertok_ptr(map);
+
+	start = get_timer(0);
+
+	ut_asserteq(-ETIMEDOUT,
+		    regmap_read_poll_timeout(map, 0, reg,
+					     (reg == 0xcacafafa),
+					     1, 5 * CONFIG_SYS_HZ));
+
+	ut_assert(get_timer(start) > (5 * CONFIG_SYS_HZ));
+
+	return 0;
+}
+
+DM_TEST(dm_test_regmap_poll, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
-- 
2.19.1

  parent reply	other threads:[~2018-11-14 10:25 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-14 10:25 [U-Boot] [PATCH u-boot v3 0/3] Add Amlogic Meson SPI Flash Controller driver Neil Armstrong
2018-11-14 10:25 ` [U-Boot] [PATCH u-boot v3 1/3] regmap: add regmap_read_poll_timeout() helper Neil Armstrong
2018-11-14 13:09   ` Jagan Teki
2018-11-14 10:25 ` Neil Armstrong [this message]
2018-11-14 13:09   ` [U-Boot] [PATCH u-boot v3 2/3] test: regmap: add regmap_read_poll_timeout test Jagan Teki
2018-11-14 10:25 ` [U-Boot] [PATCH u-boot v3 3/3] spi: Add Amlogic Meson SPI Flash Controller driver Neil Armstrong
2018-11-14 13:11   ` Jagan Teki
2018-11-14 13:12     ` Neil Armstrong
2018-11-15 15:41 ` [U-Boot] [PATCH u-boot v3 0/3] " Jerome Brunet
2018-11-22  6:40 ` Jagan Teki
2018-11-22  8:21   ` Neil Armstrong
  -- strict thread matches above, loose matches on Subject: below --
2018-11-22 10:01 Neil Armstrong
2018-11-22 10:01 ` [U-Boot] [PATCH u-boot v3 2/3] test: regmap: add regmap_read_poll_timeout test Neil Armstrong

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=20181114102520.25346-3-narmstrong@baylibre.com \
    --to=narmstrong@baylibre.com \
    --cc=u-boot@lists.denx.de \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox