[Fuego] [RFC] tests:serial: Add proof of concept serial test
Rafael Gago
rafael.gago at gmail.com
Tue May 16 11:05:34 UTC 2017
This test is even simpler than the previous one, as it doesn't
require new synchronization primitives at all.
---
engine/overlays/base/base-board.fuegoclass | 8 +++
.../Functional.serial_rx/Functional.serial_rx.spec | 12 +++++
engine/tests/Functional.serial_rx/serial_rx.sh | 59 ++++++++++++++++++++++
3 files changed, 79 insertions(+)
create mode 100644 engine/tests/Functional.serial_rx/Functional.serial_rx.spec
create mode 100644 engine/tests/Functional.serial_rx/serial_rx.sh
diff --git a/engine/overlays/base/base-board.fuegoclass b/engine/overlays/base/base-board.fuegoclass
index 6546858..df982b0 100644
--- a/engine/overlays/base/base-board.fuegoclass
+++ b/engine/overlays/base/base-board.fuegoclass
@@ -80,3 +80,11 @@ function ov_transport_cmd() {
;;
esac
}
+
+function ov_board_setup() {
+ return
+}
+
+function ov_board_teardown() {
+ return
+}
\ No newline at end of file
diff --git a/engine/tests/Functional.serial_rx/Functional.serial_rx.spec b/engine/tests/Functional.serial_rx/Functional.serial_rx.spec
new file mode 100644
index 0000000..dd1c83c
--- /dev/null
+++ b/engine/tests/Functional.serial_rx/Functional.serial_rx.spec
@@ -0,0 +1,12 @@
+{
+ "testName": "Functional.serial_rx",
+ "specs":
+ [
+ {
+ "name" : "default",
+ "BAUDRATES" : "9600 115200",
+ "DUT_SERIAL_DEV" : "/dev/ttyPS0",
+ "HOST_SERIAL_DEV": "/dev/ttyS0"
+ }
+ ]
+}
diff --git a/engine/tests/Functional.serial_rx/serial_rx.sh b/engine/tests/Functional.serial_rx/serial_rx.sh
new file mode 100644
index 0000000..e7855d0
--- /dev/null
+++ b/engine/tests/Functional.serial_rx/serial_rx.sh
@@ -0,0 +1,59 @@
+#FUEGO_DEBUG=1
+
+# Make sure that:
+#
+# -"getty" is not running on the DUTs port under test.
+# -You have the HOST's serial device forwarded to docker (using a privileged
+# container created through "docker-create-usb-privileged-container.sh" works)
+# -The jenkins user is on the dialout group:
+# > "sudo usermod -a -G dialout jenkins",
+# you may need to restart the container (logout/login) after adding the user
+# to the dialout group.
+
+function noabort() {
+ set +e
+ eval "$@"
+ RET=$?
+ set -e
+ return $RET
+}
+
+function test_build {
+ true
+}
+
+function test_deploy {
+ true
+}
+
+function test_run {
+ assert_define FUNCTIONAL_SERIAL_RX_BAUDRATES
+ assert_define FUNCTIONAL_SERIAL_RX_DUT_SERIAL_DEV
+ assert_define FUNCTIONAL_SERIAL_RX_HOST_SERIAL_DEV
+
+ local HOST_DEV=$FUNCTIONAL_SERIAL_RX_HOST_SERIAL_DEV
+ local DUT_DEV=$FUNCTIONAL_SERIAL_RX_DUT_SERIAL_DEV
+ local SENDATA="This is a test ASCII string"
+
+ echo -n "$SENDATA" > /tmp/expected
+ put /tmp/expected /tmp
+
+ for RATE in $FUNCTIONAL_SERIAL_RX_BAUDRATES ; do
+ stty -F $HOST_DEV $RATE raw -echo -echoe -echok
+ # Receive for either SENDATA.length or 10 sec.
+ cmd "stty -F $DUT_DEV $RATE raw -echo -echoe -echok min ${#SENDATA} time 100"
+ cmd "nohup cat $DUT_DEV > /tmp/received &"
+ # cmd seems to be returning slightly before the cat starts reading
+ sleep 0.3
+ echo -n "$SENDATA" > $FUNCTIONAL_SERIAL_RX_HOST_SERIAL_DEV
+ # kill "cat" in case that the communication failed.
+ noabort "cmd \"sync ; killall cat\""
+ report_append "diff /tmp/received /tmp/expected && echo TEST-$RATE OK || echo TEST-$RATE FAILED"
+ done
+}
+
+function test_processing {
+ log_compare "$TESTDIR" "$(echo "$FUNCTIONAL_SERIAL_RX_BAUDRATES" | wc -w)" "^TEST.*OK" "p"
+}
+
+. $FUEGO_CORE/engine/scripts/functional.sh
--
2.7.4
More information about the Fuego
mailing list