summaryrefslogtreecommitdiff
path: root/test/dm
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2020-02-11 10:58:41 -0500
committerTom Rini <trini@konsulko.com>2020-02-11 10:58:41 -0500
commit9a8942b53d57149754e0dfc975e0d92d1afd4087 (patch)
treede55e5352f3a8a79c413c0b8cb533428e5476841 /test/dm
parentae347120eed8204b1fdf018ddf79131964e57016 (diff)
parent21d651fb29cf268b1a5f64d080e3d352ee32c87f (diff)
Merge tag 'dm-pull-6feb20' of https://gitlab.denx.de/u-boot/custodians/u-boot-dm
sandbox conversion to SDL2 TPM TEE driver Various minor sandbox video enhancements New driver model core utility functions
Diffstat (limited to 'test/dm')
-rw-r--r--test/dm/clk.c1
-rw-r--r--test/dm/devres.c1
-rw-r--r--test/dm/dma.c1
-rw-r--r--test/dm/gpio.c1
-rw-r--r--test/dm/mailbox.c1
-rw-r--r--test/dm/ofnode.c55
-rw-r--r--test/dm/power-domain.c1
-rw-r--r--test/dm/regmap.c1
-rw-r--r--test/dm/reset.c1
-rw-r--r--test/dm/sound.c1
-rw-r--r--test/dm/spmi.c1
-rw-r--r--test/dm/syscon.c1
-rw-r--r--test/dm/tee.c1
-rw-r--r--test/dm/test-fdt.c39
-rw-r--r--test/dm/test-main.c4
-rw-r--r--test/dm/video.c1
16 files changed, 109 insertions, 2 deletions
diff --git a/test/dm/clk.c b/test/dm/clk.c
index 31335a543f1..003b78934f3 100644
--- a/test/dm/clk.c
+++ b/test/dm/clk.c
@@ -6,6 +6,7 @@
#include <common.h>
#include <clk.h>
#include <dm.h>
+#include <malloc.h>
#include <asm/clk.h>
#include <dm/test.h>
#include <dm/device-internal.h>
diff --git a/test/dm/devres.c b/test/dm/devres.c
index e7331897de8..cbd0972c9b4 100644
--- a/test/dm/devres.c
+++ b/test/dm/devres.c
@@ -10,6 +10,7 @@
#include <dm.h>
#include <malloc.h>
#include <dm/device-internal.h>
+#include <dm/devres.h>
#include <dm/test.h>
#include <dm/uclass-internal.h>
#include <test/ut.h>
diff --git a/test/dm/dma.c b/test/dm/dma.c
index b56d17731d5..12cba57a56f 100644
--- a/test/dm/dma.c
+++ b/test/dm/dma.c
@@ -8,6 +8,7 @@
#include <common.h>
#include <dm.h>
+#include <malloc.h>
#include <dm/test.h>
#include <dma.h>
#include <test/ut.h>
diff --git a/test/dm/gpio.c b/test/dm/gpio.c
index bb4b20cea93..349123a657c 100644
--- a/test/dm/gpio.c
+++ b/test/dm/gpio.c
@@ -6,6 +6,7 @@
#include <common.h>
#include <fdtdec.h>
#include <dm.h>
+#include <malloc.h>
#include <dm/root.h>
#include <dm/test.h>
#include <dm/util.h>
diff --git a/test/dm/mailbox.c b/test/dm/mailbox.c
index 4562d2ac4f8..e6c521b8b54 100644
--- a/test/dm/mailbox.c
+++ b/test/dm/mailbox.c
@@ -5,6 +5,7 @@
#include <common.h>
#include <dm.h>
+#include <malloc.h>
#include <dm/test.h>
#include <asm/mbox.h>
#include <test/ut.h>
diff --git a/test/dm/ofnode.c b/test/dm/ofnode.c
index 745de50c7ba..1c49eaf38bf 100644
--- a/test/dm/ofnode.c
+++ b/test/dm/ofnode.c
@@ -58,3 +58,58 @@ static int dm_test_ofnode_fmap(struct unit_test_state *uts)
return 0;
}
DM_TEST(dm_test_ofnode_fmap, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+
+static int dm_test_ofnode_read(struct unit_test_state *uts)
+{
+ const u32 *val;
+ ofnode node;
+ int size;
+
+ node = ofnode_path("/a-test");
+ ut_assert(ofnode_valid(node));
+
+ val = ofnode_read_prop(node, "int-value", &size);
+ ut_assertnonnull(val);
+ ut_asserteq(4, size);
+ ut_asserteq(1234, fdt32_to_cpu(val[0]));
+
+ val = ofnode_read_prop(node, "missing", &size);
+ ut_assertnull(val);
+ ut_asserteq(-FDT_ERR_NOTFOUND, size);
+
+ /* Check it works without a size parameter */
+ val = ofnode_read_prop(node, "missing", NULL);
+ ut_assertnull(val);
+
+ return 0;
+}
+DM_TEST(dm_test_ofnode_read, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+
+static int dm_test_ofnode_read_chosen(struct unit_test_state *uts)
+{
+ const char *str;
+ const u32 *val;
+ ofnode node;
+ int size;
+
+ str = ofnode_read_chosen_string("setting");
+ ut_assertnonnull(str);
+ ut_asserteq_str("sunrise ohoka", str);
+ ut_asserteq_ptr(NULL, ofnode_read_chosen_string("no-setting"));
+
+ node = ofnode_get_chosen_node("other-node");
+ ut_assert(ofnode_valid(node));
+ ut_asserteq_str("c-test@5", ofnode_get_name(node));
+
+ node = ofnode_get_chosen_node("setting");
+ ut_assert(!ofnode_valid(node));
+
+ val = ofnode_read_chosen_prop("int-values", &size);
+ ut_assertnonnull(val);
+ ut_asserteq(8, size);
+ ut_asserteq(0x1937, fdt32_to_cpu(val[0]));
+ ut_asserteq(72993, fdt32_to_cpu(val[1]));
+
+ return 0;
+}
+DM_TEST(dm_test_ofnode_read_chosen, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
diff --git a/test/dm/power-domain.c b/test/dm/power-domain.c
index 48318218a9e..8baf5d09d1d 100644
--- a/test/dm/power-domain.c
+++ b/test/dm/power-domain.c
@@ -5,6 +5,7 @@
#include <common.h>
#include <dm.h>
+#include <malloc.h>
#include <dm/test.h>
#include <asm/power-domain.h>
#include <test/ut.h>
diff --git a/test/dm/regmap.c b/test/dm/regmap.c
index 6fd1f20656b..b21f66732b9 100644
--- a/test/dm/regmap.c
+++ b/test/dm/regmap.c
@@ -10,6 +10,7 @@
#include <syscon.h>
#include <asm/test.h>
#include <dm/test.h>
+#include <linux/err.h>
#include <test/ut.h>
/* Base test of register maps */
diff --git a/test/dm/reset.c b/test/dm/reset.c
index c61daed4903..8370820428c 100644
--- a/test/dm/reset.c
+++ b/test/dm/reset.c
@@ -5,6 +5,7 @@
#include <common.h>
#include <dm.h>
+#include <malloc.h>
#include <reset.h>
#include <dm/test.h>
#include <asm/reset.h>
diff --git a/test/dm/sound.c b/test/dm/sound.c
index 3767abbd1c7..aa5368f05b9 100644
--- a/test/dm/sound.c
+++ b/test/dm/sound.c
@@ -28,6 +28,7 @@ static int dm_test_sound(struct unit_test_state *uts)
ut_asserteq(4560, sandbox_get_sound_sum(dev));
ut_assertok(sound_beep(dev, 1, 100));
ut_asserteq(9120, sandbox_get_sound_sum(dev));
+ ut_asserteq(false, sandbox_get_sound_active(dev));
return 0;
}
diff --git a/test/dm/spmi.c b/test/dm/spmi.c
index e6a910859e3..668b7e133ff 100644
--- a/test/dm/spmi.c
+++ b/test/dm/spmi.c
@@ -6,6 +6,7 @@
#include <common.h>
#include <fdtdec.h>
#include <dm.h>
+#include <malloc.h>
#include <dm/device.h>
#include <dm/root.h>
#include <dm/test.h>
diff --git a/test/dm/syscon.c b/test/dm/syscon.c
index 0ff9da7ec63..f1021f374b6 100644
--- a/test/dm/syscon.c
+++ b/test/dm/syscon.c
@@ -9,6 +9,7 @@
#include <regmap.h>
#include <asm/test.h>
#include <dm/test.h>
+#include <linux/err.h>
#include <test/ut.h>
/* Base test of system controllers */
diff --git a/test/dm/tee.c b/test/dm/tee.c
index 22f05a42197..d40f13d2915 100644
--- a/test/dm/tee.c
+++ b/test/dm/tee.c
@@ -5,6 +5,7 @@
#include <common.h>
#include <dm.h>
+#include <malloc.h>
#include <dm/test.h>
#include <sandboxtee.h>
#include <tee.h>
diff --git a/test/dm/test-fdt.c b/test/dm/test-fdt.c
index 698ca0e7cf8..75ae08081cd 100644
--- a/test/dm/test-fdt.c
+++ b/test/dm/test-fdt.c
@@ -12,6 +12,7 @@
#include <dm/test.h>
#include <dm/root.h>
#include <dm/device-internal.h>
+#include <dm/devres.h>
#include <dm/uclass-internal.h>
#include <dm/util.h>
#include <dm/lists.h>
@@ -914,3 +915,41 @@ static int dm_test_uclass_drvdata(struct unit_test_state *uts)
return 0;
}
DM_TEST(dm_test_uclass_drvdata, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+
+/* Test device_first_child_ofdata_err(), etc. */
+static int dm_test_child_ofdata(struct unit_test_state *uts)
+{
+ struct udevice *bus, *dev;
+ int count;
+
+ ut_assertok(uclass_first_device_err(UCLASS_TEST_BUS, &bus));
+ count = 0;
+ device_foreach_child_ofdata_to_platdata(dev, bus) {
+ ut_assert(dev->flags & DM_FLAG_PLATDATA_VALID);
+ ut_assert(!(dev->flags & DM_FLAG_ACTIVATED));
+ count++;
+ }
+ ut_asserteq(3, count);
+
+ return 0;
+}
+DM_TEST(dm_test_child_ofdata, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+
+/* Test device_first_child_err(), etc. */
+static int dm_test_first_child_probe(struct unit_test_state *uts)
+{
+ struct udevice *bus, *dev;
+ int count;
+
+ ut_assertok(uclass_first_device_err(UCLASS_TEST_BUS, &bus));
+ count = 0;
+ device_foreach_child_probe(dev, bus) {
+ ut_assert(dev->flags & DM_FLAG_PLATDATA_VALID);
+ ut_assert(dev->flags & DM_FLAG_ACTIVATED);
+ count++;
+ }
+ ut_asserteq(3, count);
+
+ return 0;
+}
+DM_TEST(dm_test_first_child_probe, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
diff --git a/test/dm/test-main.c b/test/dm/test-main.c
index 72648162a91..d7dc8d1f915 100644
--- a/test/dm/test-main.c
+++ b/test/dm/test-main.c
@@ -97,11 +97,11 @@ static int dm_do_test(struct unit_test_state *uts, struct unit_test *test,
* Silence the console and rely on console recording to get
* our output.
*/
- console_record_reset();
+ console_record_reset_enable();
if (!state->show_test_output)
gd->flags |= GD_FLG_SILENT;
test->func(uts);
- gd->flags &= ~GD_FLG_SILENT;
+ gd->flags &= ~(GD_FLG_SILENT | GD_FLG_RECORD);
state_set_skip_delays(false);
ut_assertok(dm_test_destroy(uts));
diff --git a/test/dm/video.c b/test/dm/video.c
index 3151ebb73fc..f72979fac4e 100644
--- a/test/dm/video.c
+++ b/test/dm/video.c
@@ -7,6 +7,7 @@
#include <common.h>
#include <bzlib.h>
#include <dm.h>
+#include <malloc.h>
#include <mapmem.h>
#include <os.h>
#include <video.h>