tests:serial: Add proof of concept serial test
RFC 1/1 tests:serial: Add proof of concept serial test
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
engine/overlays/base/base-board.fuegoclass +8 -0
@@ -80,3 +80,11 @@ function ov_transport_cmd() { ;; esac } + +function ov_board_setup() { + return +} + +function ov_board_teardown() { + return +}
engine/tests/Functional.serial_rx/Functional.serial_rx.spec new file +12 -0
@@ -0,0 +1,12 @@ +{ + "testName": "Functional.serial_rx", + "specs": + [ + { + "name" : "default", + "BAUDRATES" : "9600 115200", + "DUT_SERIAL_DEV" : "/dev/ttyPS0", + "HOST_SERIAL_DEV": "/dev/ttyS0" + } + ] +}
engine/tests/Functional.serial_rx/serial_rx.sh new file +59 -0
59 lines not on this page · raw message
Signature · 1 line
2.7.4
Quoted 7 lines
-----Original Message-----
From: Rafael Gago on Tuesday, May 16, 2017 4:06 AMThis test is even simpler than the previous one, as it doesn't require new synchronization primitives at all.
Thanks for this. I modified the filenames and spec file to the new conventions in the upcoming v1.2 release, and added this to my 'next' branch. I think it's a good enough proof of concept that I think it's worth having in our set of tests, even though I haven't tested it myself yet.
In the long run, I still think that it would be useful to have a default DUT_SERIAL_DEV defined in the board file, and has the test use that, if one is not defined by the spec.
Thanks!
-- Tim
Quoted 127 lines
--- 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.shengine/overlays/base/base-board.fuegoclass +8
-0@@ -80,3 +80,11 @@ function ov_transport_cmd() { ;; esac } + +function ov_board_setup() { + return +} + +function ov_board_teardown() { + return +}engine/tests/Functional.serial_rx/Functional.serial_rx.spec new file +12
-0@@ -0,0 +1,12 @@ +{ + "testName": "Functional.serial_rx", + "specs": + [ + { + "name" : "default", + "BAUDRATES" : "9600 115200", + "DUT_SERIAL_DEV" : "/dev/ttyPS0", + "HOST_SERIAL_DEV": "/dev/ttyS0" + } + ] +}engine/tests/Functional.serial_rx/serial_rx.sh new file +7
-0@@ -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)
engine/tests/Functional.serial_rx/serial_rx.sh new file +3
-0+# -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 theuser
engine/tests/Functional.serial_rx/serial_rx.sh new file +34
-0+# 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"
engine/tests/Functional.serial_rx/serial_rx.sh new file +2
-0+ cmd "nohup cat $DUT_DEV > /tmp/received &" + # cmd seems to be returning slightly before the cat startsreading
engine/tests/Functional.serial_rx/serial_rx.sh new file +2
-0+ sleep 0.3 + echo -n "$SENDATA" >$FUNCTIONAL_SERIAL_RX_HOST_SERIAL_DEV
engine/tests/Functional.serial_rx/serial_rx.sh new file +3
-0+ # kill "cat" in case that the communication failed. + noabort "cmd \"sync ; killall cat\"" + report_append "diff /tmp/received /tmp/expected && echoTEST-$RATE OK || echo TEST-$RATE FAILED"
engine/tests/Functional.serial_rx/serial_rx.sh new file +5
-0+ done +} + +function test_processing { + log_compare "$TESTDIR" "$(echo"$FUNCTIONAL_SERIAL_RX_BAUDRATES" | wc -w)" "^TEST.*OK" "p"
engine/tests/Functional.serial_rx/serial_rx.sh new file +3
-1+} + +. $FUEGO_CORE/engine/scripts/functional.sh --2.7.4
_______________________________________________
Fuego mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/fuego
Now I realize that I left modifications on "engine/overlays/base/base-board.fuegoclass".
Those changes were not meant to be on that commit. Sorry .
Quoted 3 lines
In the long run, I still think that it would be useful to have a default
DUT_SERIAL_DEVdefined in the board file, and has the test use that, if one is not defined by the spec.
You have a much more clear view of how Fuego works so I guess that you are right.
Note that there may be devices with more than one serial interface to test, e.g. rs232 + rs485. That is our case. On the host we have a 16x USB serial port hub that both supports rs232 and rs485 and dedicated lines to each board. That's why I left the values on the spec file, but it's perfectly possible that specs are not fit for that purpose.
Quoted 123 lines
---
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.shengine/overlays/base/base-board.fuegoclass +0
-0@@ -80,3 +80,11 @@ function ov_transport_cmd() { ;;esac
}engine/overlays/base/base-board.fuegoclass +8
-0+ +function ov_board_setup() { + return +} + +function ov_board_teardown() { + return +}engine/tests/Functional.serial_rx/Functional.serial_rx.spec new file +12
-0@@ -0,0 +1,12 @@ +{ + "testName": "Functional.serial_rx", + "specs": + [ + { + "name" : "default", + "BAUDRATES" : "9600 115200", + "DUT_SERIAL_DEV" : "/dev/ttyPS0", + "HOST_SERIAL_DEV": "/dev/ttyS0" + } + ] +}engine/tests/Functional.serial_rx/serial_rx.sh new file +7
-0@@ -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)
engine/tests/Functional.serial_rx/serial_rx.sh new file +3
-0+# -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 theuser
engine/tests/Functional.serial_rx/serial_rx.sh new file +34
-0+# 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"
+ doneengine/tests/Functional.serial_rx/serial_rx.sh new file +4
-0+} + +function test_processing { + log_compare "$TESTDIR" "$(echo"$FUNCTIONAL_SERIAL_RX_BAUDRATES" | wc -w)" "^TEST.*OK" "p"
engine/tests/Functional.serial_rx/serial_rx.sh new file +3
-1+} + +. $FUEGO_CORE/engine/scripts/functional.sh --2.7.4
Quoted 4 lines
_______________________________________________
Fuego mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/fuego
Fuego Info Page - Linux Foundation
lists.linuxfoundation.org
This list has discussions related to the Fuego Test Framework. To see the collection of prior postings to the list, visit the Fuego Archives.