]> git.ipfire.org Git - thirdparty/u-boot.git/blame - test/dm/cpu.c
test: Remove <common.h> and add needed includes
[thirdparty/u-boot.git] / test / dm / cpu.c
CommitLineData
fa44b533
MS
1// SPDX-License-Identifier: GPL-2.0+
2/*
3 * (C) Copyright 2018
4 * Mario Six, Guntermann & Drunck GmbH, mario.six@gdsys.cc
5 */
6
fa44b533 7#include <dm.h>
f7ae49fc 8#include <log.h>
fa44b533
MS
9#include <dm/test.h>
10#include <dm/uclass-internal.h>
11#include <cpu.h>
0e1fad43 12#include <test/test.h>
fa44b533
MS
13#include <test/ut.h>
14
15static int dm_test_cpu(struct unit_test_state *uts)
16{
17 struct udevice *dev;
18 char text[128];
19 struct cpu_info info;
20
21 ut_assertok(cpu_probe_all());
22
23 /* Check that cpu_probe_all really activated all CPUs */
24 for (uclass_find_first_device(UCLASS_CPU, &dev);
25 dev;
26 uclass_find_next_device(&dev))
73466df3 27 ut_assert(dev_get_flags(dev) & DM_FLAG_ACTIVATED);
fa44b533 28
8ae8da10 29 ut_assertok(uclass_get_device_by_name(UCLASS_CPU, "cpu@1", &dev));
143f0eed
PF
30 ut_asserteq_ptr(cpu_get_current_dev(), dev);
31 ut_asserteq(cpu_is_current(dev), 1);
fa44b533
MS
32
33 ut_assertok(cpu_get_desc(dev, text, sizeof(text)));
34 ut_assertok(strcmp(text, "LEG Inc. SuperMegaUltraTurbo CPU No. 1"));
35
36 ut_assertok(cpu_get_info(dev, &info));
37 ut_asserteq(info.cpu_freq, 42 * 42 * 42 * 42 * 42);
38 ut_asserteq(info.features, 0x42424242);
25a9be71 39 ut_asserteq(info.address_width, IS_ENABLED(CONFIG_PHYS_64BIT) ? 64 : 32);
fa44b533
MS
40
41 ut_asserteq(cpu_get_count(dev), 42);
42
43 ut_assertok(cpu_get_vendor(dev, text, sizeof(text)));
44 ut_assertok(strcmp(text, "Languid Example Garbage Inc."));
45
46 return 0;
47}
48
e180c2b1 49DM_TEST(dm_test_cpu, UT_TESTF_SCAN_FDT);