blob: 5c603e1f42e9a4996131ed063681576ae0c69c7c [file] [log] [blame]
Patrice Chotardd7c09682018-08-03 15:07:41 +02001// SPDX-License-Identifier: GPL-2.0
2/*
3 * Copyright (c) 2018, STMicroelectronics
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 udevice *dev_serial;
15
16 ut_assertok(uclass_get_device_by_name(UCLASS_SERIAL, "serial",
17 &dev_serial));
18
19 ut_assertok(serial_tstc());
20 /*
21 * test with default config which is the only one supported by
22 * sandbox_serial driver
23 */
24 ut_assertok(serial_setconfig(SERIAL_DEFAULT_CONFIG));
25 /*
26 * test with a serial config which is not supported by
27 * sandbox_serial driver: test with wrong parity
28 */
29 ut_asserteq(-ENOTSUPP,
30 serial_setconfig(SERIAL_CONFIG(SERIAL_PAR_ODD,
31 SERIAL_8_BITS,
32 SERIAL_ONE_STOP)));
33 /*
34 * test with a serial config which is not supported by
35 * sandbox_serial driver: test with wrong bits number
36 */
37 ut_asserteq(-ENOTSUPP,
38 serial_setconfig(SERIAL_CONFIG(SERIAL_PAR_NONE,
39 SERIAL_6_BITS,
40 SERIAL_ONE_STOP)));
41
42 /*
43 * test with a serial config which is not supported by
44 * sandbox_serial driver: test with wrong stop bits number
45 */
46 ut_asserteq(-ENOTSUPP,
47 serial_setconfig(SERIAL_CONFIG(SERIAL_PAR_NONE,
48 SERIAL_8_BITS,
49 SERIAL_TWO_STOP)));
50
51 return 0;
52}
53
54DM_TEST(dm_test_serial, DM_TESTF_SCAN_FDT);