aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/bloblist.c2
-rw-r--r--test/dm/acpi.c1
-rw-r--r--test/dm/cpu.c2
-rw-r--r--test/dm/of_platdata.c65
-rw-r--r--test/dm/ofnode.c15
-rw-r--r--test/dm/timer.c6
-rw-r--r--test/dm/wdt.c90
-rw-r--r--test/print_ut.c2
-rw-r--r--test/py/u_boot_console_base.py4
-rw-r--r--test/ut.c26
10 files changed, 200 insertions, 13 deletions
diff --git a/test/bloblist.c b/test/bloblist.c
index 4104e6a..b48be38 100644
--- a/test/bloblist.c
+++ b/test/bloblist.c
@@ -14,7 +14,7 @@
DECLARE_GLOBAL_DATA_PTR;
-/* Declare a new compression test */
+/* Declare a new bloblist test */
#define BLOBLIST_TEST(_name, _flags) \
UNIT_TEST(_name, _flags, bloblist_test)
diff --git a/test/dm/acpi.c b/test/dm/acpi.c
index 2edab7be..6f00258 100644
--- a/test/dm/acpi.c
+++ b/test/dm/acpi.c
@@ -11,6 +11,7 @@
#include <dm.h>
#include <malloc.h>
#include <mapmem.h>
+#include <timestamp.h>
#include <version.h>
#include <tables_csum.h>
#include <version.h>
diff --git a/test/dm/cpu.c b/test/dm/cpu.c
index ed12caf..d7e596ee 100644
--- a/test/dm/cpu.c
+++ b/test/dm/cpu.c
@@ -27,7 +27,7 @@ static int dm_test_cpu(struct unit_test_state *uts)
uclass_find_next_device(&dev))
ut_assert(dev_get_flags(dev) & DM_FLAG_ACTIVATED);
- ut_assertok(uclass_get_device_by_name(UCLASS_CPU, "cpu-test1", &dev));
+ ut_assertok(uclass_get_device_by_name(UCLASS_CPU, "cpu@1", &dev));
ut_asserteq_ptr(cpu_get_current_dev(), dev);
ut_asserteq(cpu_is_current(dev), 1);
diff --git a/test/dm/of_platdata.c b/test/dm/of_platdata.c
index 0463cf0..ec41087 100644
--- a/test/dm/of_platdata.c
+++ b/test/dm/of_platdata.c
@@ -1,11 +1,14 @@
// SPDX-License-Identifier: GPL-2.0+
#include <common.h>
+#include <clk.h>
#include <dm.h>
#include <dt-structs.h>
+#include <irq.h>
#include <dm/test.h>
#include <test/test.h>
#include <test/ut.h>
+#include <asm-generic/gpio.h>
#include <asm/global_data.h>
/* Test that we can find a device using of-platdata */
@@ -27,11 +30,9 @@ static int dm_test_of_plat_props(struct unit_test_state *uts)
struct udevice *dev;
int i;
- /* Skip the clock */
- ut_assertok(uclass_first_device_err(UCLASS_MISC, &dev));
- ut_asserteq_str("sandbox_clk_test", dev->name);
+ ut_assertok(uclass_get_device_by_name(UCLASS_MISC, "sandbox_spl_test",
+ &dev));
- ut_assertok(uclass_next_device_err(&dev));
plat = dev_get_plat(dev);
ut_assert(plat->boolval);
ut_asserteq(1, plat->intval);
@@ -222,3 +223,59 @@ static int dm_test_of_plat_parent(struct unit_test_state *uts)
}
DM_TEST(dm_test_of_plat_parent, UT_TESTF_SCAN_PDATA);
#endif
+
+/* Test clocks with of-platdata */
+static int dm_test_of_plat_clk(struct unit_test_state *uts)
+{
+ struct dtd_sandbox_clk_test *plat;
+ struct udevice *dev;
+ struct clk clk;
+
+ ut_assertok(uclass_first_device_err(UCLASS_MISC, &dev));
+ ut_asserteq_str("sandbox_clk_test", dev->name);
+ plat = dev_get_plat(dev);
+
+ ut_assertok(clk_get_by_phandle(dev, &plat->clocks[0], &clk));
+ ut_asserteq_str("sandbox_fixed_clock", clk.dev->name);
+
+ return 0;
+}
+DM_TEST(dm_test_of_plat_clk, UT_TESTF_SCAN_PDATA);
+
+/* Test irqs with of-platdata */
+static int dm_test_of_plat_irq(struct unit_test_state *uts)
+{
+ struct dtd_sandbox_irq_test *plat;
+ struct udevice *dev;
+ struct irq irq;
+
+ ut_assertok(uclass_get_device_by_name(UCLASS_MISC, "sandbox_irq_test",
+ &dev));
+ plat = dev_get_plat(dev);
+
+ ut_assertok(irq_get_by_phandle(dev, &plat->interrupts_extended[0],
+ &irq));
+ ut_asserteq_str("sandbox_irq", irq.dev->name);
+
+ return 0;
+}
+DM_TEST(dm_test_of_plat_irq, UT_TESTF_SCAN_PDATA);
+
+/* Test GPIOs with of-platdata */
+static int dm_test_of_plat_gpio(struct unit_test_state *uts)
+{
+ struct dtd_sandbox_gpio_test *plat;
+ struct udevice *dev;
+ struct gpio_desc desc;
+
+ ut_assertok(uclass_get_device_by_name(UCLASS_MISC, "sandbox_gpio_test",
+ &dev));
+ plat = dev_get_plat(dev);
+
+ ut_assertok(gpio_request_by_phandle(dev, &plat->test_gpios[0], &desc,
+ GPIOD_IS_OUT));
+ ut_asserteq_str("sandbox_gpio", desc.dev->name);
+
+ return 0;
+}
+DM_TEST(dm_test_of_plat_gpio, UT_TESTF_SCAN_PDATA);
diff --git a/test/dm/ofnode.c b/test/dm/ofnode.c
index 44e51de..49efabe 100644
--- a/test/dm/ofnode.c
+++ b/test/dm/ofnode.c
@@ -318,3 +318,18 @@ static int dm_test_ofnode_get_path(struct unit_test_state *uts)
return 0;
}
DM_TEST(dm_test_ofnode_get_path, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
+
+static int dm_test_ofnode_conf(struct unit_test_state *uts)
+{
+ ut_assert(!ofnode_conf_read_bool("missing"));
+ ut_assert(ofnode_conf_read_bool("testing-bool"));
+
+ ut_asserteq(123, ofnode_conf_read_int("testing-int", 0));
+ ut_asserteq(6, ofnode_conf_read_int("missing", 6));
+
+ ut_assertnull(ofnode_conf_read_str("missing"));
+ ut_asserteq_str("testing", ofnode_conf_read_str("testing-str"));
+
+ return 0;
+}
+DM_TEST(dm_test_ofnode_conf, 0);
diff --git a/test/dm/timer.c b/test/dm/timer.c
index 70043b9..9f94d47 100644
--- a/test/dm/timer.c
+++ b/test/dm/timer.c
@@ -33,16 +33,16 @@ static int dm_test_timer_timebase_fallback(struct unit_test_state *uts)
{
struct udevice *dev;
- cpu_sandbox_set_current("cpu-test1");
+ cpu_sandbox_set_current("cpu@1");
ut_assertok(uclass_get_device_by_name(UCLASS_TIMER, "timer@1", &dev));
ut_asserteq(3000000, timer_get_rate(dev));
ut_assertok(device_remove(dev, DM_REMOVE_NORMAL));
- cpu_sandbox_set_current("cpu-test2");
+ cpu_sandbox_set_current("cpu@2");
ut_assertok(uclass_get_device_by_name(UCLASS_TIMER, "timer@1", &dev));
ut_asserteq(2000000, timer_get_rate(dev));
- cpu_sandbox_set_current("cpu-test1");
+ cpu_sandbox_set_current("cpu@1");
return 0;
}
diff --git a/test/dm/wdt.c b/test/dm/wdt.c
index 24b991d..ee615f0 100644
--- a/test/dm/wdt.c
+++ b/test/dm/wdt.c
@@ -6,11 +6,14 @@
#include <common.h>
#include <dm.h>
#include <wdt.h>
+#include <asm/gpio.h>
#include <asm/state.h>
#include <asm/test.h>
#include <dm/test.h>
#include <test/test.h>
#include <test/ut.h>
+#include <linux/delay.h>
+#include <watchdog.h>
/* Test that watchdog driver functions are called */
static int dm_test_wdt_base(struct unit_test_state *uts)
@@ -19,7 +22,8 @@ static int dm_test_wdt_base(struct unit_test_state *uts)
struct udevice *dev;
const u64 timeout = 42;
- ut_assertok(uclass_get_device(UCLASS_WDT, 0, &dev));
+ ut_assertok(uclass_get_device_by_driver(UCLASS_WDT,
+ DM_DRIVER_GET(wdt_sandbox), &dev));
ut_assertnonnull(dev);
ut_asserteq(0, state->wdt.counter);
ut_asserteq(false, state->wdt.running);
@@ -39,3 +43,87 @@ static int dm_test_wdt_base(struct unit_test_state *uts)
return 0;
}
DM_TEST(dm_test_wdt_base, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
+
+static int dm_test_wdt_gpio(struct unit_test_state *uts)
+{
+ /*
+ * The sandbox wdt gpio is "connected" to gpio bank a, offset
+ * 7. Use the sandbox back door to verify that the gpio-wdt
+ * driver behaves as expected.
+ */
+ struct udevice *wdt, *gpio;
+ const u64 timeout = 42;
+ const int offset = 7;
+ int val;
+
+ ut_assertok(uclass_get_device_by_driver(UCLASS_WDT,
+ DM_DRIVER_GET(wdt_gpio), &wdt));
+ ut_assertnonnull(wdt);
+
+ ut_assertok(uclass_get_device_by_name(UCLASS_GPIO, "base-gpios", &gpio));
+ ut_assertnonnull(gpio);
+ ut_assertok(wdt_start(wdt, timeout, 0));
+
+ val = sandbox_gpio_get_value(gpio, offset);
+ ut_assertok(wdt_reset(wdt));
+ ut_asserteq(!val, sandbox_gpio_get_value(gpio, offset));
+ ut_assertok(wdt_reset(wdt));
+ ut_asserteq(val, sandbox_gpio_get_value(gpio, offset));
+
+ ut_asserteq(-ENOSYS, wdt_stop(wdt));
+
+ return 0;
+}
+DM_TEST(dm_test_wdt_gpio, UT_TESTF_SCAN_FDT);
+
+static int dm_test_wdt_watchdog_reset(struct unit_test_state *uts)
+{
+ struct sandbox_state *state = state_get_current();
+ struct udevice *gpio_wdt, *sandbox_wdt;
+ struct udevice *gpio;
+ const u64 timeout = 42;
+ const int offset = 7;
+ uint reset_count;
+ int val;
+
+ ut_assertok(uclass_get_device_by_driver(UCLASS_WDT,
+ DM_DRIVER_GET(wdt_gpio), &gpio_wdt));
+ ut_assertnonnull(gpio_wdt);
+ ut_assertok(uclass_get_device_by_driver(UCLASS_WDT,
+ DM_DRIVER_GET(wdt_sandbox), &sandbox_wdt));
+ ut_assertnonnull(sandbox_wdt);
+ ut_assertok(uclass_get_device_by_name(UCLASS_GPIO, "base-gpios", &gpio));
+ ut_assertnonnull(gpio);
+
+ /* Neither device should be "started", so watchdog_reset() should be a no-op. */
+ reset_count = state->wdt.reset_count;
+ val = sandbox_gpio_get_value(gpio, offset);
+ watchdog_reset();
+ ut_asserteq(reset_count, state->wdt.reset_count);
+ ut_asserteq(val, sandbox_gpio_get_value(gpio, offset));
+
+ /* Start both devices. */
+ ut_assertok(wdt_start(gpio_wdt, timeout, 0));
+ ut_assertok(wdt_start(sandbox_wdt, timeout, 0));
+
+ /* Make sure both devices have just been pinged. */
+ timer_test_add_offset(100);
+ watchdog_reset();
+ reset_count = state->wdt.reset_count;
+ val = sandbox_gpio_get_value(gpio, offset);
+
+ /* The gpio watchdog should be pinged, the sandbox one not. */
+ timer_test_add_offset(30);
+ watchdog_reset();
+ ut_asserteq(reset_count, state->wdt.reset_count);
+ ut_asserteq(!val, sandbox_gpio_get_value(gpio, offset));
+
+ /* After another ~30ms, both devices should get pinged. */
+ timer_test_add_offset(30);
+ watchdog_reset();
+ ut_asserteq(reset_count + 1, state->wdt.reset_count);
+ ut_asserteq(val, sandbox_gpio_get_value(gpio, offset));
+
+ return 0;
+}
+DM_TEST(dm_test_wdt_watchdog_reset, UT_TESTF_SCAN_FDT);
diff --git a/test/print_ut.c b/test/print_ut.c
index e2bcfbe..11d8580 100644
--- a/test/print_ut.c
+++ b/test/print_ut.c
@@ -9,7 +9,7 @@
#include <display_options.h>
#include <log.h>
#include <mapmem.h>
-#include <version.h>
+#include <version_string.h>
#include <test/suites.h>
#include <test/test.h>
#include <test/ut.h>
diff --git a/test/py/u_boot_console_base.py b/test/py/u_boot_console_base.py
index 1db5da4..384fd53 100644
--- a/test/py/u_boot_console_base.py
+++ b/test/py/u_boot_console_base.py
@@ -351,13 +351,13 @@ class ConsoleBase(object):
self.p.logfile_read = self.logstream
bcfg = self.config.buildconfig
config_spl = bcfg.get('config_spl', 'n') == 'y'
- config_spl_serial_support = bcfg.get('config_spl_serial_support',
+ config_spl_serial = bcfg.get('config_spl_serial',
'n') == 'y'
env_spl_skipped = self.config.env.get('env__spl_skipped',
False)
env_spl2_skipped = self.config.env.get('env__spl2_skipped',
True)
- if config_spl and config_spl_serial_support and not env_spl_skipped:
+ if config_spl and config_spl_serial and not env_spl_skipped:
m = self.p.expect([pattern_u_boot_spl_signon] +
self.bad_patterns)
if m != 0:
diff --git a/test/ut.c b/test/ut.c
index 1eec2a5..28da417 100644
--- a/test/ut.c
+++ b/test/ut.c
@@ -121,6 +121,32 @@ int ut_check_skipline(struct unit_test_state *uts)
return 0;
}
+int ut_check_skip_to_line(struct unit_test_state *uts, const char *fmt, ...)
+{
+ va_list args;
+ int len;
+ int ret;
+
+ va_start(args, fmt);
+ len = vsnprintf(uts->expect_str, sizeof(uts->expect_str), fmt, args);
+ va_end(args);
+ if (len >= sizeof(uts->expect_str)) {
+ ut_fail(uts, __FILE__, __LINE__, __func__,
+ "unit_test_state->expect_str too small");
+ return -EOVERFLOW;
+ }
+ while (1) {
+ if (!console_record_avail())
+ return -ENOENT;
+ ret = readline_check(uts);
+ if (ret < 0)
+ return ret;
+
+ if (!strcmp(uts->expect_str, uts->actual_str))
+ return 0;
+ }
+}
+
int ut_check_console_end(struct unit_test_state *uts)
{
int ret;