From: Stefan Roese <sr@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 4/4 v2] dm: test: Add test for device removal
Date: Mon, 20 Mar 2017 12:51:51 +0100 [thread overview]
Message-ID: <20170320115151.15155-4-sr@denx.de> (raw)
In-Reply-To: <20170320115151.15155-1-sr@denx.de>
Add a test for the correct device removal. Currently two different ways
for device removal are supported:
- Normal device removal via the device_remove() API
- Removal via selective device driver flags (DM_FLAG_ACTIVE_DMA)
This new test "remove_active_dma" adds tests cases for those both ways
of removal.
Signed-off-by: Stefan Roese <sr@denx.de>
Cc: Simon Glass <sjg@chromium.org>
---
v2:
- New patch in patchset
test/dm/core.c | 41 +++++++++++++++++++++++++++++++++++++++++
test/dm/test-driver.c | 1 +
2 files changed, 42 insertions(+)
diff --git a/test/dm/core.c b/test/dm/core.c
index 07b2419ea4..ef85e6b79c 100644
--- a/test/dm/core.c
+++ b/test/dm/core.c
@@ -656,6 +656,47 @@ static int dm_test_pre_reloc(struct unit_test_state *uts)
}
DM_TEST(dm_test_pre_reloc, 0);
+/*
+ * Test that removal of devices, either via the "normal" device_remove()
+ * API or via the device driver selective flag works as expected
+ */
+static int dm_test_remove_active_dma(struct unit_test_state *uts)
+{
+ struct dm_test_state *dms = uts->priv;
+ struct udevice *dev;
+
+ ut_assertok(device_bind_by_name(dms->root, false, &driver_info_manual,
+ &dev));
+ ut_assert(dev);
+
+ /* Probe the device */
+ ut_assertok(device_probe(dev));
+
+ /* Test if device is active right now */
+ ut_asserteq(true, device_active(dev));
+
+ /* Remove the device via selective remove flag */
+ dm_remove_devices_flags(DM_REMOVE_ACTIVE_ALL);
+
+ /* Test if device is inactive right now */
+ ut_asserteq(false, device_active(dev));
+
+ /* Probe the device again */
+ ut_assertok(device_probe(dev));
+
+ /* Test if device is active right now */
+ ut_asserteq(true, device_active(dev));
+
+ /* Remove the device via "normal" remove API */
+ ut_assertok(device_remove(dev, DM_REMOVE_NORMAL));
+
+ /* Test if device is inactive right now */
+ ut_asserteq(false, device_active(dev));
+
+ return 0;
+}
+DM_TEST(dm_test_remove_active_dma, 0);
+
static int dm_test_uclass_before_ready(struct unit_test_state *uts)
{
struct uclass *uc;
diff --git a/test/dm/test-driver.c b/test/dm/test-driver.c
index d10af51147..1a2932e519 100644
--- a/test/dm/test-driver.c
+++ b/test/dm/test-driver.c
@@ -145,6 +145,7 @@ U_BOOT_DRIVER(test_manual_drv) = {
.probe = test_manual_probe,
.remove = test_manual_remove,
.unbind = test_manual_unbind,
+ .flags = DM_FLAG_ACTIVE_DMA,
};
U_BOOT_DRIVER(test_pre_reloc_drv) = {
--
2.12.0
next prev parent reply other threads:[~2017-03-20 11:51 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-20 11:51 [U-Boot] [PATCH 1/4 v2] dm: core: Add flags parameter to device_remove() Stefan Roese
2017-03-20 11:51 ` [U-Boot] [PATCH 2/4 v2] dm: core: Add dm_remove_devices_flags() and hook it into device_remove() Stefan Roese
2017-03-20 11:51 ` [U-Boot] [PATCH 3/4 v2] arm: bootm: Add dm_remove_devices_flags() call to announce_and_cleanup() Stefan Roese
2017-04-05 3:27 ` Simon Glass
2017-03-20 11:51 ` Stefan Roese [this message]
2017-03-26 3:52 ` [U-Boot] [PATCH 4/4 v2] dm: test: Add test for device removal Simon Glass
2017-03-27 6:48 ` Stefan Roese
2017-03-22 6:28 ` [U-Boot] [PATCH 2/4 v3] dm: core: Add dm_remove_devices_flags() and hook it into device_remove() Stefan Roese
2017-03-26 1:17 ` Simon Glass
2017-03-26 3:52 ` Simon Glass
2017-03-27 8:31 ` Stefan Roese
2017-03-26 1:17 ` [U-Boot] [PATCH 1/4 v2] dm: core: Add flags parameter to device_remove() Simon Glass
2017-04-05 3:27 ` Simon Glass
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=20170320115151.15155-4-sr@denx.de \
--to=sr@denx.de \
--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