diff options
author | Mario Six <mario.six@gdsys.cc> | 2018-08-06 10:23:44 +0200 |
---|---|---|
committer | Simon Glass <sjg@chromium.org> | 2018-09-18 08:12:21 -0600 |
commit | fa44b53398d3a7f5ed28cb83493a70cde11f8188 (patch) | |
tree | 0750fe7a155f5ecd261987cb0120d85c83bfbd1e /test | |
parent | 57370de377340b0fcb81d90a187aa8b8f3494447 (diff) | |
download | u-boot-fa44b53398d3a7f5ed28cb83493a70cde11f8188.tar.gz u-boot-fa44b53398d3a7f5ed28cb83493a70cde11f8188.tar.bz2 u-boot-fa44b53398d3a7f5ed28cb83493a70cde11f8188.zip |
test: Add tests for CPU uclass
Add a sandbox CPU driver, and some tests for the CPU uclass.
Signed-off-by: Mario Six <mario.six@gdsys.cc>
Diffstat (limited to 'test')
-rw-r--r-- | test/dm/Makefile | 1 | ||||
-rw-r--r-- | test/dm/cpu.c | 45 |
2 files changed, 46 insertions, 0 deletions
diff --git a/test/dm/Makefile b/test/dm/Makefile index 3f5a634afd..8b1ba915d0 100644 --- a/test/dm/Makefile +++ b/test/dm/Makefile @@ -47,4 +47,5 @@ obj-$(CONFIG_WDT) += wdt.o obj-$(CONFIG_AXI) += axi.o obj-$(CONFIG_MISC) += misc.o obj-$(CONFIG_DM_SERIAL) += serial.o +obj-$(CONFIG_CPU) += cpu.o endif diff --git a/test/dm/cpu.c b/test/dm/cpu.c new file mode 100644 index 0000000000..f5f1caef71 --- /dev/null +++ b/test/dm/cpu.c @@ -0,0 +1,45 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * (C) Copyright 2018 + * Mario Six, Guntermann & Drunck GmbH, mario.six@gdsys.cc + */ + +#include <common.h> +#include <dm.h> +#include <dm/test.h> +#include <dm/uclass-internal.h> +#include <cpu.h> +#include <test/ut.h> + +static int dm_test_cpu(struct unit_test_state *uts) +{ + struct udevice *dev; + char text[128]; + struct cpu_info info; + + ut_assertok(cpu_probe_all()); + + /* Check that cpu_probe_all really activated all CPUs */ + for (uclass_find_first_device(UCLASS_CPU, &dev); + dev; + uclass_find_next_device(&dev)) + ut_assert(dev->flags & DM_FLAG_ACTIVATED); + + ut_assertok(uclass_get_device_by_name(UCLASS_CPU, "cpu-test1", &dev)); + + ut_assertok(cpu_get_desc(dev, text, sizeof(text))); + ut_assertok(strcmp(text, "LEG Inc. SuperMegaUltraTurbo CPU No. 1")); + + ut_assertok(cpu_get_info(dev, &info)); + ut_asserteq(info.cpu_freq, 42 * 42 * 42 * 42 * 42); + ut_asserteq(info.features, 0x42424242); + + ut_asserteq(cpu_get_count(dev), 42); + + ut_assertok(cpu_get_vendor(dev, text, sizeof(text))); + ut_assertok(strcmp(text, "Languid Example Garbage Inc.")); + + return 0; +} + +DM_TEST(dm_test_cpu, DM_TESTF_SCAN_FDT); |