1
2
3
4
5
6#include <common.h>
7#include <serial.h>
8#include <dm.h>
9#include <dm/test.h>
10#include <test/ut.h>
11
12static int dm_test_serial(struct unit_test_state *uts)
13{
14 struct serial_device_info info_serial = {0};
15 struct udevice *dev_serial;
16 uint value_serial;
17
18 ut_assertok(uclass_get_device_by_name(UCLASS_SERIAL, "serial",
19 &dev_serial));
20
21 ut_assertok(serial_tstc());
22
23
24
25
26 ut_assertok(serial_setconfig(dev_serial, SERIAL_DEFAULT_CONFIG));
27 ut_assertok(serial_getconfig(dev_serial, &value_serial));
28 ut_assert(value_serial == SERIAL_DEFAULT_CONFIG);
29 ut_assertok(serial_getinfo(dev_serial, &info_serial));
30 ut_assert(info_serial.type == SERIAL_CHIP_UNKNOWN);
31 ut_assert(info_serial.addr == SERIAL_DEFAULT_ADDRESS);
32
33
34
35 ut_asserteq(-EINVAL, serial_getconfig(dev_serial, NULL));
36 ut_asserteq(-EINVAL, serial_getinfo(dev_serial, NULL));
37
38
39
40
41 ut_asserteq(-ENOTSUPP,
42 serial_setconfig(dev_serial,
43 SERIAL_CONFIG(SERIAL_PAR_ODD,
44 SERIAL_8_BITS,
45 SERIAL_ONE_STOP)));
46
47
48
49
50 ut_asserteq(-ENOTSUPP,
51 serial_setconfig(dev_serial,
52 SERIAL_CONFIG(SERIAL_PAR_NONE,
53 SERIAL_6_BITS,
54 SERIAL_ONE_STOP)));
55
56
57
58
59
60 ut_asserteq(-ENOTSUPP,
61 serial_setconfig(dev_serial,
62 SERIAL_CONFIG(SERIAL_PAR_NONE,
63 SERIAL_8_BITS,
64 SERIAL_TWO_STOP)));
65
66 return 0;
67}
68
69DM_TEST(dm_test_serial, DM_TESTF_SCAN_FDT);
70