aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorPatrice Chotard <patrice.chotard@st.com>2018-08-03 15:07:41 +0200
committerTom Rini <trini@konsulko.com>2018-09-10 20:48:12 -0400
commitd7c09684d73c4831a0240ce1fcbe7644bc3ab6e7 (patch)
tree84ef39679153e3ec0ec159b5a46e597acb7e16ad /test
parentad060c052bf8593c3d21bdab1f72f5f181064972 (diff)
downloadu-boot-d7c09684d73c4831a0240ce1fcbe7644bc3ab6e7.zip
u-boot-d7c09684d73c4831a0240ce1fcbe7644bc3ab6e7.tar.gz
u-boot-d7c09684d73c4831a0240ce1fcbe7644bc3ab6e7.tar.bz2
sandbox: Add serial test
Signed-off-by: Patrice Chotard <patrice.chotard@st.com> Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'test')
-rw-r--r--test/dm/Makefile1
-rw-r--r--test/dm/serial.c54
2 files changed, 55 insertions, 0 deletions
diff --git a/test/dm/Makefile b/test/dm/Makefile
index 67c1fe6..3f5a634 100644
--- a/test/dm/Makefile
+++ b/test/dm/Makefile
@@ -46,4 +46,5 @@ obj-$(CONFIG_SPMI) += spmi.o
obj-$(CONFIG_WDT) += wdt.o
obj-$(CONFIG_AXI) += axi.o
obj-$(CONFIG_MISC) += misc.o
+obj-$(CONFIG_DM_SERIAL) += serial.o
endif
diff --git a/test/dm/serial.c b/test/dm/serial.c
new file mode 100644
index 0000000..5c603e1
--- /dev/null
+++ b/test/dm/serial.c
@@ -0,0 +1,54 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2018, STMicroelectronics
+ */
+
+#include <common.h>
+#include <serial.h>
+#include <dm.h>
+#include <dm/test.h>
+#include <test/ut.h>
+
+static int dm_test_serial(struct unit_test_state *uts)
+{
+ struct udevice *dev_serial;
+
+ ut_assertok(uclass_get_device_by_name(UCLASS_SERIAL, "serial",
+ &dev_serial));
+
+ ut_assertok(serial_tstc());
+ /*
+ * test with default config which is the only one supported by
+ * sandbox_serial driver
+ */
+ ut_assertok(serial_setconfig(SERIAL_DEFAULT_CONFIG));
+ /*
+ * test with a serial config which is not supported by
+ * sandbox_serial driver: test with wrong parity
+ */
+ ut_asserteq(-ENOTSUPP,
+ serial_setconfig(SERIAL_CONFIG(SERIAL_PAR_ODD,
+ SERIAL_8_BITS,
+ SERIAL_ONE_STOP)));
+ /*
+ * test with a serial config which is not supported by
+ * sandbox_serial driver: test with wrong bits number
+ */
+ ut_asserteq(-ENOTSUPP,
+ serial_setconfig(SERIAL_CONFIG(SERIAL_PAR_NONE,
+ SERIAL_6_BITS,
+ SERIAL_ONE_STOP)));
+
+ /*
+ * test with a serial config which is not supported by
+ * sandbox_serial driver: test with wrong stop bits number
+ */
+ ut_asserteq(-ENOTSUPP,
+ serial_setconfig(SERIAL_CONFIG(SERIAL_PAR_NONE,
+ SERIAL_8_BITS,
+ SERIAL_TWO_STOP)));
+
+ return 0;
+}
+
+DM_TEST(dm_test_serial, DM_TESTF_SCAN_FDT);