1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (c) 2018, STMicroelectronics
12 static int dm_test_serial(struct unit_test_state *uts)
14 struct serial_device_info info_serial = {0};
15 struct udevice *dev_serial;
18 ut_assertok(uclass_get_device_by_name(UCLASS_SERIAL, "serial",
21 ut_assertok(serial_tstc());
23 * test with default config which is the only one supported by
24 * sandbox_serial driver
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(&info_serial));
30 ut_assert(info_serial.type == SERIAL_CHIP_UNKNOWN);
31 ut_assert(info_serial.addr == SERIAL_DEFAULT_ADDRESS);
33 * test with a parameter which is NULL pointer
35 ut_asserteq(-EINVAL, serial_getconfig(dev_serial, NULL));
36 ut_asserteq(-EINVAL, serial_getinfo(NULL));
38 * test with a serial config which is not supported by
39 * sandbox_serial driver: test with wrong parity
41 ut_asserteq(-ENOTSUPP,
42 serial_setconfig(dev_serial,
43 SERIAL_CONFIG(SERIAL_PAR_ODD,
47 * test with a serial config which is not supported by
48 * sandbox_serial driver: test with wrong bits number
50 ut_asserteq(-ENOTSUPP,
51 serial_setconfig(dev_serial,
52 SERIAL_CONFIG(SERIAL_PAR_NONE,
57 * test with a serial config which is not supported by
58 * sandbox_serial driver: test with wrong stop bits number
60 ut_asserteq(-ENOTSUPP,
61 serial_setconfig(dev_serial,
62 SERIAL_CONFIG(SERIAL_PAR_NONE,
69 DM_TEST(dm_test_serial, DM_TESTF_SCAN_FDT);