test: log: Give tests names instead of numbers
[platform/kernel/u-boot.git] / test / dm / timer.c
1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * Copyright (C) 2015 Thomas Chou <thomas@wytron.com.tw>
4  */
5
6 #include <common.h>
7 #include <dm.h>
8 #include <timer.h>
9 #include <dm/test.h>
10 #include <dm/device-internal.h>
11 #include <test/test.h>
12 #include <test/ut.h>
13 #include <asm/cpu.h>
14
15 /*
16  * Basic test of the timer uclass.
17  */
18 static int dm_test_timer_base(struct unit_test_state *uts)
19 {
20         struct udevice *dev;
21
22         ut_assertok(uclass_get_device_by_name(UCLASS_TIMER, "timer@0", &dev));
23         ut_asserteq(1000000, timer_get_rate(dev));
24
25         return 0;
26 }
27 DM_TEST(dm_test_timer_base, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
28
29 /*
30  * Test of timebase fallback
31  */
32 static int dm_test_timer_timebase_fallback(struct unit_test_state *uts)
33 {
34         struct udevice *dev;
35
36         cpu_sandbox_set_current("cpu-test1");
37         ut_assertok(uclass_get_device_by_name(UCLASS_TIMER, "timer@1", &dev));
38         ut_asserteq(3000000, timer_get_rate(dev));
39         ut_assertok(device_remove(dev, DM_REMOVE_NORMAL));
40
41         cpu_sandbox_set_current("cpu-test2");
42         ut_assertok(uclass_get_device_by_name(UCLASS_TIMER, "timer@1", &dev));
43         ut_asserteq(2000000, timer_get_rate(dev));
44
45         cpu_sandbox_set_current("cpu-test1");
46
47         return 0;
48 }
49 DM_TEST(dm_test_timer_timebase_fallback,
50         UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);